-
Notifications
You must be signed in to change notification settings - Fork 36
/
__init__.py
366 lines (239 loc) · 6.11 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
"""
A Sphinx example and cheat sheet.
Documenting Python Code
#######################
For documenting Python code, see ``module/__init__.py`` or the code example below:
.. code-block:: python
class AClass:
\"\"\"
Class docstring, with reference to the :mod:`module`, or another class
:class:`module.AnotherClass` and its function :func:`module.AnotherClass.foo`.
\"\"\"
class AnotherClass:
\"\"\"
Another class' docstring.
\"\"\"
def foo(arg1, arg2):
\"\"\"
A method's docstring with parameters and return value.
Use all the cool Sphinx capabilities in this description, e.g. to give
usage examples ...
:Example:
>>> another_class.foo('', AClass())
:param arg1: first argument
:type arg1: string
:param arg2: second argument
:type arg2: :class:`module.AClass`
:return: something
:rtype: string
:raises: TypeError
\"\"\"
return '' + 1
Comments
########
.. comment This is a comment!
.. code-block:: python
.. comment This is a comment!
Basic Syntax
############
*italic*
**bold**
``verbatim with special characters such as *, also useful for inline code examples``
.. code-block:: python
*italic*
**bold**
``verbatim with special characters such as *, also useful for inline code examples``
Links and Downloads
###################
Hyperlink: `David Stutz <https://davidstutz.de>`_
Download: :download:`__init__.py <../../module/__init__.py>`
.. code-block:: python
Hyperlink: `David Stutz <https://davidstutz.de>`_
Download: :download:`__init__.py <../../module/__init__.py>`
Headings
########
Level 2
*******
Level 3
=======
Level 4
-------
Level 5
^^^^^^^
Note that level 5 does not impose any styling, but is added to the table of contents
on the left.
.. code-block:: python
Headings
########
Level 2
*******
Level 3
=======
Level 4
-------
Level 5
^^^^^^^
Lists
#####
* Item 1
* Item 2
* Item 3
* Multi-
line item
1. Item 1
2. Item 2
3. Item 3
#. Item 4
#. Item 5
.. code-block:: python
* Item 1
* Item 2
* Item 3
* Multi-
line item
1. Item 1
2. Item 2
3. Item 3
#. Item 4
#. Item 5
Tables
######
Complex variant:
+------------+------------+
| Header 1 | Header 2 |
+============+============+
| Cell 1.1 | Cell 1.2 |
+------------+------------+
| Multi-column |
+------------+------------+
| Cell 3.1 | Multi-row |
+------------+ |
| Cell 4.1 | |
+------------+------------+
Another, simpler variant:
======== ========
Header 1 Header 2
======== ========
Cell 1.1 Cell 1.2
Cell 2.1 Cell 2.2
======== ========
.. code-block:: python
+------------+------------+
| Header 1 | Header 2 |
+============+============+
| Cell 1.1 | Cell 1.2 |
+------------+------------+
| Multi-column |
+------------+------------+
| Cell 3.1 | Multi-row |
+------------+ |
| Cell 4.1 | |
+------------+------------+
======== ========
Header 1 Header 2
======== ========
Cell 1.1 Cell 1.2
Cell 2.1 Cell 2.2
======== ========
Boxes
#####
.. seealso:: See also box ...
.. todo:: To do box ...
.. warning:: Warning box ...
Code
####
Simple code box::
print('done ...')
Line numbers and language option:
.. code-block:: python
:linenos:
print('done ...')
Math
####
Note that backslashes need to be escaped!
If the math isn't rendered directly, refresh using Shift + F5 or Ctrl + Shift + R (in most browsers).
Inline: :math:`\\alpha`
Block:
.. math::
\\sum_{i = 1}^n w_i x_i
.. code-block:: latex
Inline: :math:`\\alpha`
Block:
.. math::
\\sum_{i = 1}^n w_i x_i
Images and Figures
##################
Image:
.. image:: ../images/pocoo.png
Figure:
.. figure:: ../images/pocoo.png
:align: center
:alt: Pocoo
:figclass: align-center
Pocoo figure ...
.. code-block:: python
Image:
.. image:: ../images/pocoo.png
Figure:
.. figure:: ../images/pocoo.png
:align: center
:alt: Pocoo
:figclass: align-center
Pocoo figure ...
Misc Elements
#############
Topic:
.. topic:: My Topic
My topic text ...
Sidebar:
.. sidebar:: My Sidebar
My sidebar text ...
.. code-block:: python
.. topic:: My Topic
My topic text ...
.. sidebar:: My Sidebar
My sidebar text ...
Citations
#########
Citation in text [Stutz2015]_
.. [Stutz2015] D. Stutz. Superpixel Segmentation: An Evaluation. GCPR, 2015.
.. code-block:: python
Citation in text [Stutz2015]_
.. [Stutz2015] D. Stutz. Superpixel Segmentation: An Evaluation. GCPR, 2015.
Footnotes
#########
The footnote section needs to be added at the end ...
.. code-block:: python
Footnote [#f]_
.. comment:: ...
.. rubric:: Footnotes
.. [#f] Footenote text ...
Footnote [#f]_
.. rubric:: Footnotes
.. [#f] Footenote text ...
"""
class AClass:
"""
Class docstring, with reference to the :mod:`module`, or another class
:class:`module.AnotherClass` and its function :func:`module.AnotherClass.foo`.
"""
class AnotherClass:
"""
Another class' docstring.
"""
def foo(arg1, arg2):
"""
A method's docstring with parameters and return value.
Use all the cool Sphinx capabilities in this description, e.g. to give
usage examples ...
:Example:
>>> another_class.foo('', AClass())
:param arg1: first argument
:type arg1: string
:param arg2: second argument
:type arg2: :class:`module.AClass`
:return: something
:rtype: string
:raises: TypeError
"""
return '' + 1