mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #1706 from psav/usage_section
Added Usage section to be compatible with Cartouche
This commit is contained in:
commit
8e780a5a10
@ -261,6 +261,10 @@ class GoogleDocstring(UnicodeMixin):
|
|||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
def _consume_usage_section(self):
|
||||||
|
lines = self._dedent(self._consume_to_next_section())
|
||||||
|
return lines
|
||||||
|
|
||||||
def _consume_section_header(self):
|
def _consume_section_header(self):
|
||||||
section = next(self._line_iter)
|
section = next(self._line_iter)
|
||||||
stripped_section = section.strip(':')
|
stripped_section = section.strip(':')
|
||||||
@ -450,6 +454,13 @@ class GoogleDocstring(UnicodeMixin):
|
|||||||
use_admonition = self._config.napoleon_use_admonition_for_examples
|
use_admonition = self._config.napoleon_use_admonition_for_examples
|
||||||
return self._parse_generic_section(section, use_admonition)
|
return self._parse_generic_section(section, use_admonition)
|
||||||
|
|
||||||
|
def _parse_usage_section(self, section):
|
||||||
|
header = ['.. rubric:: Usage:', '']
|
||||||
|
block = ['.. code-block:: python', '']
|
||||||
|
lines = self._consume_usage_section()
|
||||||
|
lines = self._indent(lines, 3)
|
||||||
|
return header + block + lines + ['']
|
||||||
|
|
||||||
def _parse_generic_section(self, section, use_admonition):
|
def _parse_generic_section(self, section, use_admonition):
|
||||||
lines = self._strip_empty(self._consume_to_next_section())
|
lines = self._strip_empty(self._consume_to_next_section())
|
||||||
lines = self._dedent(lines)
|
lines = self._dedent(lines)
|
||||||
|
Loading…
Reference in New Issue
Block a user