8000 refactor: Return anchors as a tuple, not a set, to preserve order · mkdocstrings/python@736a2b5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 736a2b5

Browse files
committed
refactor: Return anchors as a tuple, not a set, to preserve order
Related-to #mkdocstrings/crystal#6: mkdocstrings/crystal#6
1 parent 20be8f8 commit 736a2b5

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/mkdocstrings_handlers/python/handler.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,17 @@ def update_env(self, md: Markdown, config: dict) -> None: # noqa: D102 (ignore
357357
self.env.filters["get_template"] = rendering.do_get_template
358358
self.env.tests["existing_template"] = lambda template_name: template_name in self.env.list_templates()
359359

360-
def get_anchors(self, data: CollectorItem) -> set[str]: # noqa: D102 (ignore missing docstring)
360+
def get_anchors(self, data: CollectorItem) -> tuple[str, ...]: # noqa: D102 (ignore missing docstring)
361+
anchors = [data.path]
361362
try:
362-
return {data.path, data.canonical_path, *data.aliases}
363+
if data.canonical_path != data.path:
364+
anchors.append(data.canonical_path)
365+
for anchor in data.aliases:
366+
if anchor not in anchors:
367+
anchors.append(anchor)
363368
except AliasResolutionError:
364-
return {data.path}
369+
return tuple(anchors)
370+
return tuple(anchors)
365371

366372

367373
def get_handler(

0 commit comments

Comments
 (0)
0