diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2015-02-01 16:00:37 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2015-02-01 16:00:43 +0300 |
commit | 2e6e92cf50f3f0845757e1bd6afe8814e93d13f7 (patch) | |
tree | defa5a038703eeb98faa636a8974766263e7dded /doc | |
parent | 9fa628f35be31a18edfdb1e1fca8a6bd3b6b453c (diff) |
Documentation: Support documenting constructors in class __doc__
Python types defined in C can now start their docstring with a
`.. class:: TypeName(args)` line, to document their constructor.
In that case the documentation writer is responsible for indenting the
remainder of the docstring by 3 spaces, matching the generated
documentation.
Diffstat (limited to 'doc')
-rw-r--r-- | doc/python_api/sphinx_doc_gen.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index 7ffb4483593..344e6769524 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -937,10 +937,16 @@ def pymodule2sphinx(basepath, module_name, module, title): fw(title_string(heading, heading_char)) # May need to be its own function - fw(".. class:: %s\n\n" % type_name) if value.__doc__: - write_indented_lines(" ", fw, value.__doc__, False) - fw("\n") + if value.__doc__.startswith(".. class::"): + fw(value.__doc__) + else: + fw(".. class:: %s\n\n" % type_name) + write_indented_lines(" ", fw, value.__doc__, False) + else: + fw(".. class:: %s\n\n" % type_name) + fw("\n") + write_example_ref(" ", fw, module_name + "." + type_name) descr_items = [(key, descr) for key, descr in sorted(value.__dict__.items()) if not key.startswith("__")] |