@@ -10,6 +10,30 @@ This document describes the custom reStructuredText markup introduced by Sphinx
10
10
to support Python documentation and how it should be used.
11
11
12
12
13
+ Quick Reference
14
+ ===============
15
+
16
+ This table summarizes which markup should be used for some commonly used
17
+ elements:
18
+
19
+ ======================= =========================================== ====================
20
+ Element Markup See also
21
+ ======================= =========================================== ====================
22
+ arguments/parameters ``*arg* `` :ref: `inline-markup `
23
+ variables/literals/code ````foo`` ``, ````42`` ``, ````len(s) - 1`` `` :ref: `inline-markup `
24
+ True/False/None ````True`` ``, ````False`` ``, ````None`` `` :ref: `inline-markup `
25
+ functions definitions ``.. function:: print(*args) `` :ref: `directives `
26
+ functions references ``:func:`print` `` :ref: `roles `
27
+ reference labels ``.. _label-name: `` :ref: `doc-ref-role `
28
+ internal references ``:ref:`label-name` `` :ref: `doc-ref-role `
29
+ external links ```Link text <https://example.com>`_ `` :ref: `hyperlinks `
30
+ roles w/ custom text ``:role:`custom text <target>` `` :ref: `roles `
31
+ roles w/ only last part ``:role:`~hidden.hidden.visible` `` :ref: `roles `
32
+ roles w/o link ``:role:`!target` `` :ref: `roles `
33
+ comments ``.. a comment `` :ref: `comments `
34
+ ======================= =========================================== ====================
35
+
36
+
13
37
.. _rst-primer :
14
38
15
39
reStructuredText Primer
@@ -34,6 +58,7 @@ chunks of text separated by one or more blank lines. As in Python, indentation
34
58
is significant in reST, so all lines of the same paragraph must be left-aligned
35
59
to the same level of indentation.
36
60
61
+ .. _inline-markup :
37
62
38
63
Inline markup
39
64
-------------
@@ -42,7 +67,7 @@ The standard reST inline markup is quite simple: use
42
67
43
68
* one asterisk: ``*text* `` for emphasis (italics),
44
69
* two asterisks: ``**text** `` for strong emphasis (boldface), and
45
- * backquotes: ````text`` `` for code samples.
70
+ * backquotes: ````text`` `` for code samples, variables, and literals .
46
71
47
72
If asterisks or backquotes appear in running text and could be confused with
48
73
inline markup delimiters, they have to be escaped with a backslash.
@@ -132,6 +157,7 @@ The handling of the ``::`` marker is smart:
132
157
That way, the second sentence in the above example's first paragraph would be
133
158
rendered as "The next paragraph is a code sample:".
134
159
160
+ .. _hyperlinks :
135
161
136
162
Hyperlinks
137
163
----------
@@ -185,6 +211,7 @@ indentation. (There needs to be a blank line between explicit markup and normal
185
211
paragraphs. This may all sound a bit complicated, but it is intuitive enough
186
212
when you write it.)
187
213
214
+ .. _directives :
188
215
189
216
Directives
190
217
----------
@@ -229,12 +256,15 @@ body at the bottom of the document after a "Footnotes" rubric heading, like so::
229
256
230
257
You can also explicitly number the footnotes for better context.
231
258
259
+ .. _comments :
232
260
233
261
Comments
234
262
--------
235
263
236
- Every explicit markup block which isn't a valid markup construct (like the
237
- footnotes above) is regarded as a comment.
264
+ Every explicit markup block (starting with :literal: `.. \ `) which isn't a
265
+ :ref: `valid markup construct <directives >` is regarded as a comment::
266
+
267
+ .. This is a comment
238
268
239
269
240
270
Source encoding
@@ -636,17 +666,20 @@ The file name is relative to the current file's path. Documentation-specific
636
666
include files should be placed in the ``Doc/includes `` subdirectory.
637
667
638
668
.. _rest-inline-markup :
669
+ .. _roles :
639
670
640
- Inline markup
641
- -------------
671
+ Roles
672
+ -----
642
673
643
- As said before, Sphinx uses interpreted text roles to insert semantic markup in
644
- documents.
674
+ As :ref: `previously mentioned <inline-markup >`, Sphinx uses
675
+ interpreted text roles of the form ``:rolename:`content` ``
676
+ to insert semantic markup in documents.
645
677
646
- Names of local variables, such as function/method arguments, are an exception,
647
- they should be marked simply with `` *var* ``.
678
+ In the CPython documentation, there are a couple common cases
679
+ where simpler markup should be used:
648
680
649
- For all other roles, you have to write ``:rolename:`content` ``.
681
+ * ``*arg* `` (rendered as *arg *) for function and method arguments.
682
+ * ````True`` ``/````False`` ``/````None`` `` for ``True ``/``False ``/``None ``.
650
683
651
684
There are some additional facilities that make cross-referencing roles more
652
685
versatile:
0 commit comments