Skip to content

Commit 7fe9473

Browse files
committed
Make sure top level package can always be determined
The default `linkcode_resolve()` function parses the package's top level module if it's not provided as a confval. If a custom `linkcode_resolve()` is used and `top_level` isn't set, won't be able to determine the top level module
1 parent da92a28 commit 7fe9473

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

docs/source/README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ Syntax Highlighting
137137

138138
.. literalinclude:: ../../sphinx_github_style/__init__.py
139139
:language: python
140-
:lines: 226-238
140+
:lines: 232-244
141141

142142
.. only:: readme or pypi
143143

sphinx_github_style/__init__.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,13 @@ def setup(app: Sphinx) -> Dict[str, Any]:
3333
top_level = get_conf_val(app, 'top_level')
3434
TDKLexer.TOP_LEVEL = top_level
3535

36-
if not callable(linkcode_func):
36+
if callable(linkcode_func):
37+
if not top_level:
38+
raise ExtensionError(
39+
"``sphinx-github-style``: must set the `top_level` confval"
40+
" or use the default `linkcode_resolve` function"
41+
)
42+
else:
3743
print(
3844
"Function `linkcode_resolve` not found in ``conf.py``; "
3945
"using default function from ``sphinx_github_style``"

0 commit comments

Comments
 (0)