Skip to content

Commit 9d974a8

Browse files
committed
🎨 Fix reST syntax
1 parent 545f3ed commit 9d974a8

26 files changed

+1210
-1195
lines changed

docs/document/sphinx/docstrings.rst

Lines changed: 50 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ file ``docs/conf.py``:
2121

2222
.. code-block:: python
2323
24-
extensions = ["sphinx.ext.autodoc", ...]
24+
extensions = ["sphinx.ext.autodoc", ...]
2525
2626
If your package and its documentation are part of the same repository, they will
2727
always have the same relative position in the filesystem. In this case you can
@@ -30,21 +30,21 @@ path to the package, so:
3030

3131
.. code-block:: python
3232
33-
sys.path.insert(0, os.path.abspath(".."))
34-
import requests
33+
sys.path.insert(0, os.path.abspath(".."))
34+
import requests
3535
3636
If you have installed your Sphinx documentation in a virtual environment, you
3737
can also install your package there with:
3838

3939
.. code-block:: console
4040
41-
$ python -m pip install my.package
41+
$ python -m pip install my.package
4242
4343
or, if you want to develop the package further with:
4444

4545
.. code-block:: console
4646
47-
$ python -m pip install -e https://github.com/veit/my.package.git
47+
$ python -m pip install -e https://github.com/veit/my.package.git
4848
4949
Examples
5050
--------
@@ -73,42 +73,40 @@ The variant with types according to :pep:`484` has the advantage that type
7373
testers and IDEs can be used for static code analysis.
7474

7575
Python 3 type annotations:
76-
7776
.. code-block:: python
7877
79-
def func(arg1: int, arg2: str) -> bool:
80-
"""Summary line.
78+
def func(arg1: int, arg2: str) -> bool:
79+
"""Summary line.
8180
82-
Extended description of function.
81+
Extended description of function.
8382
84-
Args:
85-
arg1: Description of arg1
86-
arg2: Description of arg2
83+
Args:
84+
arg1: Description of arg1
85+
arg2: Description of arg2
8786
88-
Returns:
89-
Description of return value
87+
Returns:
88+
Description of return value
9089
91-
"""
92-
return True
90+
"""
91+
return True
9392
9493
Types in Docstrings:
95-
9694
.. code-block:: python
9795
98-
def func(arg1, arg2):
99-
"""Summary line.
96+
def func(arg1, arg2):
97+
"""Summary line.
10098
101-
Extended description of function.
99+
Extended description of function.
102100
103-
Args:
104-
arg1 (int): Description of arg1
105-
arg2 (str): Description of arg2
101+
Args:
102+
arg1 (int): Description of arg1
103+
arg2 (str): Description of arg2
106104
107-
Returns:
108-
bool: Description of return value
105+
Returns:
106+
bool: Description of return value
109107
110-
"""
111-
return True
108+
"""
109+
return True
112110
113111
.. note::
114112
:pep:`484#suggested-syntax-for-python-2-7-and-straddling-code` are currently
@@ -140,47 +138,45 @@ The main differences are that Google uses indentations and NumPy uses
140138
underscores:
141139

