Commit graph

1528 commits

Author SHA1 Message Date
Campbell Barton
daf9e3b1c6 PyDoc: fix errors in doc-strings, use type-hint syntax
- Use `tuple[...]` for RNA functions returning tuples.
- Add `| None` for optional parameters.
- Add missing `:param default:` for `bl_rna_get_subclass`.
- Fix incorrect default values (filepath, path_remap, empty enum flags).
- Use `Any` instead of unknown `capsule` for opaque handle types.
- Fix byte-string default formatting and single-element tuple syntax.
2026-02-21 10:19:07 +11:00
Campbell Barton
76976a676a PyDoc: correct operator links, use :func: instead of :mod: 2026-02-16 18:20:55 +11:00
Campbell Barton
57d607f680 PyDoc: corrections in manually maintained RST docs
Correct grammar and typos across documentation.

Update outdated API references:
- Group -> Collection.
- __cmp__ -> __eq__, verts -> vertices.
- threading code examples.
2026-02-16 03:42:15 +00:00
Campbell Barton
458640840a PyDoc: fix RST cross-references in Python API docs
Fix cross-reference roles, incorrect use of :class:.
correct broken cross-reference targets.
2026-02-16 03:42:14 +00:00
Campbell Barton
08516bebb1 PyAPI: correct function name in argument parsing
Also correct axis in `blf` example.

Ref !154424
2026-02-16 07:14:42 +11:00
Campbell Barton
51b8eb8aa3 Cleanup: correct misleading comment, remove hard-coded module name 2026-02-13 20:57:38 +11:00
Campbell Barton
87f425ff37 Cleanup: remove unused imports, argument shadowing, long lines in RST
Also resolve various pylint warnings.
2026-02-13 19:42:07 +11:00
Campbell Barton
b2c36be650 PyDoc: correct doc-strings for macro operator parameters
Macro operator doc-strings didn't properly document the parameters
for the other operators that can be passed in.

Expose them as a dictionary since internally dictionaries are
coerced into OperatorProperties.
2026-02-13 07:42:58 +00:00
Campbell Barton
c9ed852a07 PyDoc: remove outdated note about types not being available 2026-02-13 07:42:52 +00:00
Campbell Barton
10e8cb06f5 PyDoc: fix array property types, document bpy_prop_array
Array properties that don't map to a mathutils type (Vector, Matrix,
etc.) incorrectly used their element type (e.g. `float` / `int`).

- For function arguments use `Sequence[...]` since it will coerce
  accepts any sequence type.
- Struct properties use `bpy_prop_array`, because they're a
  Blender specific type which is mutable.
2026-02-13 07:42:50 +00:00
Campbell Barton
5c0b92ff3c PyDoc: write type qualifiers for function parameters
Array parameters were missing their dimensions & range.

Also simplify writing type info.
2026-02-13 07:42:49 +00:00
Campbell Barton
108755a79c PyDoc: fix error in recent example re-numbering
Error in [0] caused examples that didn't start at 0 to be ignored.

Simplify logic with iteration instead of recursion.

[0]: 0640836baa
2026-02-13 14:55:12 +11:00
Campbell Barton
f3d6223b65 PyDoc: use type hints for generated RNA types
Refactor get_type_description to return a (type_hint, type_info) tuple
instead of a single string with embedded qualifiers.

Ref !154304
2026-02-12 20:41:34 +11:00
Campbell Barton
d4f4a037f6 PyDoc: add screen context members to bpy.types.Context
Move context member documentation into bpy.types.Context using rubric
headings to group by context area (Buttons, Screen, etc.).

Make bpy.context.rst a simple placeholder linking to bpy.types.Context,
matching the pattern used by bpy.data.rst.
2026-02-12 20:41:34 +11:00
Campbell Barton
3fbd91578b PyDoc: fix missing classmethod docs for Python classes
Classmethod descriptors were not handled, causing methods in
bpy_extras.anim_utils and bpy_extras.asset_utils to be excluded
from documentation entirely.
2026-02-12 20:41:34 +11:00
Campbell Barton
a977e71471 PyDoc: fix static method handling for Python-defined methods
Python-defined static methods (e.g. bpy_extras.AutoKeying.get_4d_rotlock)
were not having their signatures extracted.
2026-02-12 20:41:34 +11:00
Campbell Barton
89f1e75823 PyDoc: fix type hierarchy & collection wrapper inheritance
- Rename "FAKE" to "PYCAPI" for non-RNA type constants, since these
  are real C-API defined Python types, not "fake".
