Skip to content

Commit

Permalink
If we fail to find the object given by path, catch the error (#162)
Browse files Browse the repository at this point in the history
This corresponds to some slightly weird code paths in convertReferenceToXRef.
Ideally we'd fix them but I don't know how.
  • Loading branch information
hoodmane authored May 7, 2024
1 parent bbcc4b0 commit a012f65
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions sphinx_js/js/convertType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ class TypeConverter implements TypeVisitor<Type> {
};
return this.addTypeArguments(type, [xref]);
} else {
// TODO: I'm not sure that it's right to generate an internal xref here.
// We need better test coverage for this code path.
const xref: TypeXRefInternal = {
name: type.name,
path,
Expand Down
17 changes: 12 additions & 5 deletions sphinx_js/renderers.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,11 +454,18 @@ def strs() -> Iterator[str]:
def render_xref(self, s: TypeXRef, escape: bool = False) -> str:
obj = None
if isinstance(s, TypeXRefInternal):
obj = self.lookup_object(s.path)
# Stick the kind on the xref so that the formatter will know what
# xref role to emit. I'm not sure how to compute this earlier. It's
# convenient to do it here.
s.kind = type(obj).__name__.lower()
try:
obj = self.lookup_object(s.path)
# Stick the kind on the xref so that the formatter will know what
# xref role to emit. I'm not sure how to compute this earlier. It's
# convenient to do it here.
s.kind = type(obj).__name__.lower()
except SphinxError:
# This sometimes happens on the code path in
# convertReferenceToXRef when we generate an xref internal from
# a symbolId. That code path is probably entirely wrong.
# TODO: fix and add test coverage.
pass
result = self._type_xref_formatter(s)
if escape:
result = rst.escape(result)
Expand Down

0 comments on commit a012f65

Please sign in to comment.