Skip to content

Commit a357d4f

Browse files
committed
docs: Document parsers options
1 parent 6b943c8 commit a357d4f

1 file changed

Lines changed: 39 additions & 12 deletions

File tree

docs/docstrings.md

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ the text as if it is Markdown, or AsciiDoc, or reStructuredText, etc..
2525

2626
### Google-style
2727

28+
The parser accepts a few options:
29+
30+
- `ignore_init_summary`: Ignore the first line in `__init__` methods' docstrings.
31+
Useful when merging `__init__` docstring into class' docstrings
32+
with mkdocstrings-python's [`merge_init_into_class`][merge_init] option. Default: false.
33+
- `trim_doctest_flags`: Remove the [doctest flags][] written as comments in `pycon` snippets within a docstring.
34+
These flags are used to alter the behavior of [doctest][] when testing docstrings,
35+
and should not be visible in your docs. Default: true.
36+
- `warn_unknown_params`: Warn about parameters documented in docstrings that do not appear in the signature. Default: true.
37+
2838
Sections are written like this:
2939

3040
```
@@ -653,12 +663,25 @@ multiple items.
653663

654664
### Numpydoc-style
655665

666+
The parser accepts a few options:
667+
668+
- `ignore_init_summary`: Ignore the first line in `__init__` methods' docstrings.
669+
Useful when merging `__init__` docstring into class' docstrings
670+
with mkdocstrings-python's [`merge_init_into_class`][merge_init] option. Default: false.
671+
- `trim_doctest_flags`: Remove the [doctest flags][] written as comments in `pycon` snippets within a docstring.
672+
These flags are used to alter the behavior of [doctest][] when testing docstrings,
673+
and should not be visible in your docs. Default: true.
674+
- `warn_unknown_params`: Warn about parameters documented in docstrings that do not appear in the signature. Default: true.
675+
- `allow_section_blank_line`: Allow blank lines in sections' content.
676+
When false, a blank line finishes the current section.
677+
When true, single blank lines are kept as part of the section.
678+
You can terminate sections with double blank lines. Default: false.
679+
656680
Sections are written like this:
657681

658682
```
659683
section identifier
660684
------------------
661-
662685
section contents
663686
```
664687

@@ -1441,9 +1464,9 @@ Returns | ✅ | ✅ | ✅
14411464
Section | Google | Numpy | Sphinx
14421465
---------------- | ------ | ----- | ------
14431466
Attributes | ✅ | ✅ | [][issue-xref-sphinx-attributes]
1444-
Functions | [][issue-xref-google-func-cls-mod] | [][issue-xref-numpy-func-cls-mod] | /
1445-
Methods | [][issue-xref-google-func-cls-mod] | [][issue-xref-numpy-func-cls-mod] | /
1446-
Classes | [][issue-xref-google-func-cls-mod] | [][issue-xref-numpy-func-cls-mod] | /
1467+
Functions | [][issue-xref-google-func-cls] | [][issue-xref-numpy-func-cls] | /
1468+
Methods | [][issue-xref-google-func-cls] | [][issue-xref-numpy-func-cls] | /
1469+
Classes | [][issue-xref-google-func-cls] | [][issue-xref-numpy-func-cls] | /
14471470
Modules | / | / | /
14481471
Deprecated | / | / | /
14491472
Examples | / | / | /
@@ -1463,18 +1486,22 @@ Returns | ✅ | ✅ | [❌][issue-xref-sphinx-returns]
14631486
[issue-xref-sphinx-returns]: https://github.com/mkdocstrings/griffe/issues/24
14641487
[issue-xref-sphinx-warns]: https://github.com/mkdocstrings/griffe/issues/25
14651488
[issue-xref-sphinx-yields]: https://github.com/mkdocstrings/griffe/issues/26
1466-
[issue-xref-numpy-func-cls-mod]: https://github.com/mkdocstrings/griffe/issues/200
1467-
[issue-xref-google-func-cls-mod]: https://github.com/mkdocstrings/griffe/issues/199
1489+
[issue-xref-numpy-func-cls]: https://github.com/mkdocstrings/griffe/issues/200
1490+
[issue-xref-google-func-cls]: https://github.com/mkdocstrings/griffe/issues/199
14681491

14691492
### Parsing options
14701493

1471-
Option | Google | Numpy | Sphinx
1472-
---------------------------- | ------ | ----- | ------
1473-
Ignore `__init__` summary | ✅ | ✅ | [][issue-ignore-init-summary-sphinx]
1474-
Trim doctest flags | ✅ | ✅ | [][issue-trim-doctest-flags-sphinx]
1475-
Warn about unknown params | ✅ | ✅ | [][issue-warn-unknown-params-sphinx]
1476-
Allow blank line in sections | / | ✅ | /
1494+
Option | Description | Google | Numpy | Sphinx
1495+
-------------------------- | ----------------------------------------- | ------ | ----- | ------
1496+
`ignore_init_summary` | Ignore `__init__` summary. | ✅ | ✅ | [][issue-ignore-init-summary-sphinx]
1497+
`trim_doctest_flags` | Trim doctest flags. | ✅ | ✅ | [][issue-trim-doctest-flags-sphinx]
1498+
`warn_unknown_params` | Warn about unknown params. | ✅ | ✅ | [][issue-warn-unknown-params-sphinx]
1499+
`allow_section_blank_line` | Allow blank line in sections. | / | ✅ | /
14771500

14781501
[issue-ignore-init-summary-sphinx]: https://github.com/mkdocstrings/griffe/issues/45
14791502
[issue-trim-doctest-flags-sphinx]: https://github.com/mkdocstrings/griffe/issues/49
14801503
[issue-warn-unknown-params-sphinx]: https://github.com/mkdocstrings/griffe/issues/64
1504+
1505+
[merge_init]: https://mkdocstrings.github.io/python/usage/configuration/docstrings/#merge_init_into_class
1506+
[doctest flags]: https://docs.python.org/3/library/doctest.html#option-flags
1507+
[doctest]: https://docs.python.org/3/library/doctest.html#module-doctest

0 commit comments

Comments
 (0)