Cleanup: replace references to "C" to C++ or the C-API

Also capitalize Blender, Python & API in docs & code-comments.
This commit is contained in:
Campbell Barton 2025-03-26 17:11:39 +11:00
parent ad5494d7ac
commit e436b9638e
26 changed files with 56 additions and 54 deletions

View File

@ -15,7 +15,7 @@
# Jeroen Bakker
#
# Version:
# v0.1 (12-05-2009) - migration of original source code to python.
# v0.1 (12-05-2009) - migration of original source code to Python.
# Added code to support blender 2.5 branch
# v0.2 (25-05-2009) - integrated with BlendFileReader.py
#

View File

@ -4,7 +4,7 @@
# SPDX-License-Identifier: GPL-2.0-or-later
"""
This script generates the blender.1 man page, embedding the help text
This script generates the ``blender.1`` man page, embedding the help text
from the Blender executable itself. Invoke it as follows:
blender.1.py --blender <path-to-blender> --output <output-filename>
@ -199,7 +199,7 @@ def create_argparse() -> argparse.ArgumentParser:
parser.add_argument(
"--blender",
required=True,
help="Path to the blender binary."
help="Path to the Blender binary."
)
parser.add_argument(
"--verbose",

View File

@ -9,7 +9,7 @@ Introduction
and the :func:`register`/:func:`unregister` functions! The :func:`pgettext` family of functions
should only be used in rare, specific cases (like e.g. complex "composited" UI strings...).
To add translations to your python script, you must define a dictionary formatted like that:
To add translations to your Python script, you must define a dictionary formatted like that:
``{locale: {msg_key: msg_translation, ...}, ...}`` where:
- locale is either a lang iso code (e.g. ``fr``), a lang+country code (e.g. ``pt_BR``),
@ -21,7 +21,7 @@ Then, call ``bpy.app.translations.register(__name__, your_dict)`` in your ``regi
``bpy.app.translations.unregister(__name__)`` in your ``unregister()`` one.
The ``Manage UI translations`` add-on has several functions to help you collect strings to translate, and
generate the needed python code (the translation dictionary), as well as optional intermediary po files
generate the needed Python code (the translation dictionary), as well as optional intermediary po files
if you want some... See
`How to Translate Blender <https://developer.blender.org/docs/handbook/translating/translator_guide/>`_ and
`Using i18n in Blender Code <https://developer.blender.org/docs/handbook/translating/developer_guide/>`_

View File

@ -2,8 +2,8 @@
Calling Operators
-----------------
Provides python access to calling operators, this includes operators written in
C, Python or macros.
Provides Python access to calling operators, this includes operators written in
C++, Python or macros.
Only keyword arguments can be used to pass operator properties.
@ -22,7 +22,7 @@ Calling an operator in the wrong context will raise a ``RuntimeError``,
there is a poll() method to avoid this problem.
Note that the operator ID (bl_idname) in this example is ``mesh.subdivide``,
``bpy.ops`` is just the access path for python.
``bpy.ops`` is just the access path for Python.
Keywords and Positional Arguments

View File

@ -2,7 +2,7 @@
Operator Example
++++++++++++++++
A common use of custom properties is for python based :class:`Operator`
A common use of custom properties is for Python based :class:`Operator`
classes. Test this code by running it in the text editor, or by clicking the
button in the 3D View-port's Tools panel. The latter will show the properties
in the Redo panel and allow you to change them.

View File

@ -5,7 +5,7 @@ Assigning to Existing Classes
Custom properties can be added to any subclass of an :class:`ID`,
:class:`Bone` and :class:`PoseBone`.
These properties can be animated, accessed by the user interface and python
These properties can be animated, accessed by the user interface and Python
like Blender's existing properties.
.. warning::

View File

@ -19,7 +19,7 @@ from bpy.props import StringProperty, IntProperty, BoolProperty
class ExampleAddonPreferences(AddonPreferences):
# This must match the add-on name, use `__package__`
# when defining this for add-on extensions or a sub-module of a python package.
# when defining this for add-on extensions or a sub-module of a Python package.
bl_idname = __name__
filepath: StringProperty(

View File

@ -1,9 +1,9 @@
"""
This function is for advanced use only, misuse can crash blender since the user
This function is for advanced use only, misuse can crash Blender since the user
count is used to prevent data being removed when it is used.
"""
# This example shows what _not_ to do, and will crash blender.
# This example shows what _not_ to do, and will crash Blender.
import bpy
# object which is in the scene.

View File

@ -10,7 +10,7 @@ convention for menus.
.. note::
Menu subclasses must be registered before referencing them from blender.
Menu subclasses must be registered before referencing them from Blender.
.. note::

View File

@ -3,7 +3,7 @@ Mesh Data
+++++++++
The mesh data is accessed in object mode and intended for compact storage,
for more flexible mesh editing from python see :mod:`bmesh`.
for more flexible mesh editing from Python see :mod:`bmesh`.
Blender stores 4 main arrays to define mesh geometry.
@ -13,7 +13,8 @@ Blender stores 4 main arrays to define mesh geometry.
- :class:`Mesh.polygons`: (reference a range of loops)
Each polygon references a slice in the loop array, this way, polygons do not store vertices or corner data such as UVs directly,
Each polygon references a slice in the loop array, this way,
polygons do not store vertices or corner data such as UVs directly,
only a reference to loops that the polygon uses.
:class:`Mesh.loops`, :class:`Mesh.uv_layers` :class:`Mesh.vertex_colors` are all aligned so the same polygon loop

View File

@ -18,10 +18,10 @@ and this behavior cannot be changed.
This example shows how to define an operator which gets mouse input to
execute a function and that this operator can be invoked or executed from
the python api.
the Python API.
Also notice this operator defines its own properties, these are different
to typical class properties because blender registers them with the
to typical class properties because Blender registers them with the
operator, to use as arguments when called, saved for operator undo/redo and
automatically added into the user interface.
"""

