I use any
as the default role when for building my documentation with Sphinx, which works as intended by automatically linking some marked references and formatting the others as code while avoiding cluttering the docstrings with markup.
Unfortunately, when building the documentation this way, the output is cluttered with warnings for references for which any
could not find a target:
WARNING: 'any' reference target not found: […]
Is there any way to suppress these warnings?
So far, the only resource I could find on this manner was this question, which is however specific about an entirely different warning.
I filed a feature request for this, which was rejected but yielded a solution nontheless (thanks to Takeshi Komiya):
Add the following to conf.py
:
def on_missing_reference(app, env, node, contnode):
if node['reftype'] == 'any':
return contnode
else:
return None
def setup(app):
app.connect('missing-reference', on_missing_reference)