From 2e6e92cf50f3f0845757e1bd6afe8814e93d13f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Sun, 1 Feb 2015 14:00:37 +0100 Subject: 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. --- doc/python_api/sphinx_doc_gen.py | 12 +++++++++--- 1 file 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("__")] -- cgit v1.2.3