@@ -1900,6 +1900,40 @@ blocks embedded in Python files look slightly different. They look like this:
1900
1900
#/*[python checksum:...]*/
1901
1901
1902
1902
1903
+ .. _clinic-howto-override-signature :
1904
+
1905
+ How to override the generated signature
1906
+ ---------------------------------------
1907
+
1908
+ You can use the ``@text_signature `` directive to override the default generated
1909
+ signature in the docstring.
1910
+ This can be useful for complex signatures that Argument Clinic cannot handle.
1911
+ The ``@text_signature `` directive takes one argument:
1912
+ the custom signature as a string.
1913
+ The provided signature is copied verbatim to the generated docstring.
1914
+
1915
+ Example from :source: `Objects/codeobject.c `::
1916
+
1917
+ /*[clinic input]
1918
+ @text_signature "($self, /, **changes)"
1919
+ code.replace
1920
+ *
1921
+ co_argcount: int(c_default="self->co_argcount") = unchanged
1922
+ co_posonlyargcount: int(c_default="self->co_posonlyargcount") = unchanged
1923
+ # etc ...
1924
+
1925
+ Return a copy of the code object with new values for the specified fields.
1926
+ [clinic start generated output]*/
1927
+
1928
+ The generated docstring ends up looking like this::
1929
+
1930
+ Doc_STRVAR(code_replace__doc__,
1931
+ "replace($self, /, **changes)\n"
1932
+ "--\n"
1933
+ "\n"
1934
+ "Return a copy of the code object with new values for the specified fields.");
1935
+
1936
+
1903
1937
.. _clinic-howto-deprecate-positional :
1904
1938
1905
1939
How to deprecate passing parameters positionally
0 commit comments