Skip to content

Commit 95902d9

Browse files
committed
Fix issue with pkg_name config values
1 parent 5995f9e commit 95902d9

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

sphinx_github_style/meth_lexer.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import copy
2+
import types
3+
from typing import Type
4+
from sphinx.application import Sphinx
15
from pygments.lexers.python import NumPyLexer
26
from inspect import getmembers, isfunction, ismethod, ismodule, isclass
3-
from sphinx.application import Sphinx
4-
from typing import Type
5-
import types
67

78

89
def get_pkg_funcs(pkg: types.ModuleType):
@@ -32,16 +33,17 @@ class TDKMethLexer(NumPyLexer):
3233
url = 'https://github.com/TDKorn'
3334
aliases = ['tdk']
3435

35-
EXTRA_KEYWORDS = NumPyLexer.EXTRA_KEYWORDS
36+
EXTRA_KEYWORDS = {}
3637

3738
@classmethod
3839
def get_pkg_lexer(cls, pkg_name: str) -> Type["TDKMethLexer"]:
3940
pkg = __import__(pkg_name)
4041
funcs = get_pkg_funcs(pkg)
41-
cls.EXTRA_KEYWORDS.update(funcs)
42+
cls.EXTRA_KEYWORDS = funcs
4243
return cls
4344

4445

4546
def setup(app: Sphinx):
46-
pkg_name = app.config._raw_config['pkg_name']
47+
# Get pkg_name from conf.py; fallback to pkg_name set by __init__.py
48+
pkg_name = app.config._raw_config.get('pkg_name', app.config.pkg_name)
4749
app.add_lexer('python', TDKMethLexer.get_pkg_lexer(pkg_name))

0 commit comments

Comments
 (0)