File tree 2 files changed +34
-1
lines changed
Misc/NEWS.d/next/Tools-Demos 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -1893,3 +1893,36 @@ blocks embedded in Python files look slightly different. They look like this:
1893
1893
#[python start generated code]*/
1894
1894
def foo(): pass
1895
1895
#/*[python checksum:...]*/
1896
+
1897
+
1898
+ .. _clinic-howto-override-signature :
1899
+
1900
+ How to override the generated signature
1901
+ ---------------------------------------
1902
+
1903
+ You can use the ``@text_signature `` directive to override the default generated
1904
+ signature in the docstring.
1905
+ This can be useful for complex signatures that Argument Clinic cannot handle.
1906
+ The ``@text_signature `` directive takes one argument:
1907
+ the custom signature as a string.
1908
+ The provided signature is copied verbatim to the generated docstring.
1909
+
1910
+ Example from :source: `Objects/codeobject.c `::
1911
+
1912
+ /*[clinic input]
1913
+ @text_signature "($self, /, **changes)"
1914
+ code.replace
1915
+ *
1916
+ co_argcount: int(c_default="self->co_argcount") = unchanged
1917
+ co_posonlyargcount: int(c_default="self->co_posonlyargcount") = unchanged
1918
+ # etc ...
1919
+
1920
+ Return a copy of the code object with new values for the specified fields.
1921
+ [clinic start generated output]*/
1922
+
1923
+ The generated docstring ends up looking like this::
1924
+
1925
+ replace($self, /, **changes)
1926
+ --
1927
+
1928
+ Return a copy of the code object with new values for the specified fields.
Original file line number Diff line number Diff line change 1
1
Argument Clinic now supports overriding automatically generated signature by
2
- using directive ``@text_signature ``.
2
+ using directive ``@text_signature ``. See :ref: ` clinic-howto-override-signature `.
You can’t perform that action at this time.
0 commit comments