def METHOD_NAME(app, filename, contents, *args):
    # FIXME: the missing typedef for 'HPy' causes the file formatting to fail
    if filename.endswith('public_api.h'):
        contents[0] = '#include "../../devel/include/hpy.h"\n' + contents[0]
    if filename.endswith('autogen_ctx.h'):
        contents[0] = 'typedef int HPy;' + contents[0]
    # remove HPyAPI_HELPER so that the sphinx-c-autodoc and clang
    # find and render the API functions
    contents[:] = [
        re.sub(r"^(HPyAPI_HELPER|HPyAPI_INLINE_HELPER|HPy_ID\(\d+\))", r"", part, flags=re.MULTILINE)
        for part in contents
    ]