PyDoc: use Python's type annotation syntax for doc-strings

Replace plain-text type information with the type syntax used
for Python's type annotations as it's more concise, especially for
callbacks which often didn't include useful type information.

Note that this change only applies to inline doc-strings,
generated doc-strings from RNA need to be updated separately.

Details:

- Many minor corrections were made when "list" was incorrectly used
  instead of "sequence".
- Some type information wasn't defined in the doc-strings and has been
  added.
- Verbose type info would benefit from support for type aliases.
This commit is contained in:
Campbell Barton
2024-11-03 15:42:19 +11:00
parent 3347aa4017
commit 3bcfb151c1
90 changed files with 722 additions and 676 deletions

View File

@@ -16,7 +16,9 @@ def batch_for_shader(shader, type, content, *, indices=None):
:arg type: "'POINTS', 'LINES', 'TRIS' or 'LINES_ADJ'".
:type type: str
:arg content: Maps the name of the shader attribute with the data to fill the vertex buffer.
:type content: dict
For the dictionary values see documentation for :class:`gpu.types.GPUVertBuf.attr_fill` data argument.
:type content: dict[str, Buffer | Sequence[float] | Sequence[int] | \
Sequence[Sequence[float]] | Sequence[Sequence[int]]]
:return: compatible batch
:rtype: :class:`gpu.types.GPUBatch`
"""

View File

@@ -6,16 +6,16 @@ def draw_circle_2d(position, color, radius, *, segments=None):
"""
Draw a circle.
:arg position: Position where the circle will be drawn.
:type position: 2D Vector
:arg color: Color of the circle. To use transparency GL_BLEND has to be enabled.
:type color: tuple containing RGBA values
:arg position: 2D position where the circle will be drawn.
:type position: Sequence[float]
:arg color: Color of the circle (RGBA). To use transparency GL_BLEND has to be enabled.
:type color: Sequence[float]
:arg radius: Radius of the circle.
:type radius: float
:arg segments: How many segments will be used to draw the circle.
Higher values give better results but the drawing will take longer.
If None or not specified, an automatic value will be calculated.
:type segments: int or None
:type segments: int | None
"""
from math import sin, cos, pi, ceil, acos
import gpu