Skip to content

Commit b829d9b

Browse files
committed
Document configurable name transforms
1 parent 8c989c7 commit b829d9b

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

docs/config/autowrap.rst

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,45 @@ generated by semiwrap. In your ``meson.build`` after you include the generated
6161
)
6262
6363
64+
Name transforms
65+
---------------
66+
67+
Generated Python names for functions, methods, and attributes can be configured
68+
with ``name_transform``. Explicit ``rename`` entries still take precedence, and
69+
YAML ``strip_prefixes`` is applied before the transform.
70+
71+
Configuration precedence is:
72+
73+
#. YAML ``name_transform``
74+
#. ``[tool.semiwrap.extension_modules."pkg.name"].name_transform``
75+
#. ``[tool.semiwrap].name_transform``
76+
#. ``default``
77+
78+
Built-ins are:
79+
80+
* ``default``: preserves existing semiwrap behavior; function and method names
81+
lowercase the first character unless the first two characters are uppercase,
82+
while attribute names are unchanged.
83+
* ``camelCase``: converts names to lower camel case, such as ``GetFoo`` or
84+
``get_foo`` becoming ``getFoo``.
85+
* ``snake_case``: converts names to lowercase words separated by underscores,
86+
such as ``GetFoo`` or ``getFoo`` becoming ``get_foo``.
87+
* ``PascalCase``: converts names to upper camel case, such as ``getFoo`` or
88+
``get_foo`` becoming ``GetFoo``.
89+
90+
Custom transforms use ``custom: package.name:function`` and receive
91+
``(name: str, kind: str)`` where kind is ``function``, ``method``, or
92+
``attribute``.
93+
94+
Example::
95+
96+
name_transform: snake_case
97+
strip_prefixes:
98+
- SW_
99+
100+
Name transforms do not apply to classes, enums, enum values, template instance
101+
names, or parameter names.
102+
64103
Reference
65104
---------
66105

0 commit comments

Comments
 (0)