Skip to content

Commit 5253cee

Browse files
committed
Allow referencing top-level namespace and linking to items in it
1 parent 3c9a575 commit 5253cee

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

mkdocstrings/handlers/crystal/collector.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ def root(self) -> DocModule:
5959
"""The top-level namespace, represented as a fake module."""
6060
try:
6161
with self._proc:
62-
return DocModule(json.load(self._proc.stdout)["program"], None, None)
62+
data = json.load(self._proc.stdout)
63+
data["program"]["full_name"] = ""
64+
return DocModule(data["program"], None, None)
6365
finally:
6466
if self._proc.returncode:
6567
cmd = " ".join(shlex.quote(arg) for arg in self._proc.args)
@@ -75,7 +77,9 @@ def collect(self, identifier: str, config: Mapping[str, Any]) -> "DocView":
7577
"""
7678
config = collections.ChainMap(config, self.default_config)
7779

78-
item = self.root.lookup(identifier)
80+
item = self.root
81+
if identifier != "::":
82+
item = item.lookup(identifier)
7983
view = DocView(item, config)
8084
if isinstance(item, DocType):
8185
self._collected.update((item,))

0 commit comments

Comments
 (0)