mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Format code blocks in docstrings
This commit is contained in:
parent
cc8161a066
commit
d102e62bc7
@ -111,7 +111,7 @@ def module_level_function(param1, param2=None, *args, **kwargs):
|
||||
|
||||
{
|
||||
'param1': param1,
|
||||
'param2': param2
|
||||
'param2': param2,
|
||||
}
|
||||
|
||||
Raises:
|
||||
|
@ -141,7 +141,7 @@ def module_level_function(param1, param2=None, *args, **kwargs):
|
||||
|
||||
{
|
||||
'param1': param1,
|
||||
'param2': param2
|
||||
'param2': param2,
|
||||
}
|
||||
|
||||
Raises
|
||||
|
@ -995,10 +995,11 @@ class Sphinx:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class math(docutils.nodes.Element): pass
|
||||
class math(docutils.nodes.Element): ...
|
||||
|
||||
def visit_math_html(self, node):
|
||||
self.body.append(self.starttag(node, 'math'))
|
||||
|
||||
def depart_math_html(self, node):
|
||||
self.body.append('</math>')
|
||||
|
||||
@ -1089,7 +1090,7 @@ class Sphinx:
|
||||
}
|
||||
|
||||
def run(self):
|
||||
...
|
||||
pass
|
||||
|
||||
def setup(app):
|
||||
app.add_directive('my-directive', MyDirective)
|
||||
@ -1347,8 +1348,9 @@ class Sphinx:
|
||||
to them using custom roles instead of generic ones (like
|
||||
:rst:role:`ref`). Example call::
|
||||
|
||||
app.add_crossref_type('topic', 'topic', 'single: %s',
|
||||
docutils.nodes.emphasis)
|
||||
app.add_crossref_type(
|
||||
'topic', 'topic', 'single: %s', docutils.nodes.emphasis
|
||||
)
|
||||
|
||||
Example usage::
|
||||
|
||||
@ -1458,7 +1460,7 @@ class Sphinx:
|
||||
app.add_js_file('example.js')
|
||||
# => <script src="_static/example.js"></script>
|
||||
|
||||
app.add_js_file('example.js', loading_method="async")
|
||||
app.add_js_file('example.js', loading_method='async')
|
||||
# => <script src="_static/example.js" async="async"></script>
|
||||
|
||||
app.add_js_file(None, body="var myVariable = 'foo';")
|
||||
|
@ -197,6 +197,7 @@ def cut_lines(
|
||||
Use like this (e.g. in the ``setup()`` function of :file:`conf.py`)::
|
||||
|
||||
from sphinx.ext.autodoc import cut_lines
|
||||
|
||||
app.connect('autodoc-process-docstring', cut_lines(4, what={'module'}))
|
||||
|
||||
This can (and should) be used in place of :confval:`automodule_skip_lines`.
|
||||
|
@ -43,7 +43,7 @@ def get_lvar_names(node: ast.AST, self: ast.arg | None = None) -> list[str]:
|
||||
This raises `TypeError` if the assignment does not create new variable::
|
||||
|
||||
ary[0] = 'foo'
|
||||
dic["bar"] = 'baz'
|
||||
dic['bar'] = 'baz'
|
||||
# => TypeError
|
||||
"""
|
||||
if self:
|
||||
|
Loading…
Reference in New Issue
Block a user