- Add USE_PYCAPI_TYPES flag, see code comments for details on the
  two separate type hierarchies (`bpy_struct` & `bpy_prop`).
- Fix `bpy_prop` base class (was incorrectly set to `bpy_struct`).
- Collection wrapper structs (e.g. BlendDataObjects) now correctly
  inherit from `bpy_prop_collection` instead of `bpy_struct`.
2026-02-12 20:41:34 +11:00
Campbell Barton
257b514557 PyDoc: add bpy_prop fake class, show base class in class signatures
- Add bpy_prop as a documented fake class between bpy_struct and
  bpy_prop_collection, matching the actual C type hierarchy.
- Show the base class in fake class signatures (e.g.
  bpy_prop_collection(bpy_prop)) instead of only in the
  "base classes" text.
2026-02-12 20:41:34 +11:00
Campbell Barton
8cf63dd3f3 PyDoc: use 'data' directive for module-level descriptors
Module-level GetSetDescriptorType entries (e.g. bpy.app.debug,
bpy.app.translations.locale) were incorrectly using '.. attribute::'
which is meant for class members. Use '.. data::' instead, matching
the Sphinx convention for module-level data.
2026-02-12 20:41:34 +11:00
Campbell Barton
998fe01e28 PyDoc: use type-hint syntax, add missing docs & some corrections
sphinx_doc_gen.py:
- Add _PRIVATE_ATTR_INCLUDE so underscore-prefixed types can be
  selectively included in API docs (needed to reference return values).
- Add :return:/:rtype: for operators.
- Fix context type entries (AnnotationLayer, FluidModifier, Curves).

bpy.props:
- Add :return:/:rtype: for property declaration functions.

gpu:
- Expose MatrixStackContext and OffScreenStackContext as documented
  gpu.types so :rtype: references resolve.

bmesh.ops:
- Use Sequence[float] for vector input params.
- Add default_value for single-element BMO_OP_SLOT_ELEMENT_BUF slots.

bpy.types:
- Convert `tuple of X` to `tuple[X, ...]` and `list of X` to `list[X]`.
- Add :return:/:rtype: to Context.path_resolve and Operator.as_keywords.
- Fix Menu example link reference.

bpy_extras:
- Convert Python type annotations to :param:/:type:/:rtype:,
  add missing doc-strings.

bpy.app.handlers:
- Add :type: with callable signatures.
- Fix depsgraph_update handler description
  (the second argument is optional).
- Fix missing argument descriptions for render and undo/redo handlers.

bpy.context
- Use type hints for for property listing.

mathutils.kdtree:
- Fix doc-string syntax.
- Clarify that the size is an upper limit.

Various minor corrections to other modules.
2026-02-12 20:41:34 +11:00
Campbell Barton
0640836baa PyDoc: number all examples to avoid conflicts when type checking
Examples were supported with/without number suffix,
this caused problems using mypy for type checking because it attempted
to resolve imports such as `mathutils` to the example file.

Having only some examples numbered already complicated documentation
for conventions with examples - simplify extraction and number all.
2026-02-12 00:51:02 +00:00
Campbell Barton
084333edb0 PyDoc: make examples self contained, resolve type warnings
Some examples were missing missing imports,
resolve some mypy warnings.
2026-02-12 00:25:15 +00:00
Campbell Barton
73940408bb PyDoc: replace deprecated TRI_FAN with TRI_STRIP in GPU examples
These examples wouldn't work on macOS.
2026-02-11 23:31:41 +00:00
Campbell Barton
59e1d067d5 PyDoc: use annotation style types for bmesh.ops 2026-02-10 10:15:27 +00:00
Campbell Barton
b0fd6cec14 PyDoc: various corrections to doc-strings and examples
- Correct typos/grammar.
- Correct examples.
- Fixes for RST syntax examples.
- Add missing arguments.
2026-02-10 01:49:44 +00:00
Campbell Barton
791505e2ed PyDoc: use :param: instead of :arg: in Sphinx docstrings
While "arg" isn't deprecated "param" is preferred and used in all
Sphinx's examples & tutorials.

