Skip to content

Commit 85c3a30

Browse files
committed
📝 Add caption and name to literalinclude directive
1 parent 23d800b commit 85c3a30

5 files changed

Lines changed: 42 additions & 6 deletions

File tree

docs/data-processing/apis/grpc/example.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ information containing a series of name-value pairs called *fields*. Here’s a
1313
simple example :download:`accounts.proto`:
1414

1515
.. literalinclude:: accounts.proto
16+
:caption: accounts.proto
17+
:name: accounts.proto
1618
:language: proto
1719
:lines: 1-7
1820

@@ -36,6 +38,8 @@ gRPC services are also defined in the ``.proto`` files, with RPC method
3638
parameters and return types specified as protocol buffer messages:
3739

3840
.. literalinclude:: accounts.proto
41+
:caption: accounts.proto
42+
:name: accounts.proto
3943
:language: proto
4044
:lines: 8-
4145

@@ -62,6 +66,8 @@ Create server
6266
For this we write the file :download:`accounts_server.py`:
6367

6468
.. literalinclude:: accounts_server.py
69+
:caption: accounts_server.py
70+
:name: accounts_server.py
6571
:language: python
6672

6773
Create client
@@ -70,6 +76,8 @@ Create client
7076
For this we create :download:`accounts_client.py`:
7177

7278
.. literalinclude:: accounts_client.py
79+
:caption: accounts_client.py
80+
:name: accounts_client.py
7381
:language: python
7482

7583
Run client and server

docs/data-processing/apis/grpc/test.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ gRPC can be tested automatically with `pytest-grpc
2020
+. Then we create a :term:`Test Fixture` for our :doc:`example` with:
2121

2222
.. literalinclude:: tests/test_accounts.py
23+
:caption: tests/test_accounts.py
24+
:name: tests/test_accounts.py
2325
:language: python
2426
:lines: 3-27
2527

docs/performance/index.rst

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Steps 2 and 3 are repeated until the assignments no longer change.
3434
A possible implementation with pure Python could look like this:
3535

3636
.. literalinclude:: py_kmeans.py
37+
:caption: py_kmeans.py
38+
:name: py_kmeans.py
3739

3840
We can create sample data with:
3941

@@ -132,7 +134,9 @@ repetitive operations into compiled code to avoid slow loops.
132134
With NumPy we can do without some loops:
133135

134136
.. literalinclude:: np_kmeans.py
135-
:lines: 1-8
137+
:caption: np_kmeans.py
138+
:name: np_kmeans.py
139+
:lines: 1-8
136140

137141
The advantages of NumPy are that the Python overhead only occurs per array and
138142
not per array element. However, because NumPy uses a specific language for array
@@ -149,7 +153,9 @@ Special data structures
149153
This way you can also bypass the loop in the ``compute_centers`` method:
150154

151155
.. literalinclude:: pd_kmeans.py
152-
:lines: 2-4, 11-15
156+
:caption: pd_kmeans.py
157+
:name: pd_kmeans.py
158+
:lines: 2-4, 11-15
153159

154160
`scipy.spatial <https://docs.scipy.org/doc/scipy/reference/spatial.html>`_
155161
for spatial queries like distances, nearest neighbours, k-Means :abbr:`etc
@@ -158,7 +164,9 @@ Special data structures
158164
Our ``find_labels`` method can then be written more specifically:
159165

160166
.. literalinclude:: sp_kmeans.py
161-
:lines: 4-10
167+
:caption: sp_kmeans.py
168+
:name: sp_kmeans.py
169+
:lines: 4-10
162170

163171
`scipy.sparse <https://docs.scipy.org/doc/scipy/reference/sparse.html>`_
164172
`sparse matrices <https://en.wikipedia.org/wiki/Sparse_matrix>`_
@@ -214,7 +222,9 @@ cumbersome.
214222
Our example could then look like this:
215223

216224
.. literalinclude:: cy_kmeans.pyx
217-
:lines: 1-28
225+
:caption: cy_kmeans.pyx
226+
:name: cy_kmeans.pyx
227+
:lines: 1-28
218228

219229
.. seealso::
220230
* `Cython Tutorials
@@ -227,7 +237,9 @@ Numba
227237
scientific Python and NumPy code into fast machine code, for example:
228238

229239
.. literalinclude:: nb_kmeans.py
230-
:lines: 1-25
240+
:caption: nb_kmeans.py
241+
:name: nb_kmeans.py
242+
:lines: 1-25
231243

232244
However, Numba requires `LLVM <https://en.wikipedia.org/wiki/LLVM>`_ and some
233245
Python constructs are not supported.
@@ -263,7 +275,9 @@ can distribute tasks in a cluster. In doing so, they have different focuses:
263275
Our example could look like this with Dask:
264276

265277
.. literalinclude:: ds_kmeans.py
266-
:lines: 1-32
278+
:caption: ds_kmeans.py
279+
:name: ds_kmeans.py
280+
:lines: 1-32
267281

268282
.. toctree::
269283
:hidden:

docs/productive/git/install-config.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ Then we can use :doc:`pandas:reference/api/pandas.DataFrame.to_csv` in
114114
:file:`exceltocsv.py` to convert the Excel files:
115115

116116
.. literalinclude:: exceltocsv.py
117+
:caption: exceltocsv.py
118+
:name: exceltocsv.py
117119
:language: python
118120

119121
Then the following section is added to the global Git configuration

docs/web/dashboards/panel/fastapi.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ up some of the basic configuration in :download:`fastAPI/main.py`:
1818
#. First, we import all the necessary elements:
1919

2020
.. literalinclude:: fastAPI/main.py
21+
:caption: fastAPI/main.py
22+
:name: fastAPI/main.py
2123
:linenos:
2224
:lines: 1-3, 5-7
2325

@@ -41,6 +43,8 @@ up some of the basic configuration in :download:`fastAPI/main.py`:
4143
the following content, for example:
4244

4345
.. literalinclude:: fastAPI/templates/base.html
46+
:caption: fastAPI/templates/base.html
47+
:name: fastAPI/templates/base.html
4448
:language: html
4549
:linenos:
4650
:lines: 1-
@@ -72,20 +76,26 @@ up some of the basic configuration in :download:`fastAPI/main.py`:
7276
a parameterised object that represents your existing code:
7377

7478
.. literalinclude:: fastAPI/sliders/sinewave.py
79+
:caption: fastAPI/sliders/sinewave.py
80+
:name: fastAPI/sliders/sinewave.py
7581
:linenos:
7682
:lines: 1-
7783

7884
:download:`fastAPI/sliders/pn_app.py`
7985
creates an app function from the ``SineWave`` class:
8086

8187
.. literalinclude:: fastAPI/sliders/pn_app.py
88+
:caption: fastAPI/sliders/pn_app.py
89+
:name: fastAPI/sliders/pn_app.py
8290
:linenos:
8391
:lines: 1-
8492

8593
#. Finally, we return to our :download:`fastAPI/main.py` and import the
8694
``createApp`` function:
8795

8896
.. literalinclude:: fastAPI/main.py
97+
:caption: fastAPI/main.py
98+
:name: fastAPI/main.py
8999
:lineno-start: 4
90100
:lines: 4
91101

0 commit comments

Comments
 (0)