[Bf-blender-cvs] [1bf35f1b197] master: Cleanup: minor changes to sphinx_doc_gen

Campbell Barton noreply at git.blender.org
Wed Jun 1 07:49:45 CEST 2022


Commit: 1bf35f1b197a825a0411c92ca590ff875f7c5f91
Author: Campbell Barton
Date:   Wed Jun 1 15:48:20 2022 +1000
Branches: master
https://developer.blender.org/rB1bf35f1b197a825a0411c92ca590ff875f7c5f91

Cleanup: minor changes to sphinx_doc_gen

- Remove unused pymethod2sphinx.
- Correct exception string formatting.
- Define encoding for file reading with execfile(..).

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

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 0d514e0694d..bba5430cd95 100644
--- a/doc/python_api/sphinx_doc_gen.py
+++ b/doc/python_api/sphinx_doc_gen.py
@@ -552,7 +552,7 @@ def import_value_from_module(module_name, import_name):
 
 def execfile(filepath):
     global_namespace = {"__file__": filepath, "__name__": "__main__"}
-    with open(filepath) as file_handle:
+    with open(filepath, encoding="utf-8") as file_handle:
         exec(compile(file_handle.read(), filepath, 'exec'), global_namespace)
 
 
@@ -714,26 +714,6 @@ def write_indented_lines(ident, fn, text, strip=True):
             fn(ident + l + "\n")
 
 
-def pymethod2sphinx(ident, fw, identifier, py_func):
-    """
-    class method to sphinx
-    """
-    arg_str = inspect.formatargspec(*inspect.getargspec(py_func))
-    if arg_str.startswith("(self, "):
-        arg_str = "(" + arg_str[7:]
-        func_type = "method"
-    elif arg_str.startswith("(cls, "):
-        arg_str = "(" + arg_str[6:]
-        func_type = "classmethod"
-    else:
-        func_type = "staticmethod"
-
-    fw(ident + ".. %s:: %s%s\n\n" % (func_type, identifier, arg_str))
-    if py_func.__doc__:
-        write_indented_lines(ident + "   ", fw, py_func.__doc__)
-        fw("\n")
-
-
 def pyfunc2sphinx(ident, fw, module_name, type_name, identifier, py_func, is_class=True):
     """
     function or class method to sphinx
@@ -2177,7 +2157,7 @@ def write_rst_enum_items_and_index(basepath):
         fw("\n")
         for key, enum_items in rna_enum_dict.items():
             if not key.startswith("rna_enum_"):
-                raise Exception("Found RNA enum identifier that doesn't use the 'rna_enum_' prefix, found %r!", key)
+                raise Exception("Found RNA enum identifier that doesn't use the 'rna_enum_' prefix, found %r!" % key)
             key_no_prefix = key.removeprefix("rna_enum_")
             fw("   %s\n" % key_no_prefix)
 
@@ -2428,8 +2408,6 @@ def setup_monkey_patch():
 
 # Avoid adding too many changes here.
 def setup_blender():
-    import bpy
-
     # Remove handlers since the functions get included
     # in the doc-string and don't have meaningful names.
     lists_to_restore = []



More information about the Bf-blender-cvs mailing list