@@ -193,6 +193,71 @@ The CLI supports the following options:
193193 The list of files to process.
194194
195195
196+ .. _clinic-classes :
197+
198+ Classes for extending Argument Clinic
199+ -------------------------------------
200+
201+ .. module :: clinic
202+
203+ .. class :: CConverter
204+
205+ The base class for all converters.
206+ See :ref: `clinic-howto-custom-converter ` for how to subclass this class.
207+
208+ .. attribute :: type
209+
210+ The C type to use for this variable.
211+ :attr: `!type ` should be a Python string specifying the type,
212+ e.g. ``'int' ``.
213+ If this is a pointer type, the type string should end with ``' *' ``.
214+
215+ .. attribute :: default
216+
217+ The Python default value for this parameter, as a Python value.
218+ Or the magic value ``unspecified `` if there is no default.
219+
220+ .. attribute :: py_default
221+
222+ :attr: `!default ` as it should appear in Python code,
223+ as a string.
224+ Or ``None `` if there is no default.
225+
226+ .. attribute :: c_default
227+
228+ :attr: `!default ` as it should appear in C code,
229+ as a string.
230+ Or ``None `` if there is no default.
231+
232+ .. attribute :: c_ignored_default
233+
234+ The default value used to initialize the C variable when
235+ there is no default, but not specifying a default may
236+ result in an "uninitialized variable" warning. This can
237+ easily happen when using option groups—although
238+ properly written code will never actually use this value,
239+ the variable does get passed in to the impl, and the
240+ C compiler will complain about the "use" of the
241+ uninitialized value. This value should always be a
242+ non-empty string.
243+
244+ .. attribute :: converter
245+
246+ The name of the C converter function, as a string.
247+
248+ .. attribute :: impl_by_reference
249+
250+ A boolean value. If true,
251+ Argument Clinic will add a ``& `` in front of the name of
252+ the variable when passing it into the impl function.
253+
254+ .. attribute :: parse_by_reference
255+
256+ A boolean value. If true,
257+ Argument Clinic will add a ``& `` in front of the name of
258+ the variable when passing it into :c:func: `PyArg_ParseTuple `.
259+
260+
196261.. _clinic-tutorial :
197262
198263Tutorial
@@ -1348,7 +1413,7 @@ See also :pep:`573`.
13481413How to write a custom converter
13491414-------------------------------
13501415
1351- A converter is a Python class that inherits from :py:class: `! CConverter `.
1416+ A converter is a Python class that inherits from :py:class: `CConverter `.
13521417The main purpose of a custom converter, is for parameters parsed with
13531418the ``O& `` format unit --- parsing such a parameter means calling
13541419a :c:func: `PyArg_ParseTuple ` "converter function".
@@ -1360,73 +1425,13 @@ your converter class with the ``_converter`` suffix stripped off.
13601425
13611426Instead of subclassing :py:meth: `!CConverter.__init__ `,
13621427write a :py:meth: `!converter_init ` method.
1363- Apart for the * self * parameter, all additional :py:meth: `!converter_init `
1364- parameters **must ** be keyword-only.
1428+ :py:meth: `!converter_init ` always accepts a * self * parameter.
1429+ After * self *, all additional parameters **must ** be keyword-only.
13651430Any arguments passed to the converter in Argument Clinic
13661431will be passed along to your :py:meth: `!converter_init ` method.
1367- See :py:class: `! CConverter ` for a list of members you may wish to specify in
1432+ See :py:class: `CConverter ` for a list of members you may wish to specify in
13681433your subclass.
13691434
1370- .. module :: clinic
1371-
1372- .. class :: CConverter
1373-
1374- The base class for all converters.
1375- See :ref: `clinic-howto-custom-converter ` for how to subclass this class.
1376-
1377- .. attribute :: type
1378-
1379- The C type to use for this variable.
1380- :attr: `!type ` should be a Python string specifying the type,
1381- e.g. ``'int' ``.
1382- If this is a pointer type, the type string should end with ``' *' ``.
1383-
1384- .. attribute :: default
1385-
1386- The Python default value for this parameter, as a Python value.
1387- Or the magic value ``unspecified `` if there is no default.
1388-
1389- .. attribute :: py_default
1390-
1391- :attr: `!default ` as it should appear in Python code,
1392- as a string.
1393- Or ``None `` if there is no default.
1394-
1395- .. attribute :: c_default
1396-
1397- :attr: `!default ` as it should appear in C code,
1398- as a string.
1399- Or ``None `` if there is no default.
1400-
1401- .. attribute :: c_ignored_default
1402-
1403- The default value used to initialize the C variable when
1404- there is no default, but not specifying a default may
1405- result in an "uninitialized variable" warning. This can
1406- easily happen when using option groups—although
1407- properly written code will never actually use this value,
1408- the variable does get passed in to the impl, and the
1409- C compiler will complain about the "use" of the
1410- uninitialized value. This value should always be a
1411- non-empty string.
1412-
1413- .. attribute :: converter
1414-
1415- The name of the C converter function, as a string.
1416-
1417- .. attribute :: impl_by_reference
1418-
1419- A boolean value. If true,
1420- Argument Clinic will add a ``& `` in front of the name of
1421- the variable when passing it into the impl function.
1422-
1423- .. attribute :: parse_by_reference
1424-
1425- A boolean value. If true,
1426- Argument Clinic will add a ``& `` in front of the name of
1427- the variable when passing it into :c:func: `PyArg_ParseTuple `.
1428-
1429-
14301435Here's the simplest example of a custom converter, from :source: `Modules/zlibmodule.c `::
14311436
14321437 /*[python input]
0 commit comments