auto-generated py api now shows bpy.context.* items in the 'References' section of each type.
This commit is contained in:
@@ -910,36 +910,8 @@ def pymodule2sphinx(basepath, module_name, module, title):
|
|||||||
|
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
|
# Changes in blender will force errors here
|
||||||
def pycontext2sphinx(basepath):
|
context_type_map = {
|
||||||
# Only use once. very irregular
|
|
||||||
|
|
||||||
filepath = os.path.join(basepath, "bpy.context.rst")
|
|
||||||
file = open(filepath, "w", encoding="utf-8")
|
|
||||||
fw = file.write
|
|
||||||
fw(title_string("Context Access (bpy.context)", "="))
|
|
||||||
fw(".. module:: bpy.context\n")
|
|
||||||
fw("\n")
|
|
||||||
fw("The context members available depend on the area of blender which is currently being accessed.\n")
|
|
||||||
fw("\n")
|
|
||||||
fw("Note that all context values are readonly, but may be modified through the data api or by running operators\n\n")
|
|
||||||
|
|
||||||
# nasty, get strings directly from blender because there is no other way to get it
|
|
||||||
import ctypes
|
|
||||||
|
|
||||||
context_strings = (
|
|
||||||
"screen_context_dir",
|
|
||||||
"view3d_context_dir",
|
|
||||||
"buttons_context_dir",
|
|
||||||
"image_context_dir",
|
|
||||||
"node_context_dir",
|
|
||||||
"text_context_dir",
|
|
||||||
"clip_context_dir",
|
|
||||||
"sequencer_context_dir",
|
|
||||||
)
|
|
||||||
|
|
||||||
# Changes in blender will force errors here
|
|
||||||
type_map = {
|
|
||||||
"active_base": ("ObjectBase", False),
|
"active_base": ("ObjectBase", False),
|
||||||
"active_bone": ("Bone", False),
|
"active_bone": ("Bone", False),
|
||||||
"active_object": ("Object", False),
|
"active_object": ("Object", False),
|
||||||
@@ -1003,7 +975,35 @@ def pycontext2sphinx(basepath):
|
|||||||
"visible_pose_bones": ("PoseBone", True),
|
"visible_pose_bones": ("PoseBone", True),
|
||||||
"weight_paint_object": ("Object", False),
|
"weight_paint_object": ("Object", False),
|
||||||
"world": ("World", False),
|
"world": ("World", False),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def pycontext2sphinx(basepath):
|
||||||
|
# Only use once. very irregular
|
||||||
|
|
||||||
|
filepath = os.path.join(basepath, "bpy.context.rst")
|
||||||
|
file = open(filepath, "w", encoding="utf-8")
|
||||||
|
fw = file.write
|
||||||
|
fw(title_string("Context Access (bpy.context)", "="))
|
||||||
|
fw(".. module:: bpy.context\n")
|
||||||
|
fw("\n")
|
||||||
|
fw("The context members available depend on the area of blender which is currently being accessed.\n")
|
||||||
|
fw("\n")
|
||||||
|
fw("Note that all context values are readonly, but may be modified through the data api or by running operators\n\n")
|
||||||
|
|
||||||
|
# nasty, get strings directly from blender because there is no other way to get it
|
||||||
|
import ctypes
|
||||||
|
|
||||||
|
context_strings = (
|
||||||
|
"screen_context_dir",
|
||||||
|
"view3d_context_dir",
|
||||||
|
"buttons_context_dir",
|
||||||
|
"image_context_dir",
|
||||||
|
"node_context_dir",
|
||||||
|
"text_context_dir",
|
||||||
|
"clip_context_dir",
|
||||||
|
"sequencer_context_dir",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
unique = set()
|
unique = set()
|
||||||
blend_cdll = ctypes.CDLL("")
|
blend_cdll = ctypes.CDLL("")
|
||||||
@@ -1018,7 +1018,7 @@ def pycontext2sphinx(basepath):
|
|||||||
while char_array[i] is not None:
|
while char_array[i] is not None:
|
||||||
member = ctypes.string_at(char_array[i]).decode(encoding="ascii")
|
member = ctypes.string_at(char_array[i]).decode(encoding="ascii")
|
||||||
fw(".. data:: %s\n\n" % member)
|
fw(".. data:: %s\n\n" % member)
|
||||||
member_type, is_seq = type_map[member]
|
member_type, is_seq = context_type_map[member]
|
||||||
fw(" :type: %s :class:`bpy.types.%s`\n\n" % ("sequence of " if is_seq else "", member_type))
|
fw(" :type: %s :class:`bpy.types.%s`\n\n" % ("sequence of " if is_seq else "", member_type))
|
||||||
unique.add(member)
|
unique.add(member)
|
||||||
i += 1
|
i += 1
|
||||||
@@ -1026,8 +1026,8 @@ def pycontext2sphinx(basepath):
|
|||||||
# generate typemap...
|
# generate typemap...
|
||||||
# for member in sorted(unique):
|
# for member in sorted(unique):
|
||||||
# print(' "%s": ("", False),' % member)
|
# print(' "%s": ("", False),' % member)
|
||||||
if len(type_map) > len(unique):
|
if len(context_type_map) > len(unique):
|
||||||
raise Exception("Some types are not used: %s" % str([member for member in type_map if member not in unique]))
|
raise Exception("Some types are not used: %s" % str([member for member in context_type_map if member not in unique]))
|
||||||
else:
|
else:
|
||||||
pass # will have raised an error above
|
pass # will have raised an error above
|
||||||
|
|
||||||
@@ -1314,6 +1314,13 @@ def pyrna2sphinx(basepath):
|
|||||||
fw(".. hlist::\n")
|
fw(".. hlist::\n")
|
||||||
fw(" :columns: 2\n\n")
|
fw(" :columns: 2\n\n")
|
||||||
|
|
||||||
|
# context does its own thing
|
||||||
|
# "active_base": ("ObjectBase", False),
|
||||||
|
for ref_attr, (ref_type, ref_is_seq) in sorted(context_type_map.items()):
|
||||||
|
if ref_type == struct_id:
|
||||||
|
fw(" * :mod:`bpy.context.%s`\n" % ref_attr)
|
||||||
|
del ref_attr, ref_type, ref_is_seq
|
||||||
|
|
||||||
for ref in struct.references:
|
for ref in struct.references:
|
||||||
ref_split = ref.split(".")
|
ref_split = ref.split(".")
|
||||||
if len(ref_split) > 2:
|
if len(ref_split) > 2:
|
||||||
|
|||||||
Reference in New Issue
Block a user