version of Argument Clinic that ships with the next version
of CPython *could* be totally incompatible and break all your code.
-The Goals Of Argument Clinic
+
+The goals of Argument Clinic
============================
Argument Clinic's primary goal
things with all the information you give it.
-Basic Concepts And Usage
+Basic concepts and usage
========================
Argument Clinic ships with CPython; you'll find it in ``Tools/clinic/clinic.py``.
a block.)
-Converting Your First Function
+Converting your first function
==============================
The best way to get a sense of how Argument Clinic works is to
Congratulations, you've ported your first function to work with Argument Clinic!
-Advanced Topics
+
+Advanced topics
===============
Now that you've had some experience working with Argument Clinic, it's time
Currently the generated code will use :c:func:`PyArg_ParseTuple`, but this
will change soon.
-Optional Groups
+
+Optional groups
---------------
Some legacy functions have a tricky approach to parsing their arguments:
it accepts, along with the default value for each parameter.
Just run ``Tools/clinic/clinic.py --converters`` to see the full list.
+
Py_buffer
---------
Argument Clinic generates code that does it for you (in the parsing function).
-
Advanced converters
-------------------
behaves like a default value of ``None``, but the C variable is initialized
with ``NULL``.
+
Expressions specified as default values
---------------------------------------
* Tuple/list/set/dict literals.
-
Using a return converter
------------------------
Also, the function you are cloning from must have been previously defined
in the current file.
+
Calling Python code
-------------------
You can see more examples of custom converters in the CPython
source tree; grep the C files for the string ``CConverter``.
+
Writing a custom return converter
---------------------------------
specifically the implementation of ``CReturnConverter`` and
all its subclasses.
+
METH_O and METH_NOARGS
-----------------------------------------------
+----------------------
To convert a function using ``METH_O``, make sure the function's
single argument is using the ``object`` converter, and mark the
You can still use a self converter, a return converter, and specify
a ``type`` argument to the object converter for ``METH_O``.
+
tp_new and tp_init functions
-----------------------------------------------
+----------------------------
You can convert ``tp_new`` and ``tp_init`` functions. Just name
them ``__new__`` or ``__init__`` as appropriate. Notes:
(If your function doesn't support keywords, the parsing function
generated will throw an exception if it receives any.)
+
Changing and redirecting Clinic's output
----------------------------------------
The #ifdef trick
-----------------------------------------------
+----------------
If you're converting a function that isn't available on all platforms,
there's a trick you can use to make life a little easier. The existing
move it above the ``PyMethodDef`` structure where that macro is used.
-
Using Argument Clinic in Python files
-------------------------------------