Skip to content

Commit

Permalink
Avoid multiple-targets-found error in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Peque committed Apr 5, 2019
1 parent 92bfc39 commit 30b90bc
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#
# All configuration values have a default; values that are commented out
# serve to show the default.
from sphinx.domains.python import PythonDomain

import osbrain

Expand Down Expand Up @@ -270,3 +271,32 @@

# If true, do not generate a @detailmenu in the "Top" node's menu.
#texinfo_no_detailmenu = False


class MyPythonDomain(PythonDomain):
def find_obj(self, env, modname, classname, name, type, searchmode=0):
"""
Ensures an object always resolves to the desired module if defined
there.
See: https://github.com/sphinx-doc/sphinx/issues/3866
"""
orig_matches = PythonDomain.find_obj(self, env, modname, classname, name, type, searchmode)
matches = []
for match in orig_matches:
match_name = match[0]
desired_name = 'osbrain' + '.' + name.strip('.')
if match_name == desired_name:
matches.append(match)
break
if matches:
return matches
else:
return orig_matches


def setup(sphinx):
"""
Use MyPythonDomain in place of PythonDomain.
"""
sphinx.override_domain(MyPythonDomain)

0 comments on commit 30b90bc

Please sign in to comment.