From 2d1ef275f2299c71dade74743cdca0c771648333 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 14 Mar 2011 10:31:50 +0000 Subject: bpy.types.libraries.load sphinx doc & examples (doc system needed some updates). http://www.blender.org/documentation/blender_python_api_2_56_3/bpy.types.BlendDataLibraries.html#bpy.types.BlendDataLibraries.load --- .../examples/bpy.types.BlendDataLibraries.load.py | 23 ++++++++++++++++++++++ doc/python_api/sphinx_doc_gen.py | 15 +++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 doc/python_api/examples/bpy.types.BlendDataLibraries.load.py (limited to 'doc') diff --git a/doc/python_api/examples/bpy.types.BlendDataLibraries.load.py b/doc/python_api/examples/bpy.types.BlendDataLibraries.load.py new file mode 100644 index 00000000000..43e6ac90ae7 --- /dev/null +++ b/doc/python_api/examples/bpy.types.BlendDataLibraries.load.py @@ -0,0 +1,23 @@ +import bpy + +filepath = "//link_library.blend" + +# load a single scene we know the name of. +with bpy.data.libraries.load(filepath) as (data_from, data_to): + data_to.scenes = ["Scene"] + + +# load all meshes +with bpy.data.libraries.load(filepath) as (data_from, data_to): + data_to.meshes = data_from.meshes + + +# link all objects starting with 'A' +with bpy.data.libraries.load(filepath, link=True) as (data_from, data_to): + data_to.objects = [name for name in data_from.objects if name.startswith("A")] + + +# append everything +with bpy.data.libraries.load(filepath) as (data_from, data_to): + for attr in dir(data_to): + setattr(data_to, attr, getattr(data_from, attr)) diff --git a/doc/python_api/sphinx_doc_gen.py b/doc/python_api/sphinx_doc_gen.py index e10d5c5cf9a..e51ea516158 100644 --- a/doc/python_api/sphinx_doc_gen.py +++ b/doc/python_api/sphinx_doc_gen.py @@ -279,6 +279,13 @@ def py_c_func2sphinx(ident, fw, module_name, type_name, identifier, py_func, is_ fw(ident + ".. function:: %s()\n\n" % identifier) fw(ident + " " + undocumented_message(module_name, type_name, identifier)) + if is_class: + write_example_ref(ident + " ", fw, module_name + "." + type_name + "." + identifier) + else: + write_example_ref(ident + " ", fw, module_name + "." + identifier) + + fw("\n") + def pyprop2sphinx(ident, fw, identifier, py_prop): ''' @@ -356,7 +363,7 @@ def pymodule2sphinx(BASEPATH, module_name, module, title): 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. - py_c_func2sphinx("", fw, module_name, module, attribute, value, is_class=False) + py_c_func2sphinx("", fw, module_name, None, attribute, value, is_class=False) elif value_type == type: classes.append((attribute, value)) elif value_type in (bool, int, float, str, tuple): @@ -655,6 +662,12 @@ def pyrna2sphinx(BASEPATH): pyfunc2sphinx(" ", fw, identifier, py_func, is_class=True) del py_funcs, py_func + py_funcs = struct.get_py_c_functions() + py_func = None + + for identifier, py_func in py_funcs: + py_c_func2sphinx(" ", fw, "bpy.types", struct.identifier, identifier, py_func, is_class=True) + lines = [] if struct.base or _BPY_STRUCT_FAKE: -- cgit v1.2.3