Debian Codegraph @

docs/restructuredtext_demo/__init__.py

raw
1 r"""
2 Few general reStructuredText formating markups are documented here.
3
4 reStructuredText code related formating are demonstrated in the `demo_restructuredtext_module`.
5
6 Many examples are copied from `the docutils quickref
7 <https://docutils.sourceforge.io/docs/user/rst/quickref.html>`_.
8
9 Scope and Purpose
10 =================
11
12 Sample package for describing and demonstrating ``pydoctor`` HTML API rendering for **reStructuredText** based documentation.
13
14 Try to keep the example as condensed as possible.
15
16 - Make it easy to review HTML rendering.
17 - Cover all most common reStructuredText markup.
18 Like the usage of list with various indentation types.
19 - Have it build as part of our continuous integration tests.
20 To ensure we don't introduce regressions.
21
22 .. note:: Even if most of the structural (i.e. not inline) reST markup appears to ressemble Epytext markup,
23 blank lines are often needed where Epytext allowed no blank line after parent element. Indentation
24 is also much more important, lists content and child items must be correctly indented.
25
26 Titles
27 ======
28
29 Level 2
30 -------
31
32 Level 3
33 ~~~~~~~
34
35 Level 4
36 ^^^^^^^
37
38 Level 5
39 !!!!!!!
40
41 Lists
42 =====
43
44 reStructuredText supports both ordered and unordered lists.
45 A list consists of one or more consecutive list items with the same indentation.
46 Each list item is marked by a bullet.
47 The bullet for unordered list items is a single dash character (``-``).
48 Bullets for ordered list items consist of a series of numbers followed by periods,
49 such as ``12.`` or ``1.2.8.``.
50
51 Ordered list example:
52
53 1. This is an ordered list item.
54 2. This is a another ordered list
55 item.
56 3. This is a third list item. Note that
57 the paragraph may be indented more
58 than the bullet.
59
60 Example of unordered list:
61
62 - This is an ordered list item.
63 - This is a another ordered list
64 item.
65
66 Example of complex list:
67
68 1. This is a list item.
69
70 - This is a sublist.
71 - The sublist contains two
72 items.
73
74 - The second item of the
75 sublist has its own sublist.
76
77 2. This list item contains two
78 paragraphs and a doctest block.
79
80 >>> print 'This is a doctest block'
81 This is a doctest block
82
83 This is the second paragraph.
84
85
86 Literal Blocks
87 ==============
88
89 Literal blocks are used to represent "preformatted" text.
90 Everything within a literal block should be displayed exactly as it appears in plaintext.
91
92 - Spaces and newlines are preserved.
93 - Text is shown in a monospaced font.
94 - Inline markup is not detected.
95
96 Literal blocks are introduced by paragraphs ending in the special sequence ``::``.
97 Literal blocks end at the first line whose indentation is equal to or less than that of the paragraph that introduces them.
98
99 The following is a literal block::
100
101 Literal /
102 / **Block**
103
104
105 Doctest Blocks
106 ==============
107
108 - contain examples consisting of Python expressions and their output
109 - can be used by the doctest module to test the documented object
110 - begin with the special sequence ``>>>``
111 - are delimited from surrounding blocks by blank lines
112 - may not contain blank lines
113
114 The following is a doctest block inside a block quote (automatically added because of indentation):
115
116 >>> print (1+3,
117 ... 3+5)
118 (4, 8)
119 >>> 'a-b-c-d-e'.split('-')
120 ['a', 'b', 'c', 'd', 'e']
121
122 This is a paragraph following the doctest block.
123
124
125 Python code Blocks
126 ==================
127
128 Using reStructuredText markup it is possible to specify Python code snippets in a ``.. python::`` directive .
129
130 If the Python prompt gets in your way when you try to copy and paste and you are not interested in self-testing docstrings,
131 the
132
133 This will let you obtain a simple block of colorized text:
134
135 .. python::
136
137 def fib(n):
138 '''Print a Fibonacci series.'''
139 a, b = 0, 1
140 while b < n:
141 print b,
142 a, b = b, a+b
143
144
145 Inline Markup
146 =============
147
148 reStructuredText defines a lot of inline markup, here's a few of the most common:
149
150 - *Italicized text*
151 - **Bold-faced text**
152 - ``Source code``
153 - `subprocess.Popen` (Interpreted text: used for cross-referencing python objects)
154
155 .. note::
156 Inline markup cannot be nested.
157 A workaround is to use the ``.. replace::`` directive:
158
159 I recommend you try |Python|_.
160
161 .. |Python| replace:: **Python**, *the* best language around
162
163 URLs
164 ====
165
166 The inline markup construct ```text <url>`_`` is used to create links to external URLs and URIs.
167 'text' is the text that should be displayed for the link, and 'url' is the target of the link.
168 If you wish to use the URL as the text for the link, you can simply write the URL as is.
169
170 The following example illustrates how URLs can be used:
171
172 - http://www.python.org (A standalone hyperlink.)
173 - `docutils quickref
174 <https://docutils.sourceforge.io/docs/user/rst/quickref.html>`_
175 - External hyperlinks with substitution, like Python_.
176
177 .. _Python: http://www.python.org/
178
179
180 Admonitions
181 ===========
182
183 .. note:: This is just a info.
184
185 .. tip:: This is good for you.
186
187 .. hint:: This too.
188
189 .. important:: Important information here.
190
191 .. warning:: This should be taken seriouly.
192
193 .. attention:: Beware.
194
195 .. caution:: This should be taken very seriouly.
196
197 .. danger:: This function is a security whole!
198
199 .. error:: This is not right.
200
201 .. raw:: html
202
203 <style>
204 .rst-admonition-purple {
205 background-color: plum ! important;
206 }
207 .rst-admonition-purple p.rst-admonition-title{
208 color: purple ! important;
209 }
210 </style>
211
212 .. admonition:: Purple
213
214 This needs additionnal CSS for the new "rst-admonition-purple" class.
215 Include additional CSS by defining a raw block::
216
217 .. raw:: html
218
219 <style>
220 .rst-admonition-purple {
221 background-color: plum ! important;
222 }
223 .rst-admonition-purple p.rst-admonition-title{
224 color: purple ! important;
225 }
226 </style>
227
228 .. note:: The ``! important`` is required to overrride ``apidocs.css``.
229
230
231 Symbols
232 =======
233
234 Any symbol can be rendered with the ``.. unicode::`` directive.
235
236 Copyright |copy| 2021, |MojoInc (TM)| |---|
237 all rights reserved.
238
239 .. |copy| unicode:: 0xA9 .. copyright sign
240 .. |MojoInc (TM)| unicode:: MojoInc U+2122
241 .. with trademark sign
242 .. |---| unicode:: U+02014 .. em dash
243 :trim:
244
245 Comments
246 ========
247
248 This is a commented warning::
249
250 .. .. warning:: This should not be used!
251
252 .. .. warning:: This should not be used!
253
254 Escaping
255 ========
256
257 Escaping is used to write text that would otherwise be interpreted as reStructuredText markup.
258 ReStructuredText handles escaping with the backslash character.
259
260 thisis\ *one*\ word.
261
262 .. note:: The docstring must be declared as a raw docstring: with the ``r`` prefix to prevent Python to interpret the backslashes.
263
264 See more on escaping on `docutils documentation page <https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#escaping-mechanism>`_
265
266
267
268
269 """