Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
79 commits
Select commit Hold shift + click to select a range
376caf0
Issue #19659: Added documentation for Argument Clinic.
larryhastings Jan 4, 2014
5ca5d3a
Argument Clinic: fixed test suite, improved howto.
larryhastings Jan 5, 2014
9e47d75
Issue #20141: Improved Argument Clinic's support for the PyArg_Parse …
larryhastings Jan 7, 2014
01ae6c7
Issue #19273: The marker comments Argument Clinic uses have been changed
larryhastings Jan 7, 2014
1f988b1
Closes #20200: Argument Clinic custom converter example should be in a
zware Jan 10, 2014
5c53fd9
Issue #20214: Fixed a number of small issues and documentation errors in
larryhastings Jan 12, 2014
8d13753
Minor doc fix in Clinic howto.
larryhastings Jan 12, 2014
ef8fde7
Issue #20268: Argument Clinic now supports cloning the parameters
larryhastings Jan 15, 2014
ecea194
Issue #20226: Major improvements to Argument Clinic.
larryhastings Jan 16, 2014
71ff306
Issue #20287: Argument Clinic's output is now configurable, allowing
larryhastings Jan 18, 2014
8224acf
Doc improvements for Clinic howto "Goals" section.
larryhastings Jan 18, 2014
3619f5f
Issue #20294: Argument Clinic now supports argument parsing for __new…
larryhastings Jan 19, 2014
745625b
Doc fixes for Argument Clinic.
larryhastings Jan 22, 2014
4259315
GitHub-Issue-Link: https://github.com/python/cpython/issues/64547
ezio-melotti Jan 25, 2014
86a65e4
Documentation fixes, including fixing "suspicious" problems.
larryhastings Jan 26, 2014
416ba5f
including correctly generating code for Clinic blocks inside C
larryhastings Feb 1, 2014
6341d75
Fix Issue #21528 - Fix documentation typos
dstufft May 20, 2014
e3c5656
Issue #24000: Improved Argument Clinic's mapping of converters to legacy
larryhastings May 8, 2015
2914da8
Argument Clinic: added missing bit of info in howto
taleinat May 16, 2015
1b9d562
Issue #24232: Fix typos. Patch by Ville Skyttä.
berkerpeksag May 18, 2015
be8c565
Issue #24232: Fix typos. Patch by Ville Skyttä.
berkerpeksag May 18, 2015
f3fcaa4
Back porting changeset db302b88fdb6 to 3.4 branch, which fixed multip…
orsenthil Jun 15, 2015
62bda94
null merge with 3.4
orsenthil Jun 15, 2015
05046f9
null merge 3.4 to 3.5 (9a0c5ffe7420 merged 3.4 to default, bypassing …
ned-deily Jun 15, 2015
70bfe58
null merge 3.5 to default (9a0c5ffe7420 merged 3.4 to default, bypass…
ned-deily Jun 15, 2015
0ca4094
Issue #25626: Change zlib to accept Py_ssize_t and cap to UINT_MAX
vadmium Nov 20, 2015
c7b612a
Issue #25626: Merge zlib fix from 3.5
vadmium Nov 21, 2015
cfb1132
Issue #27130: Fix handling of buffers exceeding UINT_MAX in “zlib” mo…
vadmium Jul 23, 2016
4d20304
Issue #27626: Spelling fixes in docs, comments and internal names
vadmium Jul 28, 2016
3c7af20
Issue #26462: Doc: reduce literal_block warnings, fix syntax highligh…
vadmium Jul 26, 2016
2138267
Issue #27745: Fix some typos in Argument Clinic howto, by Lele Gaifax
vadmium Aug 12, 2016
83f8383
clinic: PY_LONG_LONG -> long long
benjaminp Sep 8, 2016
0147885
Issue 28753: Argument Clinic howto docfix, courtesy Julien Palard.
larryhastings Nov 20, 2016
2ff77e2
Change double hyphens (en dashes) to em (longer) dashes
vadmium Nov 21, 2016
a0b8e05
Merge doc fixups from 3.5
vadmium Nov 21, 2016
e066b36
Merge doc fixups from 3.6
vadmium Nov 21, 2016
d29e1f8
Change an en-dash to an em-dash.
serhiy-storchaka Nov 21, 2016
36e7d29
Issue 28753: Argument Clinic howto docfix, courtesy Julien Palard.
vadmium Dec 10, 2016
85fea54
Issue #28755: Improve syntax highlighting in Arg Clinic howto
vadmium Dec 10, 2016
8764b20
Issues #28755, #28753: Merge Arg Clinic howto from 3.5
vadmium Dec 10, 2016
4ad9136
Issue #28755: Merge Arg Clinic howto from 3.6
vadmium Dec 10, 2016
9a35ab4
bpo-29918: Add missed "const" modifiers in C API documentation. (#846)
serhiy-storchaka Mar 30, 2017
3fae62e
bpo-29596: Improve clinic howto documentation (GH-1710)
gfyoung Jun 6, 2017
3f5fc8f
Improve highlighting of some code blocks. (python/cpython#6401)
serhiy-storchaka Apr 8, 2018
40bb2c7
Docs: be less specific about python versions (python/cpython#6985)
grimreaper May 20, 2018
357a8f2
bpo-20260: Implement non-bitwise unsigned int converters for Argument…
serhiy-storchaka Jul 26, 2018
f9b4857
bpo-35042: Use the :pep: role where a PEP is specified (python/cpytho…
matrixise Oct 26, 2018
8c3d865
Doc: Replace the deprecated highlightlang directive by highlight. (py…
matrixise May 17, 2019
50f60a4
bpo-38600: NULL -> ``NULL``. (python/cpython#17001)
serhiy-storchaka Oct 30, 2019
403488f
bpo-42048: Clinic Howto: Document AC's defining_class converter (pyth…
Jan 20, 2021
4cd6fc6
bpo-45320: Remove long-deprecated inspect methods (python/cpython#28618)
hugovk Oct 20, 2021
9d1a7ad
bpo-46613: Add PyType_GetModuleByDef to the public API (python/cpytho…
encukou Feb 11, 2022
03d39ac
python/cpython#92536: PEP 623: Remove wstr and legacy APIs from Unico…
methane May 12, 2022
7980ac5
Document Py_ssize_t. (python/cpython#92512)
JulienPalard May 13, 2022
d2514e5
Docs: remove redundant "adverb-adjective" hyphens from compound modif…
nedbat Jul 5, 2022
d6ff211
python/cpython#95007: Remove the NoneType return converter from Argum…
noamcohen97 Aug 1, 2022
5f6ac54
python/cpython#97956: Mention `generate_global_objects.py` in `AC How…
sobolevn Oct 7, 2022
1196c45
docs: Change links to label refs (python/cpython#98454)
slateny Oct 26, 2022
9243c7a
python/cpython#98763: Prefer "python" over "python3" for command line…
felixxm Jan 11, 2023
59eef01
python/cpython#64658: Expand Argument Clinic return converter docs (p…
erlend-aasland May 5, 2023
d8a7663
python/cpython#104389: Add 'unused' keyword to Argument Clinic C conv…
erlend-aasland May 12, 2023
b247a69
Docs: Normalize Argument Clinic How-To section capitalization (python…
erlend-aasland Jul 15, 2023
9ca360c
Docs: Normalise Argument Clinic advanced topics headings (python/cpyt…
erlend-aasland Jul 18, 2023
4c56015
Docs: Argument Clinic: Group guides about default values (python/cpyt…
erlend-aasland Jul 18, 2023
60a674b
Docs: Argument Clinic: Add Background and Tutorial top-level sections…
erlend-aasland Jul 21, 2023
f73589c
Docs: Remove duplicate word in Argument Clinic howto heading (python/…
hakancelikdev Jul 24, 2023
4eda298
Docs: Add missing markup to Argument Clinic docs (python/cpython#106876)
erlend-aasland Jul 24, 2023
f4d2138
Docs: Remove the numbered steps from the Argument Clinic tutorial (py…
erlend-aasland Jul 26, 2023
8405f89
Docs: Argument Clinic: Restructure "Basic concepts and usage" (python…
erlend-aasland Jul 26, 2023
64b07f5
python/cpython#107507: Replace 'The goals of Argument Clinic' with a …
erlend-aasland Jul 31, 2023
1c3fb9b
Docs: Argument Clinic: Improve 'How to write a custom converter' (pyt…
erlend-aasland Aug 5, 2023
ce3b69d
Docs: Argument Clinic: Move the CConverter class to the reference (py…
erlend-aasland Aug 7, 2023
eec5f46
python/cpython#95065: Add Argument Clinic support for deprecating pos…
erlend-aasland Aug 7, 2023
6a0051f
python/cpython#86457: Add docs for Argument Clinic @text_signature di…
erlend-aasland Aug 8, 2023
8dd6936
python/cpython#104683: Add --exclude option to Argument Clinic CLI (p…
erlend-aasland Aug 8, 2023
067ee64
Docs: clean up Argument Clinic howto's (python/cpython#107797)
erlend-aasland Aug 9, 2023
f62db14
Add clinic.rst with history
erlend-aasland Aug 9, 2023
b091bbd
Add clinic.rst to Development Tools
erlend-aasland Aug 9, 2023
7e4977f
Adapt clinic.rst
erlend-aasland Aug 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Documentation fixes, including fixing "suspicious" problems.
  • Loading branch information
larryhastings committed Jan 26, 2014
commit 86a65e43087b5b2dd45aa287e936512a7238c955
114 changes: 64 additions & 50 deletions Doc/howto/clinic.rst
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ Let's dive in!
1. Find a Python builtin that calls either :c:func:`PyArg_ParseTuple`
or :c:func:`PyArg_ParseTupleAndKeywords`, and hasn't been converted
to work with Argument Clinic yet.
For my example I'm using ``pickle.Pickler.dump()``.
For my example I'm using ``_pickle.Pickler.dump()``.

2. If the call to the ``PyArg_Parse`` function uses any of the
following format units::
Expand Down Expand Up @@ -214,7 +214,7 @@ Let's dive in!
Sample::

/*[clinic input]
pickle.Pickler.dump
_pickle.Pickler.dump

Write a pickled representation of obj to the open file.
[clinic start generated code]*/
Expand All @@ -227,22 +227,27 @@ Let's dive in!
the top. (In our sample code we'll just show the two blocks next to
each other.)

The name of the class and module should be the same as the one
seen by Python. Check the name defined in the :c:type:`PyModuleDef`
or :c:type:`PyTypeObject` as appropriate.

When you declare a class, you must also specify two aspects of its type
in C: the type declaration you'd use for a pointer to an instance of
this class, and a pointer to the :c:type:`PyTypeObject` for this class.

Sample::

/*[clinic input]
module pickle
class pickle.Pickler
[clinic start generated code]*/
/*[clinic input]
module _pickle
class _pickle.Pickler "PicklerObject *" "&Pickler_Type"
[clinic start generated code]*/

/*[clinic input]
pickle.Pickler.dump
/*[clinic input]
_pickle.Pickler.dump

Write a pickled representation of obj to the open file.
[clinic start generated code]*/
Write a pickled representation of obj to the open file.
[clinic start generated code]*/

The name of the class and module should be the same as the one
seen by Python. Check the name defined in the :c:type:`PyModuleDef`
or :c:type:`PyTypeObject` as appropriate.



Expand Down Expand Up @@ -286,13 +291,13 @@ Let's dive in!

Sample::

/*[clinic input]
module pickle
class pickle.Pickler
[clinic start generated code]*/
/*[clinic input]
module _pickle
class _pickle.Pickler "PicklerObject *" "&Pickler_Type"
[clinic start generated code]*/

/*[clinic input]
pickle.Pickler.dump
/*[clinic input]
_pickle.Pickler.dump

obj: 'O'

Expand All @@ -309,7 +314,7 @@ Let's dive in!
itself before the first keyword-only argument, indented the
same as the parameter lines.

(``pickle.Pickler.dump`` has neither, so our sample is unchanged.)
(``_pickle.Pickler.dump`` has neither, so our sample is unchanged.)


10. If the existing C function calls :c:func:`PyArg_ParseTuple`
Expand All @@ -327,12 +332,12 @@ Let's dive in!
Sample::

/*[clinic input]
module pickle
class pickle.Pickler
module _pickle
class _pickle.Pickler "PicklerObject *" "&Pickler_Type"
[clinic start generated code]*/

/*[clinic input]
pickle.Pickler.dump
_pickle.Pickler.dump

obj: 'O'
/
Expand All @@ -354,12 +359,12 @@ Let's dive in!
Sample::

/*[clinic input]
module pickle
class pickle.Pickler
module _pickle
class _pickle.Pickler "PicklerObject *" "&Pickler_Type"
[clinic start generated code]*/

/*[clinic input]
pickle.Pickler.dump
_pickle.Pickler.dump

obj: 'O'
The object to be pickled.
Expand All @@ -373,13 +378,13 @@ Let's dive in!
the file in your text editor to see::

/*[clinic input]
module pickle
class pickle.Pickler
module _pickle
class _pickle.Pickler "PicklerObject *" "&Pickler_Type"
[clinic start generated code]*/
/*[clinic end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/

/*[clinic input]
pickle.Pickler.dump
_pickle.Pickler.dump

obj: 'O'
The object to be pickled.
Expand All @@ -388,12 +393,12 @@ Let's dive in!
Write a pickled representation of obj to the open file.
[clinic start generated code]*/

PyDoc_STRVAR(pickle_Pickler_dump__doc__,
PyDoc_STRVAR(_pickle_Pickler_dump__doc__,
"Write a pickled representation of obj to the open file.\n"
"\n"
...
static PyObject *
pickle_Pickler_dump_impl(PyObject *self, PyObject *obj)
_pickle_Pickler_dump_impl(PicklerObject *self, PyObject *obj)
/*[clinic end generated code: checksum=3bd30745bf206a48f8b576a1da3d90f55a0a4187]*/

Obviously, if Argument Clinic didn't produce any output, it's because
Expand Down Expand Up @@ -428,8 +433,8 @@ Let's dive in!
macro defining the appropriate static :c:type:`PyMethodDef` structure for
this builtin::

#define _PICKLE_PICKLER_DUMP_METHODDEF \
{"dump", (PyCFunction)_pickle_Pickler_dump, METH_O, _pickle_Pickler_dump__doc__},
#define __PICKLE_PICKLER_DUMP_METHODDEF \
{"dump", (PyCFunction)__pickle_Pickler_dump, METH_O, __pickle_Pickler_dump__doc__},

This static structure should be *exactly* the same as the existing static
:c:type:`PyMethodDef` structure for this builtin.
Expand Down Expand Up @@ -463,13 +468,13 @@ Let's dive in!
Sample::

/*[clinic input]
module pickle
class pickle.Pickler
module _pickle
class _pickle.Pickler "PicklerObject *" "&Pickler_Type"
[clinic start generated code]*/
/*[clinic end generated code: checksum=da39a3ee5e6b4b0d3255bfef95601890afd80709]*/

/*[clinic input]
pickle.Pickler.dump
_pickle.Pickler.dump

obj: 'O'
The object to be pickled.
Expand All @@ -478,12 +483,12 @@ Let's dive in!
Write a pickled representation of obj to the open file.
[clinic start generated code]*/

PyDoc_STRVAR(pickle_Pickler_dump__doc__,
PyDoc_STRVAR(__pickle_Pickler_dump__doc__,
"Write a pickled representation of obj to the open file.\n"
"\n"
...
static PyObject *
pickle_Pickler_dump_impl(PyObject *self, PyObject *obj)
_pickle_Pickler_dump_impl(PicklerObject *self, PyObject *obj)
/*[clinic end generated code: checksum=3bd30745bf206a48f8b576a1da3d90f55a0a4187]*/
{
/* Check whether the Pickler was initialized correctly (issue3664).
Expand Down Expand Up @@ -515,8 +520,8 @@ Let's dive in!
Sample::

static struct PyMethodDef Pickler_methods[] = {
_PICKLE_PICKLER_DUMP_METHODDEF
_PICKLE_PICKLER_CLEAR_MEMO_METHODDEF
__PICKLE_PICKLER_DUMP_METHODDEF
__PICKLE_PICKLER_CLEAR_MEMO_METHODDEF
{NULL, NULL} /* sentinel */
};

Expand Down Expand Up @@ -1106,15 +1111,16 @@ Using a "self converter"
------------------------

Argument Clinic automatically adds a "self" parameter for you
using a default converter. However, you can override
using a default converter. It automatically sets the ``type``
of this parameter to the "pointer to an instance" you specified
when you declared the type. However, you can override
Argument Clinic's converter and specify one yourself.
Just add your own ``self`` parameter as the first parameter in a
block, and ensure that its converter is an instance of
``self_converter`` or a subclass thereof.

What's the point? This lets you automatically cast ``self``
from ``PyObject *`` to a custom type, just like ``object()``
does with its ``type`` parameter.
What's the point? This lets you override the type of ``self``,
or give it a different default name.

How do you specify the custom type you want to cast ``self`` to?
If you only have one or two functions with the same type for ``self``,
Expand Down Expand Up @@ -1502,6 +1508,8 @@ preset configurations, as follows:
and ``docstring_prototype``, write the ``impl_definition`` to
``block``, and write everything else to ``file``.

The default filename is ``"{dirname}/clinic/{basename}.h"``.

``buffer``
Save up all most of the output from Clinic, to be written into
your file near the end. For Python files implementing modules
Expand Down Expand Up @@ -1554,7 +1562,7 @@ The ``new`` subcommand works like this::

This creates a new destination with name ``<name>`` and type ``<type>``.

There are five destination types::
There are five destination types:

``suppress``
Throws the text away.
Expand All @@ -1575,12 +1583,18 @@ There are five destination types::
The template can use three strings internally that will be replaced
by bits of the filename:

{filename}
The full filename.
{path}
The full path to the file, including directory and full filename.
{dirname}
The name of the directory the file is in.
{basename}
Everything up to but not including the last '.'.
{extension}
The last '.' and everything after it.
Just the name of the file, not including the directory.
{basename_root}
Basename with the extension clipped off
(everything up to but not including the last '.').
{basename_extension}
The last '.' and everything after it. If the basename
does not contain a period, this will be the empty string.

If there are no periods in the filename, {basename} and {filename}
are the same, and {extension} is empty. "{basename}{extension}"
Expand Down