142140
Google:
143-
144141
.. code-block:: python
145142
146-
def func(arg1, arg2):
147-
"""Summary line.
143+
def func(arg1, arg2):
144+
"""Summary line.
148145
149-
Extended description of function.
146+
Extended description of function.
150147
151-
Args:
152-
arg1 (int): Description of arg1
153-
arg2 (str): Description of arg2
148+
Args:
149+
arg1 (int): Description of arg1
150+
arg2 (str): Description of arg2
154151
155-
Returns:
156-
bool: Description of return value
152+
Returns:
153+
bool: Description of return value
157154
158-
"""
159-
return True
155+
"""
156+
return True
160157
161158
NumPy:
162-
163159
.. code-block:: python
164160
165-
def func(arg1, arg2):
166-
"""Summary line.
161+
def func(arg1, arg2):
162+
"""Summary line.
167163
168-
Extended description of function.
164+
Extended description of function.
169165
170-
Parameters
171-
----------
172-
arg1 : int
173-
Description of arg1
174-
arg2 : str
175-
Description of arg2
166+
Parameters
167+
----------
168+
arg1 : int
169+
Description of arg1
170+
arg2 : str
171+
Description of arg2
176172
177-
Returns
178-
-------
179-
bool
180-
Description of return value
173+
Returns
174+
-------
175+
bool
176+
Description of return value
181177
182-
"""
183-
return True
178+
"""
179+
return True
184180
185181
You can find the detailed configuration options in
186182
`sphinxcontrib.napoleon.Config

docs/document/sphinx/intersphinx.rst

Lines changed: 47 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,26 @@ In ``docs/conf.py`` Intersphinx must be indicated as an extension:
1212

1313
.. code-block:: python
1414
15-
extensions = [
16-
"sphinx.ext.intersphinx",
17-
]
15+
extensions = [
16+
"sphinx.ext.intersphinx",
17+
]
1818
1919
External Sphinx documentation can then be specified, e.g. with:
2020

2121
.. code-block:: python
2222
23-
intersphinx_mapping = {
24-
"python": ("https://docs.python.org/3", None),
25-
"bokeh": ("https://bokeh.pydata.org/en/latest/", None),
26-
}
23+
intersphinx_mapping = {
24+
"python": ("https://docs.python.org/3", None),
25+
"bokeh": ("https://bokeh.pydata.org/en/latest/", None),
26+
}
2727
2828
However, alternative files can also be specified for an inventory, for example:
2929

3030
.. code-block:: python
3131
32-
intersphinx_mapping = {
33-
"python": ("https://docs.python.org/3", None, "python-inv.txt"),
34-
}
32+
intersphinx_mapping = {
33+
"python": ("https://docs.python.org/3", None, "python-inv.txt"),
34+
}
3535
3636
Determine link targets
3737
----------------------
@@ -41,12 +41,12 @@ for example:
4141

4242
.. code-block:: console
4343
44-
$ python -m sphinx.ext.intersphinx https://docs.python.org/3/objects.inv
45-
c:function
46-
PyAnySet_Check c-api/set.html#c.PyAnySet_Check
47-
PyAnySet_CheckExact c-api/set.html#c.PyAnySet_CheckExact
48-
PyArg_Parse c-api/arg.html#c.PyArg_Parse
49-
44+
$ python -m sphinx.ext.intersphinx https://docs.python.org/3/objects.inv
45+
c:function
46+
PyAnySet_Check c-api/set.html#c.PyAnySet_Check
47+
PyAnySet_CheckExact c-api/set.html#c.PyAnySet_CheckExact
48+
PyArg_Parse c-api/arg.html#c.PyArg_Parse
49+
5050
5151
Create a link
5252
-------------
@@ -57,17 +57,17 @@ of the following variants can be specified:
5757
:c:func:`PyArg_Parse`
5858
.. code-block:: rest
5959
60-
:c:func:`PyArg_Parse`
60+
:c:func:`PyArg_Parse`
6161
6262
:c:func:`!PyArg_Parse`
6363
.. code-block:: rest
6464
65-
:c:func:`!PyArg_Parse`
65+
:c:func:`!PyArg_Parse`
6666
6767
:c:func:`Parsing arguments <PyArg_Parse>`
6868
.. code-block:: rest
6969
70-
:c:func:`Parsing arguments <PyArg_Parse>`
70+
:c:func:`Parsing arguments <PyArg_Parse>`
7171
7272
Custom links
7373
------------
@@ -82,50 +82,48 @@ The error can be corrected with:
8282

8383
.. code-block:: console
8484
85-
$ python -m pip install sphobjinv
85+
$ python -m pip install sphobjinv
8686
8787
#. Then the original file can be downloaded with:
8888

8989
.. code-block:: console
9090
91-
$ cd docs/build/
92-
$ mkdir _intersphinx
93-
$ !$
94-
$ curl -O https://www.crummy.com/software/BeautifulSoup/bs4/doc/objects.inv
95-
$ mv objects.inv bs4_objects.inv
91+
$ cd docs/build/
92+
$ mkdir _intersphinx
93+
$ !$
94+
$ curl -O https://www.crummy.com/software/BeautifulSoup/bs4/doc/objects.inv
95+
$ mv objects.inv bs4_objects.inv
9696
9797
#. Change the Sphinx configuration ``docs/conf.py``:
9898

9999
.. code-block:: console
100100
101-
intersphinx_mapping = {
102-
103-
'bs4': ('https://www.crummy.com/software/BeautifulSoup/bs4/doc/', "_intersphinx/bs4_objects.inv")
101+
intersphinx_mapping = {
102+
103+
'bs4': ('https://www.crummy.com/software/BeautifulSoup/bs4/doc/', "_intersphinx/bs4_objects.inv")
104104
}
105105
106106
#. Convert to a text file:
107107

108108
.. code-block:: console
109109
110-
$ sphobjinv convert plain bs4_objects.inv bs4_objects.txt
110+
$ sphobjinv convert plain bs4_objects.inv bs4_objects.txt
111111
112112
#. Editing the text file
113113

114-
e.g.:
115-
116114
.. code-block:: console
117115
118-
bs4.BeautifulSoup py:class 1 index.html#beautifulsoup -
119-
bs4.BeautifulSoup.get_text py:method 1 index.html#get-text -
120-
bs4.element.Tag py:class 1 index.html#tag -
116+
bs4.BeautifulSoup py:class 1 index.html#beautifulsoup -
117+
bs4.BeautifulSoup.get_text py:method 1 index.html#get-text -
118+
bs4.element.Tag py:class 1 index.html#tag -
121119
122120
These entries can then be referenced in a Sphinx documentation with:
123121

124122
.. code-block:: rest
125123
126-
- :class:`bs4.BeautifulSoup`
127-
- :meth:`bs4.BeautifulSoup.get_text`
128-
- :class:`bs4.element.Tag`
124+
- :class:`bs4.BeautifulSoup`
125+
- :meth:`bs4.BeautifulSoup.get_text`
126+
- :class:`bs4.element.Tag`
129127
130128
.. seealso::
131129
* `Sphinx objects.inv v2 Syntax
@@ -135,13 +133,13 @@ The error can be corrected with:
135133

