Introspection API
mkdocstrings_handlers.crystal.collector.CrystalCollector
#
Bases: BaseHandler
root: DocRoot
cached
property
#
The top-level namespace, represented as a fake module.
__init__(crystal_docs_flags: Sequence[str] = (), source_locations: Mapping[str, str] = {})
#
Create a "collector", reading docs from crystal doc
in the current directory.
Normally this should not be instantiated.
When using mkdocstrings-crystal within MkDocs, a plugin can access the instance as config.plugins['mkdocstrings'].get_handler('crystal')
.
See Extras.
mkdocstrings_handlers.crystal.items.DocItem
#
A representation of a documentable item from Crystal language.
abs_id: str
property
#
The absolute identifier of this item, sometimes known as "path", e.g. Foo::Bar
or Foo::Bar#baz(x,y)
.
This is also the canonical identifier that will be used as its HTML id.
doc: str | None
property
#
The doc comment of this item.
kind: str
abstractmethod
property
#
One of:
- module, class, struct, enum, alias, annotation,
- instance_method, class_method, macro,
- constant
name: str
property
#
The name of this item, e.g. Foo
or baz
.
parent: DocItem | None = parent
class-attribute
instance-attribute
#
The item that is the parent namespace for this item.
rel_id: str
property
#
The relative identifier of this item, e.g. Foo
or baz(x,y)
.
lookup(identifier: str | DocPath) -> DocItem
#
Find an item by its identifier, relative to this item or the root.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier |
str | DocPath
|
The item to search for. |
required |
Returns: An object that's a subclass of DocItem. Raises: CollectionError: When an item by that identifier couldn't be found.
Subclasses of DocItem#
DocType
#
Bases: DocItem
A DocItem representing a Crystal type.
ancestors: Sequence[DocPath]
cached
property
#
The modules and classes this type inherited.
class_methods: DocMapping[DocClassMethod]
cached
property
#
The class methods within this type.
constants: DocMapping[DocConstant]
cached
property
#
The constants (or enum members) within this type.
constructors: DocMapping[DocConstructor]
cached
property
#
The constructors within this type.
extended_modules: Sequence[DocPath]
cached
property
#
The modules that this type extended.
full_name: str
property
#
The path of this item, e.g. Foo::Bar(T)
or baz
.
included_modules: Sequence[DocPath]
cached
property
#
The modules that this type included.
including_types: Sequence[DocPath]
cached
property
#
Known types that include this type.
instance_methods: DocMapping[DocInstanceMethod]
cached
property
#
The instance methods within this type.
is_abstract: bool
property
#
Whether this type is abstract.
locations: Sequence[DocLocation]
cached
property
#
The code locations over which the definitions of this type span.
macros: DocMapping[DocMacro]
cached
property
#
The macros within this type.
subclasses: Sequence[DocPath]
cached
property
#
Known subclasses of this type.
superclass: DocPath | None
cached
property
#
The possible superclass of this type.
types: DocMapping[DocType]
cached
property
#
The types nested in this type as a namespace.
walk_types() -> Iterator[DocType]
#
Recusively iterate over all types under this type (excl. itself) in lexicographic order.
Subclasses of DocType#
DocAlias
#
Bases: DocType
A DocType representing a Crystal alias.
aliased: crystal_html.TextWithLinks
cached
property
#
A rich string containing the definition of what this is aliased to.
DocConstant
#
DocMethod
#
Bases: DocItem
A DocItem representing a Crystal method.
args_string: str
cached
property
#
A rich string with the method's parameters.
e.g. (foo : Bar) : Baz
is_abstract: bool
property
#
Whether this method is abstract.
location: DocLocation | None
cached
property
#
Code location of this method. Can be None
if unknown.
Subclasses of DocMethod#
DocConstructor
#
Bases: DocClassMethod
A DocInstanceMethod representing a Crystal macro.
Utilities#
mkdocstrings_handlers.crystal.items.DocMapping
#
Bases: Generic[D]
Represents items contained within a type. A container of DocItems.
__bool__() -> bool
#
bool(mapping)
to check whether it's non-empty.
__contains__(key: str) -> bool
#
"identifier" in mapping
to check whether the mapping contains an item by this identifier (see DocItem.rel_id).
__getitem__(key: str) -> D
#
mapping["identifier"]
to get the item by this identifier (see DocItem.rel_id).
Returns:
Type | Description |
---|---|
D
|
A DocItem |
Raises: KeyError: if the item is missing.
__iter__() -> Iterator[D]
#
Iterate over the items like a list.
__len__() -> int
#
len(mapping)
to get the number of items.
mkdocstrings_handlers.crystal.items.DocLocation
dataclass
#
mkdocstrings_handlers.crystal.items.DocPath
#
mkdocstrings_handlers.crystal.crystal_html.TextWithLinks
#
Bases: UserString
A string with embedded information about which parts of it are links to other items.
Can be converted to an actual string with str(obj)
-- or used directly, being a subclass of str
.
The link information is currently for internal use only.
tokens: Sequence[LinkToken] = tokens
instance-attribute
#
The list of embedded links.