Rest Sphinx Cheatsheet
Rest Sphinx Cheatsheet
Lists
- This is item 1. A blank line before the first
and last items is required.
• This is item 1. A blank line before the first and last items is
required.
- This is nested list
• This is nested list
* Item 3: blank lines between items are optional. • Item 3: blank lines between items are optional.
* Item 4: Bullets are "-", "*" or "+". • Item 4: Bullets are "-", "*" or "+". Continuing text must be
Continuing text must be aligned after the aligned after the bullet and whitespace.
bullet and whitespace.
3. Enumerators are arabic numbers, single
letters, or roman numerals 3. Enumerators are arabic numbers, single letters, or roman numerals
4. List items should be sequentially numbered, 4. List items should be sequentially numbered, but need not start at 1
but need not start at 1 (although not all (although not all formatters will honour the first index).
formatters will honour the first index). 5. This item is auto-enumerated
#. This item is auto-enumerated
Term definition
Term definition
The term is a one-line phrase, and the
definition is one or more paragraphs or body The term is a one-line phrase, and the definition is one or more
elements, indented relative to the term. Blank paragraphs or body elements, indented relative to the term. Blank
lines are not allowed between term and definition. lines are not allowed between term and definition.
Sections structure
Parts
##### Parts Chapters
******** Chapters
Sections
======== Sections Subsections
----------- Subsections
Subsubsection Paragraphs
^^^^^^^^^^^^^ Subsubsection """"""""""
Paragraphs
.. [1] You can use # (autonumbered) as well. | [1] You can use # (autonumbered) as well.
.. [CIT] Any combination of letters and numbers. | [CIT] Any combination of letters and numbers.
Titles are hyperlinks
===================== Titles are hyperlinks
`Titles are hyperlinks` Titles are hyperlinks
External hyperlinks, like `Python
<http://www.python.org/>`_. External hyperlinks, like Python.
Created by: Radek Lát ([email protected]) https://github.com/radeklat/sphinx-rest-cheatsheet Revised: 2018-06-15 08:47s, v1.5.2
Substitutions (general syntax is .. |<sub>| <directive>:: <data>)
The |BH| symbol must be used on containers. |RST|
replacement example, |RST|_ documentation.
:meth: Reference a method of an object. The role text can include the type name and the method name; if it occurs within the description of a
type, the type name can be omitted. A dotted name may be used.
:attr: Reference a data attribute of an object.
:exc: Reference an exception. A dotted name may be used.
.. deprecated:: version Similar to above, but describes when the feature was deprecated. An explanation can also be given, for example to
inform the reader what should be used instead.
.. seealso:: Many sections include a list of references to module documentation or external documents.
.. rubric:: title This directive creates a paragraph heading that is not used to create a table of contents node.
.. hlist:: This directive must contain a bullet list. It will transform it into a more compact list by either distributing more than one
:columns: 3
item horizontally, or reducing spacing between items, depending on the builder. For builders that support the
* First item horizontal distribution, there is a :columns: option that specifies the number of columns; it defaults to 2.
1 http://docutils.sourceforge.net/docs/ref/rst/directives.html#image
PyCharm - Type Hinting2
Type of parameter def f(param: int):
Return type def f() -> int:
class C:
foo = None # type: List[str]
def f1():
x = f2() # type: str
return x.upper()
PyCharm - Legacy type syntax for doctrings (use in info fields lists :param or :type)
Foo Class Foo visible in the current scope T Generic type (T-Z are reserved for generics)
x.y.Bar Class Bar from x.y module T <= Foo Generic type with upper bound Foo
Foo | Bar Classes Foo or Bar Foo[T] Foo parametrized with T
(Foo, Bar) Tuple of Foo and Bar (Foo, Bar) -> Baz Function of Foo and Bar that returns Baz
list[Foo] List of Foo elements list[dict[str, int]] List of dicts from str to int (nested arguments)
dict[Foo, Bar] Dict from Foo to Bar
2 https://www.jetbrains.com/pycharm/help/type-hinting-in-pycharm.html