Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix:edit this context for undefined domain #286

Merged
merged 5 commits into from
Aug 31, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 27 additions & 22 deletions src/ansys_sphinx_theme/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""This is the ansys-sphinx-theme module."""
import logging
import pathlib
from typing import Any, Dict

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

if "_autosummary" in pagename:
for obj_node in list(doctree.findall(addnodes.desc)):
domain = obj_node.get("domain")
for signode in obj_node:
if not isinstance(signode, addnodes.desc_signature):
continue
# Convert signode to a specified format
info = {}
for key in DOMAIN_KEYS.get(domain, []):
value = signode.get(key)
if not value:
value = ""
info[key] = value
if not info:
continue
# This is an API example
return sphinx_linkcode_resolve(
domain=domain,
info=info,
library=f"{github_user}/{github_repo}",
source_path=github_source,
github_version=kind,
edit=True,
)
try:
domain = obj_node.get("domain")
for signode in obj_node:
if not isinstance(signode, addnodes.desc_signature):
continue
# Convert signode to a specified format
info = {}
for key in DOMAIN_KEYS.get(domain, []):
value = signode.get(key)
if not value:
value = ""
info[key] = value
if not info:
continue
# This is an API example
return sphinx_linkcode_resolve(
domain=domain,
info=info,
library=f"{github_user}/{github_repo}",
source_path=github_source,
github_version=kind,
edit=True,
)
except Exception as e:
RobPasMue marked this conversation as resolved.
Show resolved Hide resolved
logging.debug(f"An error occurred: {e}") # Log the exception as debug info
return link

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