136134
.. code-block:: console
137135
138-
$ sphobjinv convert zlib bs4_objects.txt bs4_objects.txt
136+
$ sphobjinv convert zlib bs4_objects.txt bs4_objects.txt
139137
140138
#. Create Sphinx documentation:
141139

142140
.. code-block:: console
143141
144-
$ python -m sphinx -ab html docs/ docs/_build/
142+
$ python -m sphinx -ab html docs/ docs/_build/
145143
146144
Add roles
147145
---------
@@ -150,18 +148,18 @@ If you get an error message that a certain text role is unknown, e.g.
150148

151149
.. code-block:: console
152150
153-
WARNING: Unknown interpreted text role "confval".
151+
WARNING: Unknown interpreted text role "confval".
154152
155153
so you can add them in the ``conf.py``:
156154

157155
.. code-block:: python
158156
159-
def setup(app):
160-
# from sphinx.ext.autodoc import cut_lines
161-
# app.connect('autodoc-process-docstring', cut_lines(4, what=['module']))
162-
app.add_object_type(
163-
"confval",
164-
"confval",
165-
objname="configuration value",
166-
indextemplate="pair: %s; configuration value",
167-
)
157+
def setup(app):
158+
# from sphinx.ext.autodoc import cut_lines
159+
# app.connect('autodoc-process-docstring', cut_lines(4, what=['module']))
160+
app.add_object_type(
161+
"confval",
162+
"confval",
163+
objname="configuration value",
164+
indextemplate="pair: %s; configuration value",
165+
)

docs/document/sphinx/placeholder.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ version.
3131
As of Sphinx≥1.8, curly braces can be displayed with a backslash (``\``).
3232

3333
.. note::
34-
.. rst:role:: content
34+
.. rst:role:: content
3535
3636
This role has no special meaning by default. You can therefore use it for
3737
anything, for example also for variable names.

0 commit comments

Comments
 (0)