Skip to content

Commit ebec6f4

Browse files
committed
Add skipping literal blocks example to docs
1 parent 56f1a85 commit ebec6f4

File tree

1 file changed

+41
-6
lines changed

1 file changed

+41
-6
lines changed

docs/src/examples.rst

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.. _examples:
22

3+
.. highlight:: python
4+
35
Examples
46
========
57

@@ -45,7 +47,9 @@ particularly in the reference documentation itself:
4547

4648
.. autolink-examples:: lib.Knight
4749

48-
Such a table is generated with :rst:dir:`autolink-examples`::
50+
Such a table is generated with :rst:dir:`autolink-examples`:
51+
52+
.. code-block:: rst
4953
5054
.. autolink-examples:: lib.Knight
5155
@@ -60,14 +64,18 @@ The import can be hidden instead.
6064
6165
lib.Knight().taunt()
6266
63-
The previous block is produced with :rst:dir:`autolink-preface`::
67+
The previous block is produced with :rst:dir:`autolink-preface`:
68+
69+
.. code-block:: rst
6470
6571
.. autolink-preface:: import lib
6672
.. code:: python
6773
6874
lib.Knight().taunt()
6975
70-
A multiline preface can be written in the content portion of the directive::
76+
A multiline preface can be written in the content portion of the directive:
77+
78+
.. code-block:: rst
7179
7280
.. autolink-preface::
7381
@@ -96,7 +104,9 @@ the previous left off.
96104
print(knight.taunt())
97105
knight.scratch()
98106
99-
This was achieved with :rst:dir:`autolink-concat`::
107+
This was achieved with :rst:dir:`autolink-concat`:
108+
109+
.. code-block:: rst
100110
101111
.. autolink-concat:: section
102112
.. code:: python
@@ -124,7 +134,9 @@ and preventing it from being included in further sources with concatenation.
124134
import lib
125135
lib.Knight()
126136
127-
Which is done via :rst:dir:`autolink-skip`::
137+
Which is done via :rst:dir:`autolink-skip`:
138+
139+
.. code-block:: rst
128140
129141
.. autolink-skip::
130142
.. code:: python
@@ -135,6 +147,27 @@ Which is done via :rst:dir:`autolink-skip`::
135147
Skipping is supported for single blocks, sections and entire files.
136148
See :rst:dir:`autolink-skip` for more information and options.
137149

150+
151+
Skipping literal blocks
152+
^^^^^^^^^^^^^^^^^^^^^^^
153+
154+
The following example is using a literal block (``::``)
155+
which does *not* have :rst:dir:`autolink-skip` set
156+
and thus has linking::
157+
158+
import lib
159+
k1 = lib.Knight()
160+
161+
.. autolink-skip::
162+
163+
The following example is using a literal block (``::``)
164+
which *does* have :rst:dir:`autolink-skip` set
165+
in the paragraph before it and thus has no linking::
166+
167+
import lib
168+
k2 = lib.Knight()
169+
170+
138171
Autodoc integration
139172
-------------------
140173
A backreference table of the code examples that use a definition is handy
@@ -196,7 +229,9 @@ Reference tables across intersphinx work too:
196229
It seems that the reference type information is more important
197230
for Sphinx when dealing with external modules,
198231
likely because the references cannot be resolved dynamically.
199-
Please specify a ``type`` in :rst:dir:`autolink-examples`::
232+
Please specify a ``type`` in :rst:dir:`autolink-examples`:
233+
234+
.. code-block:: rst
200235
201236
.. autolink-examples:: numpy.linspace
202237
:type: func

0 commit comments

Comments
 (0)