Fairly early in output_templates(), we've got this comment:
# we have to set these things before we're done:
#
# docstring_prototype
# docstring_definition
# impl_prototype
# methoddef_define
# parser_prototype
# parser_definition
# impl_definition
# cpp_if
# cpp_endif
# methoddef_ifndef
Post this comment, there are a few large blocks of code where most of these "fields" are set; these blocks depend on the type of call:
no args -- METH_NOARGS
one positional arg -- METH_O
optional groups
positional only args
methods/funcs with keyword args
Post these cases, most of the "fields" are set and there follows some fairly complex "post-processing" code (produce deprecation warnings, process some of the templates, and there's also some special handling for new/init methods.
We should try to refactor the five major cases in some kind of way. Perhaps a "builder class" that holds the required fields is the best approach. Perhaps "builder class" helpers for rendering Limited API fields and Internal API fields would be useful.
Fairly early in
output_templates()
, we've got this comment:Post this comment, there are a few large blocks of code where most of these "fields" are set; these blocks depend on the type of call:
METH_NOARGS
METH_O
Post these cases, most of the "fields" are set and there follows some fairly complex "post-processing" code (produce deprecation warnings, process some of the templates, and there's also some special handling for new/init methods.
We should try to refactor the five major cases in some kind of way. Perhaps a "builder class" that holds the required fields is the best approach. Perhaps "builder class" helpers for rendering Limited API fields and Internal API fields would be useful.