diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-06-27 22:34:27 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-06-27 22:34:27 +0400 |
commit | 768ecb1ba90b964ff1eeae8798889d0b07dea741 (patch) | |
tree | 9eb6d26b0c46aa97c667046723639e33721d6085 /source/blender/python | |
parent | 650de24271501bddce1c0782ea071e9d8727101a (diff) |
api reference docs: include bpy.data in the main page since its used everywhere.
since this isnt a module its self its a little odd to do this but toctree cant make arbitrary cross-references.
Also added some usage examples: http://www.blender.org/documentation/250PythonDoc/bpy.data.html
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/doc/examples/bpy.data.py | 28 | ||||
-rw-r--r-- | source/blender/python/doc/sphinx_doc_gen.py | 38 | ||||
-rwxr-xr-x | source/blender/python/doc/sphinx_doc_gen.sh | 2 |
3 files changed, 60 insertions, 8 deletions
diff --git a/source/blender/python/doc/examples/bpy.data.py b/source/blender/python/doc/examples/bpy.data.py new file mode 100644 index 00000000000..0c2a463c01b --- /dev/null +++ b/source/blender/python/doc/examples/bpy.data.py @@ -0,0 +1,28 @@ +import bpy + + +# print all objects +for obj in bpy.data.objects: + print(obj.name) + + +# print all scene names in a list +print(bpy.data.scenes.keys()) + + +# remove mesh Cube +if "Cube" in bpy.data.meshes: + mesh = bpy.data.meshes["Cube"] + print("removing mesh", mesh) + bpy.data.meshes.unlink(mesh) + + +# write images into a file next to the blend +file = open(bpy.data.filepath.replace(".blend", ".txt"), 'w') + +for image in bpy.data.images: + file.write("%s %dx%d\n" % (image.filepath, image.size[0], image.size[1])) + +file.close() + + diff --git a/source/blender/python/doc/sphinx_doc_gen.py b/source/blender/python/doc/sphinx_doc_gen.py index 6363e14d85c..195a91e7539 100644 --- a/source/blender/python/doc/sphinx_doc_gen.py +++ b/source/blender/python/doc/sphinx_doc_gen.py @@ -296,7 +296,7 @@ def rna2sphinx(BASEPATH): if bpy.app.build_revision != "Unknown": version_string = version_string + " r" + bpy.app.build_revision - fw("project = 'Blender 3D'\n") + fw("project = 'Blender'\n") # fw("master_doc = 'index'\n") fw("copyright = u'Blender Foundation'\n") fw("version = '%s - UNSTABLE API'\n" % version_string) @@ -323,7 +323,7 @@ def rna2sphinx(BASEPATH): fw("\n") fw("This document is an API reference for Blender %s. built %s.\n" % (version_string, bpy.app.build_date)) fw("\n") - fw("An introduction to blender and python can be found at <http://wiki.blender.org/index.php/Dev:2.5/Py/API/Intro>\n") + fw("An introduction to Blender and Python can be found at <http://wiki.blender.org/index.php/Dev:2.5/Py/API/Intro>\n") fw("\n") fw("`A PDF version of this document is also available <blender_python_reference_250.pdf>`__\n") fw("\n") @@ -350,6 +350,7 @@ def rna2sphinx(BASEPATH): fw("\n") fw(".. toctree::\n") fw(" :maxdepth: 1\n\n") + fw(" bpy.data.rst\n\n") # note: not actually a module fw(" bpy.ops.rst\n\n") fw(" bpy.types.rst\n\n") @@ -390,8 +391,8 @@ def rna2sphinx(BASEPATH): filepath = os.path.join(BASEPATH, "bpy.ops.rst") file = open(filepath, "w") fw = file.write - fw("Blender Operators (bpy.ops)\n") - fw("===========================\n\n") + fw("Operators (bpy.ops)\n") + fw("===================\n\n") fw(".. toctree::\n") fw(" :glob:\n\n") fw(" bpy.ops.*\n\n") @@ -400,14 +401,37 @@ def rna2sphinx(BASEPATH): filepath = os.path.join(BASEPATH, "bpy.types.rst") file = open(filepath, "w") fw = file.write - fw("Blender Types (bpy.types)\n") - fw("=========================\n\n") + fw("Types (bpy.types)\n") + fw("=================\n\n") fw(".. toctree::\n") fw(" :glob:\n\n") fw(" bpy.types.*\n\n") file.close() + # not actually a module, only write this file so we + # can reference in the TOC + filepath = os.path.join(BASEPATH, "bpy.data.rst") + file = open(filepath, "w") + fw = file.write + fw("Data Access (bpy.data)\n") + fw("======================\n\n") + fw(".. module:: bpy\n") + fw("\n") + fw("This module is used for all blender/python access.\n") + fw("\n") + fw(" .. literalinclude:: ../examples/bpy.data.py\n") + fw("\n") + fw(" .. data:: data\n") + fw("\n") + fw(" Access to blenders internal data\n") + fw("\n") + fw(" :type: :class:`bpy.types.Main`\n") + file.close() + + EXAMPLE_SET_USED.add("bpy.data") + + # python modules from bpy import utils as module pymodule2sphinx(BASEPATH, "bpy.utils", module, "Utilities (bpy.utils)") @@ -424,7 +448,7 @@ def rna2sphinx(BASEPATH): del module import blf as module - pymodule2sphinx(BASEPATH, "blf", module, "Blender Font Drawing (blf)") + pymodule2sphinx(BASEPATH, "blf", module, "Font Drawing (blf)") del module # game engine diff --git a/source/blender/python/doc/sphinx_doc_gen.sh b/source/blender/python/doc/sphinx_doc_gen.sh index 03fe9a2efec..4f5f55af2bd 100755 --- a/source/blender/python/doc/sphinx_doc_gen.sh +++ b/source/blender/python/doc/sphinx_doc_gen.sh @@ -8,7 +8,7 @@ SSH_HOST="ideasman42@emo.blender.org" SSH_UPLOAD="/data/www/vhosts/www.blender.org/documentation/250PythonDoc" # dont delete existing docs, now partial updates are used for quick builds. -$BLENDER -b -P ./source/blender/python/doc/sphinx_doc_gen.py +$BLENDER --background --python ./source/blender/python/doc/sphinx_doc_gen.py # html sphinx-build source/blender/python/doc/sphinx-in source/blender/python/doc/sphinx-out |