Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-04-19 05:17:21 +0300
committerCampbell Barton <campbell@blender.org>2022-04-19 05:17:58 +0300
commit76acc5e9992e3bc554dac678bf40be1d285a81e8 (patch)
tree2397c0ba18c77e865750dfec750b26b0afa6d668 /doc
parentadcce654e38307b180ebdfa3699a80018ac95f63 (diff)
PyDoc: fix including literal text immediately after function args
Literal text from examples could be included directly after function arguments, this caused a warning with mis-matching indentation.
Diffstat (limited to 'doc')
-rw-r--r--doc/python_api/sphinx_doc_gen.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py
index b074ce77a39..c21a796c43a 100644
--- a/doc/python_api/sphinx_doc_gen.py
+++ b/doc/python_api/sphinx_doc_gen.py
@@ -573,7 +573,7 @@ def example_extract_docstring(filepath):
line_no += 1
file.close()
- return "\n".join(text), line_no, line_no_has_content
+ return "\n".join(text).rstrip("\n"), line_no, line_no_has_content
def title_string(text, heading_char, double=False):
@@ -593,9 +593,13 @@ def write_example_ref(ident, fw, example_id, ext="py"):
filepath_full = os.path.join(os.path.dirname(fw.__self__.name), filepath)
text, line_no, line_no_has_content = example_extract_docstring(filepath_full)
+ if text:
+ # Ensure a blank line, needed since in some cases the indentation doesn't match the previous line.
+ # which causes Sphinx not to warn about bad indentation.
+ fw("\n")
+ for line in text.split("\n"):
+ fw("%s\n" % (ident + line).rstrip())
- for line in text.split("\n"):
- fw("%s\n" % (ident + line).rstrip())
fw("\n")
# Some files only contain a doc-string.