diff options
author | Campbell Barton <campbell@blender.org> | 2022-06-01 08:48:20 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-06-01 08:48:20 +0300 |
commit | 1bf35f1b197a825a0411c92ca590ff875f7c5f91 (patch) | |
tree | 64b14724b173d0a27871d6ad68fe3e24b2f2b386 | |
parent | 61a7e5be186c911e6a5cbf92f4ced2670deb3af9 (diff) |
Cleanup: minor changes to sphinx_doc_gen
- Remove unused pymethod2sphinx.
- Correct exception string formatting.
- Define encoding for file reading with execfile(..).
-rw-r--r-- | doc/python_api/sphinx_doc_gen.py | 26 |
1 files changed, 2 insertions, 24 deletions
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 = [] |