View File

@ -20,7 +20,7 @@ Notice ``__init__()`` and ``__del__()`` are declared.
For other operator types they are not useful but for modal operators they will
be called before the :class:`Operator.invoke` and after the operator finishes.
Also see the
:ref:`class construction and destruction section <info_overview_class_construction_destruction>`
:ref:`class construction and destruction section <info_overview_class_construction_destruction>`.
"""
import bpy

View File

@ -13,7 +13,7 @@ that no undo step will created (see next example for more info about undo).
.. note::
Operator subclasses must be registered before accessing them from blender.
Operator subclasses must be registered before accessing them from Blender.
"""
import bpy

View File

@ -10,7 +10,7 @@ convention for panels.
.. note::
Panel subclasses must be registered for blender to use them.
Panel subclasses must be registered for Blender to use them.
"""
import bpy

View File

@ -4,13 +4,13 @@ Custom Properties
PropertyGroups are the base class for dynamically defined sets of properties.
They can be used to extend existing blender data with your own types which can
be animated, accessed from the user interface and from python.
They can be used to extend existing Blender data with your own types which can
be animated, accessed from the user interface and from Python.
.. note::
The values assigned to blender data are saved to disk but the class
definitions are not, this means whenever you load blender the class needs
The values assigned to Blender data are saved to disk but the class
definitions are not, this means whenever you load Blender the class needs
to be registered too.
This is best done by creating an add-on which loads on startup and registers
@ -18,7 +18,7 @@ be animated, accessed from the user interface and from python.
.. note::
PropertyGroups must be registered before assigning them to blender data.
PropertyGroups must be registered before assigning them to Blender data.
.. seealso::

View File

@ -8,7 +8,7 @@ import array
class CustomRenderEngine(bpy.types.RenderEngine):
# These three members are used by blender to set up the
# These three members are used by Blender to set up the
# RenderEngine; define its internal name, visible name and capabilities.
bl_idname = "CUSTOM"
bl_label = "Custom"

View File

@ -8,7 +8,7 @@ Notice the name of the class, this naming convention is similar as the one for p
.. note::
UIList subclasses must be registered for blender to use them.
UIList subclasses must be registered for Blender to use them.
"""
import bpy

View File

