Skip to content

Commit 572d621

Browse files
Fix:edit this context for undefined domain (#286)
1 parent 60a7a0b commit 572d621

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

src/ansys_sphinx_theme/__init__.py

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""This is the ansys-sphinx-theme module."""
2+
import logging
23
import pathlib
34
from typing import Any, Dict
45

@@ -159,28 +160,32 @@ def fix_edit_link_page(link: str) -> str:
159160

160161
if "_autosummary" in pagename:
161162
for obj_node in list(doctree.findall(addnodes.desc)):
162-
domain = obj_node.get("domain")
163-
for signode in obj_node:
164-
if not isinstance(signode, addnodes.desc_signature):
165-
continue
166-
# Convert signode to a specified format
167-
info = {}
168-
for key in DOMAIN_KEYS.get(domain, []):
169-
value = signode.get(key)
170-
if not value:
171-
value = ""
172-
info[key] = value
173-
if not info:
174-
continue
175-
# This is an API example
176-
return sphinx_linkcode_resolve(
177-
domain=domain,
178-
info=info,
179-
library=f"{github_user}/{github_repo}",
180-
source_path=github_source,
181-
github_version=kind,
182-
edit=True,
183-
)
163+
try:
164+
domain = obj_node.get("domain")
165+
for signode in obj_node:
166+
if not isinstance(signode, addnodes.desc_signature):
167+
continue
168+
# Convert signode to a specified format
169+
info = {}
170+
for key in DOMAIN_KEYS.get(domain, []):
171+
value = signode.get(key)
172+
if not value:
173+
value = ""
174+
info[key] = value
175+
if not info:
176+
continue
177+
# This is an API example
178+
return sphinx_linkcode_resolve(
179+
domain=domain,
180+
info=info,
181+
library=f"{github_user}/{github_repo}",
182+
source_path=github_source,
183+
github_version=kind,
184+
edit=True,
185+
)
186+
except ValueError as e:
187+
logging.debug(f"An error occurred: {e}") # Log the exception as debug info
188+
return link
184189

185190
elif "autoapi" in pagename:
186191
for obj_node in list(doctree.findall(addnodes.desc)):

0 commit comments

Comments
 (0)