Ref !154039
2026-02-07 14:30:16 +11:00
Nick Alberelli
f7a3348637 PyDoc: add a Python API documentation contribution guide
Add a contribution guide for Blender's Python API documentation,
similar to the User Manual contribution guide.

Some parts of this process weren't so clear,
especially the example auto-discovery.

Cover:
- Setting up the build environment.
- Modifying API documentation.
- Adding example code snippets.
- File naming conventions and auto-discovery.
- Best practices and style guidelines.

PR !151750

Co-authored-by: Campbell Barton <campbell@blender.org>
2026-01-31 20:06:52 +11:00
Campbell Barton
845ca44a30 PyDoc: clarify threading example regarding Blender API usage
Address issue raised in #153398.
2026-01-28 09:29:48 +00:00
Brecht Van Lommel
59f187ff9d Cleanup: Remove outdated guardedalloc guide
This was already very outdated before and even more so now. The docs in
MEM_guardedalloc.h cover this information already.

Pull Request: https://projects.blender.org/blender/blender/pulls/151387
2026-01-26 19:20:40 +01:00
Campbell Barton
03975acb55 Doc: add Python API example for KeyMaps add-on registration
Add an example with some notes on keymap usage, targeted at add-on
developers.

- Avoid pitfalls, add-on developers sometimes incorrectly modify user
  keymaps directly, which persists after the add-on is disabled and
  interferes with user preferences.
- Documents subtle/non-obvious requirements.
- Mention edge case regarding modal operator key-maps.

Ref !153111
2026-01-22 07:23:50 +00:00
Campbell Barton
25bbf21575 Fix: Python API docs broken links for classes in submodules
Duplicating the module path in `.. class::` identifiers broke links.

This affected `bmesh.types`, `imbuf.types`, and `idprop.types`.
2026-01-21 17:07:18 +11:00
Campbell Barton
323bbeaa4d Fix #152607: Python API docs missing idprop module page 2026-01-21 17:07:18 +11:00
Nick Alberelli
e1008386eb PyAPI: support for context logging to suppress missing member access
Add hide_missing keyword argument to temp_override.logging_set().
This reduces noise from members that aren't available in the current
context while still showing members that exist but are empty.

- Add CTX_LogFlag enum with Access and HideMissing flags to control
  context member logging behavior during temporary overrides.

- Store & restore original logging with a temporary context so each
  context override properly stores & restores the logging options.

Ref !148760
2026-01-13 19:17:09 +11:00
Nick Alberelli
d11b9878c4 Docs: Add Action Slot example code to PyAPI docs
Add some example code for working with Action slots.

Reference: https://projects.blender.org/blender/blender-manual/issues/105297
Pull Request: https://projects.blender.org/blender/blender/pulls/151510
2026-01-09 16:32:49 +01:00
Nick Alberelli
6577606415 Fix #151742: Docs: Fix Typo in bpy.types.USDHook code
Changes to example code introduced with db88381e75 contains a typo,
using `data block` instead of the standard `data-block`.

This changes ensures consistency with the spelling of `data-block` with
other API example files.

Pull Request: https://projects.blender.org/blender/blender/pulls/151850
2025-12-18 18:36:25 +01:00
Hans Goudey
8353707064 Cleanup: UI: Remove uiBut type alias
Use blender::ui::Button directly instead.
Ref 03ccc71c10
2025-12-05 18:42:52 +01:00
Hans Goudey
57f68051b8 Cleanup: UI: Remove uiBlock type alias
Just use blender::ui::Block directly
2025-12-05 18:42:52 +01:00
Hans Goudey
18872cfb92 Refactor: UI: Remove "UI_" prefix from functions in namespace
- Mainly avoiding the `ui::UI_*` repetition, removing naming redundancy
- I skipped the "uiDefBut" style functions, those can be handled later
- "uiTemplate" functions are moved to snake case
- "GetThemeColor" functions are still not snake case, that's a next step
- I renamed "but" to "button" for one group of functions

