Skip to content

Commit 8357243

Browse files
authored
DOC improve code block CSS (scikit-learn#27136)
1 parent f1273b7 commit 8357243

File tree

5 files changed

+50
-42
lines changed

5 files changed

+50
-42
lines changed

doc/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
# Specify how to identify the prompt when copying code snippets
6969
copybutton_prompt_text = r">>> |\.\.\. "
7070
copybutton_prompt_is_regexp = True
71+
copybutton_exclude = "style"
7172

7273
try:
7374
import jupyterlite_sphinx # noqa: F401

doc/developers/advanced_installation.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,13 @@ console:
229229
For 64-bit Python, configure the build environment by running the following
230230
commands in ``cmd`` or an Anaconda Prompt (if you use Anaconda):
231231

232-
::
232+
.. sphinx-prompt 1.3.0 (used in doc-min-dependencies CI task) does not support `batch` prompt type,
233+
.. so we work around by using a known prompt type and an explicit prompt text.
234+
..
235+
.. prompt:: bash C:\>
233236

234-
$ SET DISTUTILS_USE_SDK=1
235-
$ "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64
237+
SET DISTUTILS_USE_SDK=1
238+
"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvarsall.bat" x64
236239

237240
Replace ``x64`` by ``x86`` to build for 32-bit Python.
238241

doc/install.rst

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -71,32 +71,32 @@ Then run:
7171

7272
<div class="highlight">
7373
<pre class="sk-expandable" data-packager="pip" data-os="linux" data-venv="no"
74-
><span class="prompt1">pip3 install -U scikit-learn</span></pre>
75-
74+
><span>pip3 install -U scikit-learn</span></pre>
75+
7676
<pre class="sk-expandable" data-packager="pip" data-os="windows" data-venv="no"
77-
><span class="prompt1">pip install -U scikit-learn</span></pre>
78-
77+
><span>pip install -U scikit-learn</span></pre>
78+
7979
<pre class="sk-expandable" data-packager="pip" data-os="mac" data-venv="no"
80-
><span class="prompt1">pip install -U scikit-learn</span></pre>
81-
80+
><span>pip install -U scikit-learn</span></pre>
81+
8282
<pre class="sk-expandable" data-packager="pip" data-os="linux" data-venv=""
83-
><span class="prompt1">python3 -m venv sklearn-venv</span>
84-
<span class="prompt1">source sklearn-venv/bin/activate</span>
85-
<span class="prompt1">pip3 install -U scikit-learn</span></pre>
86-
83+
><span>python3 -m venv sklearn-venv</span>
84+
<span>source sklearn-venv/bin/activate</span>
85+
<span>pip3 install -U scikit-learn</span></pre>
86+
8787
<pre class="sk-expandable" data-packager="pip" data-os="windows" data-venv=""
88-
><span class="prompt1">python -m venv sklearn-venv</span>
89-
<span class="prompt1">sklearn-venv\Scripts\activate</span>
90-
<span class="prompt1">pip install -U scikit-learn</span></pre>
91-
88+
><span>python -m venv sklearn-venv</span>
89+
<span>sklearn-venv\Scripts\activate</span>
90+
<span>pip install -U scikit-learn</span></pre>
91+
9292
<pre class="sk-expandable" data-packager="pip" data-os="mac" data-venv=""
93-
><span class="prompt1">python -m venv sklearn-venv</span>
94-
<span class="prompt1">source sklearn-venv/bin/activate</span>
95-
<span class="prompt1">pip install -U scikit-learn</span></pre>
93+
><span>python -m venv sklearn-venv</span>
94+
<span>source sklearn-venv/bin/activate</span>
95+
<span>pip install -U scikit-learn</span></pre>
9696

9797
<pre class="sk-expandable" data-packager="conda"
98-
><span class="prompt1">conda create -n sklearn-env -c conda-forge scikit-learn</span>
99-
<span class="prompt1">conda activate sklearn-env</span></pre>
98+
><span>conda create -n sklearn-env -c conda-forge scikit-learn</span>
99+
<span>conda activate sklearn-env</span></pre>
100100
</div>
101101

102102
In order to check your installation you can use
@@ -105,29 +105,29 @@ In order to check your installation you can use
105105

106106
<div class="highlight">
107107
<pre class="sk-expandable" data-packager="pip" data-os="linux" data-venv="no"
108-
><span class="prompt1">python3 -m pip show scikit-learn # to see which version and where scikit-learn is installed</span>
109-
<span class="prompt1">python3 -m pip freeze # to see all packages installed in the active virtualenv</span>
110-
<span class="prompt1">python3 -c "import sklearn; sklearn.show_versions()"</span></pre>
108+
><span>python3 -m pip show scikit-learn # to see which version and where scikit-learn is installed</span>
109+
<span>python3 -m pip freeze # to see all packages installed in the active virtualenv</span>
110+
<span>python3 -c "import sklearn; sklearn.show_versions()"</span></pre>
111111

112112
<pre class="sk-expandable" data-packager="pip" data-os="windows" data-venv="no"
113-
><span class="prompt1">python -m pip show scikit-learn # to see which version and where scikit-learn is installed</span>
114-
<span class="prompt1">python -m pip freeze # to see all packages installed in the active virtualenv</span>
115-
<span class="prompt1">python -c "import sklearn; sklearn.show_versions()"</span></pre>
113+
><span>python -m pip show scikit-learn # to see which version and where scikit-learn is installed</span>
114+
<span>python -m pip freeze # to see all packages installed in the active virtualenv</span>
115+
<span>python -c "import sklearn; sklearn.show_versions()"</span></pre>
116116

117117
<pre class="sk-expandable" data-packager="pip" data-os="mac" data-venv="no"
118-
><span class="prompt1">python -m pip show scikit-learn # to see which version and where scikit-learn is installed</span>
119-
<span class="prompt1">python -m pip freeze # to see all packages installed in the active virtualenv</span>
120-
<span class="prompt1">python -c "import sklearn; sklearn.show_versions()"</span></pre>
118+
><span>python -m pip show scikit-learn # to see which version and where scikit-learn is installed</span>
119+
<span>python -m pip freeze # to see all packages installed in the active virtualenv</span>
120+
<span>python -c "import sklearn; sklearn.show_versions()"</span></pre>
121121

122122
<pre class="sk-expandable" data-packager="pip" data-venv=""
123-
><span class="prompt1">python -m pip show scikit-learn # to see which version and where scikit-learn is installed</span>
124-
<span class="prompt1">python -m pip freeze # to see all packages installed in the active virtualenv</span>
125-
<span class="prompt1">python -c "import sklearn; sklearn.show_versions()"</span></pre>
123+
><span>python -m pip show scikit-learn # to see which version and where scikit-learn is installed</span>
124+
<span>python -m pip freeze # to see all packages installed in the active virtualenv</span>
125+
<span>python -c "import sklearn; sklearn.show_versions()"</span></pre>
126126

127127
<pre class="sk-expandable" data-packager="conda"
128-
><span class="prompt1">conda list scikit-learn # to see which scikit-learn version is installed</span>
129-
<span class="prompt1">conda list # to see all packages installed in the active conda environment</span>
130-
<span class="prompt1">python -c "import sklearn; sklearn.show_versions()"</span></pre>
128+
><span>conda list scikit-learn # to see which scikit-learn version is installed</span>
129+
<span>conda list # to see all packages installed in the active conda environment</span>
130+
<span>python -c "import sklearn; sklearn.show_versions()"</span></pre>
131131
</div>
132132

133133
Note that in order to avoid potential conflicts with other packages it is
@@ -290,7 +290,7 @@ Note that those solvers are not enabled by default, please refer to the
290290
`scikit-learn-intelex <https://intel.github.io/scikit-learn-intelex/what-is-patching.html>`_
291291
documentation for more details on usage scenarios. Direct export example:
292292

293-
.. prompt:: bash $
293+
.. prompt:: python >>>
294294

295295
from sklearnex.neighbors import NearestNeighbors
296296

@@ -340,6 +340,6 @@ using the ``regedit`` tool:
340340

341341
#. Reinstall scikit-learn (ignoring the previous broken installation):
342342

343-
.. prompt:: python $
343+
.. prompt:: bash $
344344

345345
pip install --exists-action=i scikit-learn

doc/modules/array_api.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ automatically skipped. Therefore it's important to run the tests with the
125125

126126
.. prompt:: bash $
127127

128-
$ pip install array-api-compat # and other libraries as needed
129-
$ pytest -k "array_api" -v
128+
pip install array-api-compat # and other libraries as needed
129+
pytest -k "array_api" -v
130130

131131
Note on MPS device support
132132
--------------------------
@@ -143,7 +143,7 @@ To enable the MPS support in PyTorch, set the environment variable
143143

144144
.. prompt:: bash $
145145

146-
$ PYTORCH_ENABLE_MPS_FALLBACK=1 pytest -k "array_api" -v
146+
PYTORCH_ENABLE_MPS_FALLBACK=1 pytest -k "array_api" -v
147147

148148
At the time of writing all scikit-learn tests should pass, however, the
149149
computational speed is not necessarily better than with the CPU device.

doc/themes/scikit-learn-modern/static/css/theme.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,6 +1208,10 @@ div.install > input:checked + label {
12081208
display: none;
12091209
}
12101210

1211+
pre.sk-expandable > span:before {
1212+
content: "$ ";
1213+
}
1214+
12111215
/* Show hidden content when the checkbox is checked */
12121216
/* for conda */
12131217
#quickstart-conda:checked ~* [data-packager="conda"] {

0 commit comments

Comments
 (0)