diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-01-22 05:04:25 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-01-22 05:04:25 +0300 |
commit | 7f1a8a947d9629d956157464814541dbb764defb (patch) | |
tree | 6d5a57068bfdceebd9beb1d677a2b5ab48291982 /release | |
parent | 68874c9aa4415a86af748c39658d078df7c1bb6c (diff) |
initial sphinx doc generation support for python and C modules.
python modules bpy.app, bpy.utils are now included in docs.
C defined python module bpy.props has its docstrings extracted and written directly into sphinx docs since the C methods cant be inspected.
added docstrings to bpy.props and improved some in bpy.utils.
will update online docs tomorrow.
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/modules/bpy/app.py | 21 | ||||
-rw-r--r-- | release/scripts/modules/bpy/utils.py | 54 |
2 files changed, 54 insertions, 21 deletions
diff --git a/release/scripts/modules/bpy/app.py b/release/scripts/modules/bpy/app.py index da45ab8eb30..8fc92175d0e 100644 --- a/release/scripts/modules/bpy/app.py +++ b/release/scripts/modules/bpy/app.py @@ -18,6 +18,27 @@ # <pep8 compliant> +""" +This module contains application values that remain unchanged during runtime. + +.. data:: version + + The Blender version as a tuple of 3 numbers. eg. (2, 50, 11) + + +.. data:: version_string + + The Blender version formatted as a string. + +.. data:: home + + The blender home directory, normally matching $HOME + +.. data:: binary_path + + The location of blenders executable, useful for utilities that spawn new instances. + +""" # constants import _bpy version = _bpy._VERSION diff --git a/release/scripts/modules/bpy/utils.py b/release/scripts/modules/bpy/utils.py index 1948a28a726..90ba9ba4c71 100644 --- a/release/scripts/modules/bpy/utils.py +++ b/release/scripts/modules/bpy/utils.py @@ -18,13 +18,18 @@ # <pep8 compliant> -import bpy -import os +""" +This module contains utility functions spesific to blender but +not assosiated with blenders internal data. +""" + +import bpy as _bpy +import os as _os def expandpath(path): if path.startswith("//"): - return os.path.join(os.path.dirname(bpy.data.filename), path[2:]) + return _os.path.join(_os.path.dirname(_bpy.data.filename), path[2:]) return path @@ -47,21 +52,23 @@ _unclean_chars = ''.join([chr(i) for i in _unclean_chars]) def clean_name(name, replace="_"): - ''' + """ + Returns a name with characters replaced that may cause problems under various circumstances, such as writing to a file. All characters besides A-Z/a-z, 0-9 are replaced with "_" or the replace argumet if defined. - ''' + """ for ch in _unclean_chars: name = name.replace(ch, replace) return name def display_name(name): - ''' - Only capitalize all lowercase names, mixed case use them as is. - should work with filenames and module names. - ''' - name_base = os.path.splitext(name)[0] + """ + Creates a display string from name to be used menus and the user interface. + Capitalize the first letter in all lowercase names, mixed case names are kept as is. + Intended for use with filenames and module names. + """ + name_base = _os.path.splitext(name)[0] # string replacements name_base = name_base.replace("_colon_", ":") @@ -75,39 +82,44 @@ def display_name(name): # base scripts -_scripts = os.path.join(os.path.dirname(__file__), os.path.pardir, os.path.pardir) -_scripts = (os.path.normpath(_scripts), ) +_scripts = _os.path.join(_os.path.dirname(__file__), _os.path.pardir, _os.path.pardir) +_scripts = (_os.path.normpath(_scripts), ) def script_paths(*args): + """ + Returns a list of valid script paths from the home directory and user preferences. + + Accepts any number of string arguments which are joined to make a path. + """ scripts = list(_scripts) # add user scripts dir - user_script_path = bpy.context.user_preferences.filepaths.python_scripts_directory + user_script_path = _bpy.context.user_preferences.filepaths.python_scripts_directory if not user_script_path: # XXX - WIN32 needs checking, perhaps better call a blender internal function. - user_script_path = os.path.join(os.path.expanduser("~"), ".blender", "scripts") + user_script_path = _os.path.join(_os.path.expanduser("~"), ".blender", "scripts") - user_script_path = os.path.normpath(user_script_path) + user_script_path = _os.path.normpath(user_script_path) - if user_script_path not in scripts and os.path.isdir(user_script_path): + if user_script_path not in scripts and _os.path.isdir(user_script_path): scripts.append(user_script_path) if not args: return scripts - subdir = os.path.join(*args) + subdir = _os.path.join(*args) script_paths = [] for path in scripts: - path_subdir = os.path.join(path, subdir) - if os.path.isdir(path_subdir): + path_subdir = _os.path.join(path, subdir) + if _os.path.isdir(path_subdir): script_paths.append(path_subdir) return script_paths -_presets = os.path.join(_scripts[0], "presets") # FIXME - multiple paths +_presets = _os.path.join(_scripts[0], "presets") # FIXME - multiple paths def preset_paths(subdir): @@ -115,4 +127,4 @@ def preset_paths(subdir): Returns a list of paths for a spesific preset. ''' - return (os.path.join(_presets, subdir), ) + return (_os.path.join(_presets, subdir), ) |