@ -103,7 +103,7 @@ class MESH_UL_vgroups_slow(bpy.types.UIList):
def filter_items_empty_vgroups(self, context, vgroups):
# This helper function checks vgroups to find out whether they are empty, and what's their average weights.
# TODO: This should be RNA helper actually (a vgroup prop like "raw_data: ((vidx, vweight), etc.)").
# Too slow for python!
# Too slow for Python!
obj_data = context.active_object.data
ret = {vg.index: [True, 0.0] for vg in vgroups}
if hasattr(obj_data, "vertices"): # Mesh data

View File

@ -1,5 +1,5 @@
"""
This is the most simple example of inserting a keyframe from python.
This is the most simple example of inserting a keyframe from Python.
"""
import bpy

View File

@ -2,16 +2,16 @@
#
# SPDX-License-Identifier: GPL-2.0-or-later
# This is a quite stupid script which extracts bmesh api docs from
# 'bmesh_opdefines.cc' in order to avoid having to add a lot of introspection
# data access into the api.
# This is a quite stupid script which extracts BMesh API docs from
# `bmesh_opdefines.cc` in order to avoid having to add a lot of introspection
# data access into the API.
#
# The script is stupid because it makes assumptions about formatting...
# that each arg has its own line, that comments above or directly after will be __doc__ etc...
# that each argument has its own line, that comments above or directly after will be __doc__ etc...
#
# We may want to replace this script with something else one day but for now its good enough.
# if it needs large updates it may be better to rewrite using a real parser or
# add introspection into bmesh.ops.
# add introspection into `bmesh.ops`.
# - campbell
import os
@ -149,7 +149,7 @@ def main():
blocks_py = []
for comment, b in blocks:
# magic, translate into python
# Magic, translate into Python.
b[0] = b[0].replace("static BMOpDefine ", "")
is_enum = False
@ -358,7 +358,7 @@ def main():
elif tp_sub == BMO_OP_SLOT_SUBTYPE_MAP_ELEM:
tp_str += ":class:`bmesh.types.BMVert`/:class:`bmesh.types.BMEdge`/:class:`bmesh.types.BMFace`"
elif tp_sub == BMO_OP_SLOT_SUBTYPE_MAP_INTERNAL:
tp_str += "unknown internal data, not compatible with python"
tp_str += "unknown internal data, not compatible with Python"
else:
assert False, "unreachable, unknown type {!r}".format(vars_dict_reverse[tp_sub])
else:

View File

