Skip to content

Commit 3ac0740

Browse files
committed
Distinguish top-level namespace
1 parent 078568e commit 3ac0740

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

mkdocstrings/handlers/crystal/items.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,9 @@ def full_name(self):
290290

291291
@property
292292
def abs_id(self):
293-
return (self.parent.abs_id + "::" if self.parent else "") + self.rel_id
293+
return (
294+
self.parent.abs_id + "::" if self.parent and self.parent.parent else ""
295+
) + self.rel_id
294296

295297
@property
296298
def kind(self) -> str:
@@ -325,12 +327,14 @@ def rel_id(self):
325327

326328
@property
327329
def abs_id(self):
328-
return (self.parent.abs_id if self.parent else "") + self.METHOD_ID_SEP + self.rel_id
330+
return (
331+
self.parent.abs_id + self.METHOD_ID_SEP if self.parent and self.parent.parent else ""
332+
) + self.rel_id
329333

330334
@property
331335
def short_name(self):
332336
"""Similar to [rel_id][mkdocstrings.handlers.crystal.items.DocItem.rel_id], but also includes the separator first, e.g. `#bar(x,y)` or `.baz()`"""
333-
return self.METHOD_SEP + self.name
337+
return (self.METHOD_SEP if self.parent and self.parent.parent else "") + self.name
334338

335339
@property
336340
def is_abstract(self) -> bool:

mkdocstrings/templates/crystal/material/type.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{{ log.debug() }}
22

33
<div class="doc doc-object doc-type {{ obj.kind }}">
4+
{% if obj.parent %}
45
<h{{ heading_level }}
56
id="{{ obj.abs_id }}"
67
class="doc doc-heading"
@@ -11,6 +12,7 @@
1112
<br/><small>inherits <code>{{ obj.superclass |reference }}</code></small>
1213
{% endif %}
1314
</h{{ heading_level }}>
15+
{% endif %}
1416

1517
<div class="doc doc-contents {% if root %}first{% endif %}">
1618
{% if obj.doc %}{{ obj.doc |convert_markdown(obj, heading_level, obj.abs_id) }}{% endif %}

0 commit comments

Comments
 (0)