diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-10-15 09:55:51 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-10-15 09:55:51 +0400 |
commit | 39593b9b11bb4a33fd6e2989485b4f878da04fff (patch) | |
tree | 8f971e795b5368f10b7263b9425b5d3122c9459c /doc/python_api/sphinx_doc_gen.py | |
parent | ebc2cc15c0dc6a00f47b951401eaf2c78547ffe6 (diff) |
sphinx docgen wasn't including example scripts for python methods of RNA types.
Diffstat (limited to 'doc/python_api/sphinx_doc_gen.py')
-rw-r--r-- | doc/python_api/sphinx_doc_gen.py | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index e661bb01e60..e95fa6fef35 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -466,7 +466,9 @@ ClassMethodDescriptorType = type(dict.__dict__['fromkeys']) MethodDescriptorType = type(dict.get) GetSetDescriptorType = type(int.real) StaticMethodType = type(staticmethod(lambda: None)) -from types import MemberDescriptorType +from types import (MemberDescriptorType, + MethodType, + ) _BPY_STRUCT_FAKE = "bpy_struct" _BPY_PROP_COLLECTION_FAKE = "bpy_prop_collection" @@ -629,12 +631,12 @@ def pymethod2sphinx(ident, fw, identifier, py_func): fw("\n") -def pyfunc2sphinx(ident, fw, identifier, py_func, is_class=True): +def pyfunc2sphinx(ident, fw, module_name, type_name, identifier, py_func, is_class=True): ''' function or class method to sphinx ''' - if type(py_func) == type(bpy.types.Space.draw_handler_add): + if type(py_func) == MethodType: return arg_str = inspect.formatargspec(*inspect.getargspec(py_func)) @@ -657,6 +659,11 @@ def pyfunc2sphinx(ident, fw, identifier, py_func, is_class=True): write_indented_lines(ident + " ", fw, py_func.__doc__) fw("\n") + if is_class: + write_example_ref(ident + " ", fw, module_name + "." + type_name + "." + identifier) + else: + write_example_ref(ident + " ", fw, module_name + "." + identifier) + def py_descr2sphinx(ident, fw, descr, module_name, type_name, identifier): if identifier.startswith("_"): @@ -867,7 +874,7 @@ def pymodule2sphinx(basepath, module_name, module, title): for attribute, value, value_type in module_dir_value_type: if value_type == types.FunctionType: - pyfunc2sphinx("", fw, attribute, value, is_class=False) + pyfunc2sphinx("", fw, module_name, None, attribute, value, is_class=False) elif value_type in (types.BuiltinMethodType, types.BuiltinFunctionType): # both the same at the moment but to be future proof # note: can't get args from these, so dump the string as is # this means any module used like this must have fully formatted docstrings. @@ -1316,7 +1323,7 @@ def pyrna2sphinx(basepath): py_func = None for identifier, py_func in py_funcs: - pyfunc2sphinx(" ", fw, identifier, py_func, is_class=True) + pyfunc2sphinx(" ", fw, "bpy.types", struct_id, identifier, py_func, is_class=True) del py_funcs, py_func py_funcs = struct.get_py_c_functions() |