Skip to content

Commit

Permalink
Disable buggy cross referencing
Browse files Browse the repository at this point in the history
Sphinx attempts to create cross-references for attribute and variable names...

  sphinx-doc/sphinx#2549
  sphinx-doc/sphinx#3866

This results in numerous warnings of the form...

  WARNING: more than one target found for cross-reference 'digest'

Adapting a patch from the tickets above. Sphinx deprecated override_domain(),
so using add_domain() instead...

  https://www.sphinx-doc.org/en/2.0/extdev/appapi.html#sphinx.application.Sphinx.override_domain
  • Loading branch information
atagar committed May 14, 2020
1 parent 0354799 commit a22ebbd
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# serve to show the default.

import sys, os
from sphinx.domains.python import PythonDomain

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand Down Expand Up @@ -260,9 +261,35 @@
trac_url = 'https://trac.torproject.org/{slug}'
spec_url = 'https://gitweb.torproject.org/torspec.git/commit/?id={slug}'


def skip_members(app, what, name, obj, skip, options):
if name in ('ATTRIBUTES', 'PARSER_FOR_LINE'):
return True # skip the descriptor's parser constants


class PythonDomainNoXref(PythonDomain):
"""
Sphinx attempts to create cross-reference links for variable names...
https://github.com/sphinx-doc/sphinx/issues/2549
https://github.com/sphinx-doc/sphinx/issues/3866
This causes alot of warnings such as...
stem/descriptor/networkstatus.py:docstring of
stem.descriptor.networkstatus.DocumentDigest:: WARNING: more than one
target found for cross-reference 'digest':
stem.descriptor.extrainfo_descriptor.ExtraInfoDescriptor.digest, ...
"""

def resolve_xref(self, env, fromdocname, builder, typ, target, node, contnode):
if 'refspecific' in node:
del node['refspecific']

return super(PythonDomainNoXref, self).resolve_xref(
env, fromdocname, builder, typ, target, node, contnode)


def setup(app):
app.connect('autodoc-skip-member', skip_members)
app.add_domain(PythonDomainNoXref, override = True)

0 comments on commit a22ebbd

Please sign in to comment.