[Bf-blender-cvs] [28169cea3d7] master: PyDoc: avoid blank lines at the beginning of code-examples

Campbell Barton noreply at git.blender.org
Tue Dec 8 10:53:18 CET 2020


Commit: 28169cea3d722f699cba2503d3d9d99b096663af
Author: Campbell Barton
Date:   Tue Dec 8 20:49:28 2020 +1100
Branches: master
https://developer.blender.org/rB28169cea3d722f699cba2503d3d9d99b096663af

PyDoc: avoid blank lines at the beginning of code-examples

===================================================================

M	doc/python_api/sphinx_doc_gen.py

===================================================================

diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py
index b148f4c6a46..930e5b88911 100644
--- a/doc/python_api/sphinx_doc_gen.py
+++ b/doc/python_api/sphinx_doc_gen.py
@@ -551,7 +551,7 @@ def example_extract_docstring(filepath):
         file.close()
         return "", 0
 
-    for line in file.readlines():
+    for line in file:
         line_no += 1
         if line.startswith('"""'):
             break
@@ -559,6 +559,13 @@ def example_extract_docstring(filepath):
             text.append(line.rstrip())
 
     line_no += 1
+
+    # Skip over blank lines so the Python code doesn't have blank lines at the top.
+    for line in file:
+        if line.strip():
+            break
+        line_no += 1
+
     file.close()
     return "\n".join(text), line_no



More information about the Bf-blender-cvs mailing list