@ -5,7 +5,7 @@
"""
---------------
Dump the python API into a JSON file, or generate changelogs from those JSON API dumps.
Dump the Python API into a JSON file, or generate changelogs from those JSON API dumps.
Typically, changelog output from this tool should be added into "doc/python_api/rst/change_log.rst"
@ -14,7 +14,7 @@ This way the changelog generation simply needs to re-download the previous versi
---------------
# Dump api blender_version.json in CWD:
# Dump API blender_version.json in CWD:
blender --background --factory-startup --python doc/python_api/sphinx_changelog_gen.py -- \
--indexpath="path/to/api/docs/api_dump_index.json" \
dump --filepath-out="path/to/api/docs/<version>/api_dump.json"
@ -24,7 +24,7 @@ blender --background --factory-startup --python doc/python_api/sphinx_changelog_
--indexpath="path/to/api/docs/api_dump_index.json" \
changelog --filepath-out doc/python_api/rst/change_log.rst
# Api comparison can also run without blender,
# Api comparison can also run without Blender,
# will by default generate changeloig between the last two available versions listed in the index,
# unless input files are provided explicitly:
python doc/python_api/sphinx_changelog_gen.py -- \
@ -152,7 +152,7 @@ def api_dump(args):
)
del props
# python props, tricky since we don't know much about them.
# Python properties, tricky since we don't know much about them.
for prop_id, attr in struct_info.get_py_properties():
dump_class[prop_id] = (
@ -415,7 +415,7 @@ def main(argv=None):
argv = argv[argv.index("--") + 1:] # get all args after "--"
# When --help or no args are given, print this help
usage_text = "Run blender in background mode with this script: "
usage_text = "Run Blender in background mode with this script: "
"blender --background --factory-startup --python %s -- [options]" % os.path.basename(__file__)
parser = argparse.ArgumentParser(description=usage_text,

View File

@ -9,8 +9,8 @@ API dump in RST files
blender --background --factory-startup --python doc/python_api/sphinx_doc_gen.py
This will generate python files in doc/python_api/sphinx-in/
providing ./blender is or links to the blender executable
This will generate Python files in doc/python_api/sphinx-in/
providing ./blender is or links to the Blender executable
To choose sphinx-in directory:
blender --background --factory-startup --python doc/python_api/sphinx_doc_gen.py -- --output=../python_api
@ -450,7 +450,7 @@ RNA_BLACKLIST = {
RST_NOINDEX_ATTR = {
# Render is both a method and an attribute, from looking into this
# having both doesn't cause problems in practice since the `render` method
# is registered and called from C code where the attribute is accessed from the instance.
# is registered and called from C++ code where the attribute is accessed from the instance.
("bpy.types", "RenderEngine", "render"),
}
@ -585,7 +585,8 @@ def generate_changelog():
# --------------------------------API DUMP--------------------------------------
# Lame, python won't give some access.
# Unfortunately Python doesn't expose direct access to these types.
# Access them indirectly.
ClassMethodDescriptorType = type(dict.__dict__["fromkeys"])
MethodDescriptorType = type(dict.get)
GetSetDescriptorType = type(int.real)
@ -865,7 +866,7 @@ def py_descr2sphinx(ident, fw, descr, module_name, type_name, identifier):
def py_c_func2sphinx(ident, fw, module_name, type_name, identifier, py_func, is_class=True):
"""
C defined function to sphinx.
C/C++ defined function to Sphinx.
"""
# Dump the doc-string, assume its formatted correctly.
@ -1990,7 +1991,7 @@ def write_rst_index(basepath):
"bpy.path",
"bpy.app",
# C modules.
# Python C-API modules.
"bpy.props",
)
@ -2028,7 +2029,7 @@ def write_rst_index(basepath):
fw("* :ref:`genindex`\n")
fw("* :ref:`modindex`\n\n")
# Special case, this `bmesh.ops.rst` is extracted from C source.
# Special case, this `bmesh.ops.rst` is extracted from C++ source.
if "bmesh.ops" not in EXCLUDE_MODULES:
execfile(os.path.join(SCRIPT_DIR, "rst_from_bmesh_opdefines.py"))

View File

@ -19,7 +19,7 @@ __all__ = (
)
# internal blender C module
# Internal Blender C-API modules.
from _bpy import (
app,
context,

View File

@ -208,7 +208,7 @@ def object_add_grid_scale_apply_operator(operator, context):
"""
Scale an operators distance values by the grid size.
"""
# This is a Python version of the C function `WM_operator_view3d_unit_defaults`.
# This is a Python version of the C++ function `WM_operator_view3d_unit_defaults`.
grid_scale = object_add_grid_scale(context)
properties = operator.properties

View File

@ -14,7 +14,7 @@ _StructMetaPropGroup = _types.bpy_struct_meta_idprop
# Private dummy object use for comparison only.
_sentinel = object()
# Note that methods extended in C are defined in: `bpy_rna_types_capi.cc`.
# Note that methods extended in the C-API are defined in: `bpy_rna_types_capi.cc`.
class Context(_StructRNA):

View File

@ -196,7 +196,7 @@ class InfoStructRNA:
import types
functions = []
for identifier, attr in self._get_py_visible_attrs():
# Methods may be python wrappers to C functions.
# Methods may be Python wrappers to C-API functions.
ok = False
if (attr_func := getattr(attr, "__func__", None)) is not None:
if type(attr_func) == types.FunctionType:
@ -212,7 +212,7 @@ class InfoStructRNA:
import types
functions = []
for identifier, attr in self._get_py_visible_attrs():
# Methods may be python wrappers to C functions.
# Methods may be Python wrappers to C-API functions.
ok = False
if (attr_func := getattr(attr, "__func__", None)) is not None:
if type(attr_func) == types.BuiltinFunctionType: