diff options
author | Julian Eisel <julian@blender.org> | 2021-03-31 23:53:03 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2021-03-31 23:53:03 +0300 |
commit | c7904d2398fd4d43d15268c792aa15ea8ee538fe (patch) | |
tree | 484fd7f66ac59c82abd4aca18894f991b4935483 /doc | |
parent | 91b87d8d7fb8aec62faf00e5e0c3619d2753a92e (diff) | |
parent | 1a100d2d78c75c9a6ac015606cc16698e7775682 (diff) |
Merge branch 'master' into ui-asset-view-templateui-asset-view-template
Diffstat (limited to 'doc')
-rw-r--r-- | doc/python_api/sphinx_doc_gen.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index 5c6cf24a178..8be194a58a2 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -553,7 +553,7 @@ def example_extract_docstring(filepath): line_no += 1 else: file.close() - return "", 0 + return "", 0, False for line in file: line_no += 1 @@ -563,15 +563,17 @@ def example_extract_docstring(filepath): text.append(line.rstrip()) line_no += 1 + line_no_has_content = False # Skip over blank lines so the Python code doesn't have blank lines at the top. for line in file: if line.strip(): + line_no_has_content = True break line_no += 1 file.close() - return "\n".join(text), line_no + return "\n".join(text), line_no, line_no_has_content def title_string(text, heading_char, double=False): @@ -590,16 +592,18 @@ def write_example_ref(ident, fw, example_id, ext="py"): filepath = os.path.join("..", "examples", "%s.%s" % (example_id, ext)) filepath_full = os.path.join(os.path.dirname(fw.__self__.name), filepath) - text, line_no = example_extract_docstring(filepath_full) + text, line_no, line_no_has_content = example_extract_docstring(filepath_full) for line in text.split("\n"): fw("%s\n" % (ident + line).rstrip()) fw("\n") - fw("%s.. literalinclude:: %s\n" % (ident, filepath)) - if line_no > 0: - fw("%s :lines: %d-\n" % (ident, line_no)) - fw("\n") + # Some files only contain a doc-string. + if line_no_has_content: + fw("%s.. literalinclude:: %s\n" % (ident, filepath)) + if line_no > 0: + fw("%s :lines: %d-\n" % (ident, line_no)) + fw("\n") EXAMPLE_SET_USED.add(example_id) else: if bpy.app.debug: @@ -1408,7 +1412,8 @@ def pyrna2sphinx(basepath): else: fw(" .. attribute:: %s\n\n" % prop.identifier) if prop.description: - fw(" %s\n\n" % prop.description) + write_indented_lines(" ", fw, prop.description, False) + fw("\n") # special exception, can't use generic code here for enums if prop.type == "enum": |