Skip to content

Commit eba20ff

Browse files
maint: update the attributes
1 parent 5b456d5 commit eba20ff

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/ansys_sphinx_theme/extension/linkcode.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,18 @@ def link_code(app: Sphinx, doctree: Node):
186186
github_source = html_context.get("source_path", "")
187187
github_version = html_context.get("github_version", "main")
188188

189-
if hasattr(env.config, "link_code_library"):
189+
if getattr(env.config, "link_code_library"):
190190
library = getattr(env.config, "link_code_library")
191-
github_source = getattr(env.config, "link_code_source", github_source)
192-
github_version = getattr(env.config, "link_code_branch", github_version)
191+
193192
elif github_user and github_repo:
194193
library = f"{github_user}/{github_repo}"
195194

196195
else:
197196
raise AttributeError("The library should have either html_context or link_code_library.")
197+
198+
github_source = getattr(env.config, "link_code_source", github_source)
199+
github_version = getattr(env.config, "link_code_branch", github_version)
200+
198201
if not library:
199202
raise AttributeError(
200203
"The conf.py file either should have html_context or link_code_library with github_repo and github_user." # noqa: E501

0 commit comments

Comments
 (0)