Pull Request: https://projects.blender.org/blender/blender/pulls/151193
2025-12-05 17:59:22 +01:00
John Kiril Swenson
6f9556c561 Cleanup: UI: Standardize ellipsis for menu operators
This patch standardizes ellipses on labels that require further input
from the user before running the operator as per our
HIG.

- PR does not include buttons (e.g. "Purge" in Outliner) and only
  modifies menu items.
- PR does not include operators that wait for input from the user during
  modal operation (e.g. `view3d.select_box`, `paint.sample_color`).
- Some usage of ellipses were removed since they were only present to
  indicate the start of the sentence (to be finished by submenu items).
  E.g. "Make Local...", "Sort Elements...", "Move..." do not require extra
  input from the user.

Pull Request: https://projects.blender.org/blender/blender/pulls/150950
2025-12-04 23:04:28 +01:00
Bipin Yadav
6784fc424e Fix #150602: invalid string formatting in menu example
Ref !150802
2025-11-30 08:40:23 +00:00
Campbell Barton
f590b6ca66 Merge branch 'blender-v5.0-release' 2025-11-02 20:00:21 +11:00
nutti
7adf5b9705 PyDoc: support multi-line operator descriptions
Even though these aren't used at the moment, their inclusion shouldn't
cause errors, as they're supported elsewhere in Blender.

Ref !149167
2025-11-02 19:58:08 +11:00
nutti
2d07d2a72a Fix: invalid PyDoc format on bpy.types.Context
Currently PyDoc format on bpy.types.Context is not correct.
This PR fixes this.

Pull Request: https://projects.blender.org/blender/blender/pulls/148813
2025-11-01 06:20:36 +01:00
Campbell Barton
9d3dc4392b Merge branch 'blender-v5.0-release' 2025-10-23 14:00:12 +11:00
Campbell Barton
a370884486 Merge branch 'blender-v5.0-release' 2025-10-23 14:00:08 +11:00
Campbell Barton
cdb643f8b7 Cleanup: use ASCII comments, add tailing newline 2025-10-23 13:58:16 +11:00
Nathan Burnham
0e6ea19853 PyAPI Docs: Fix "On this page" covering content
Sphinx CSS "hides" the _On this page_ pane by setting its `position` to `fixed` and `right` to `-15em`—this assumes it has a fixed `width` of `15em`, which it doesn't if it is overridden to `auto`.

Fixes #148347; caused by [45fee7d851][0], which also affects the 4.5 LTS docs.

[0]: 45fee7d851

Pull Request: https://projects.blender.org/blender/blender/pulls/148603
2025-10-23 04:22:48 +02:00
Nick Alberelli
61da6403be USD: Add new get_prim_map API for the on_export hook
Similar to: 0df5d8220b

For consistency sake, we should have the `get_prim_map` function working
on the export side of USD hooks as well as the import side.

Pull Request: https://projects.blender.org/blender/blender/pulls/147242
2025-10-19 22:36:07 +02:00
Jacques Lucke
96d2f3430f Merge branch 'blender-v5.0-release' 2025-10-16 19:20:23 +02:00
Jeroen Bakker
e2dc63c5de Fix #147618: PyGPU incorrect colors when drawing images
644fb2b679 fixed a long standing issue
that offscreen example showed the wrong colors. However the fix assumes
that input texture color space is always sRGB.

This adds a shader variation that draws textures that are stored in scene referred
linear color space (like all of our Image data-block).

Co-authored-by: Clément Foucault <foucault.clem@gmail.com>
Pull Request: https://projects.blender.org/blender/blender/pulls/147788
2025-10-16 19:12:16 +02:00