myst_parser.inventory
#
Logic for dealing with sphinx style inventories (e.g. objects.inv).
These contain mappings of reference names to ids, scoped by domain and object type.
This is adapted from the Sphinx inventory.py module. We replicate it here, so that it can be used without Sphinx.
1. Module Contents#
1.1. Classes#
A single inventory item. |
|
Inventory data. |
|
A file reader for an inventory file. |
|
A match from an inventory. |
1.2. Functions#
Convert from a Sphinx compliant format. |
|
Convert to a Sphinx compliant format. |
|
Load inventory data from a stream. |
|
Match a whole name with a pattern, that can include * wildcards, to match 0 or more characters. |
|
Filter a set of inventories. |
|
Filter a set of sphinx style inventories. |
|
Create a string representation of the filter, from the given arguments. |
|
Fetch an inventory from a URL or local path. |
|
Command line interface for fetching and parsing an inventory. |
1.3. API#
- class myst_parser.inventory.InventoryItemType[source]#
Bases:
typing.TypedDict
A single inventory item.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- class myst_parser.inventory.InventoryType[source]#
Bases:
typing.TypedDict
Inventory data.
Initialization
Initialize self. See help(type(self)) for accurate signature.
- myst_parser.inventory.from_sphinx(inv: sphinx.util.typing.Inventory) myst_parser.inventory.InventoryType [source]#
Convert from a Sphinx compliant format.
- myst_parser.inventory.to_sphinx(inv: myst_parser.inventory.InventoryType) sphinx.util.typing.Inventory [source]#
Convert to a Sphinx compliant format.
- myst_parser.inventory.load(stream: IO, base_url: str | None = None) myst_parser.inventory.InventoryType [source]#
Load inventory data from a stream.
- class myst_parser.inventory.InventoryFileReader(stream: IO)[source]#
A file reader for an inventory file.
This reader supports mixture of texts and compressed texts.
Initialization
- readlines() collections.abc.Iterator[str] [source]#
- read_compressed_chunks() collections.abc.Iterator[bytes] [source]#
- read_compressed_lines() collections.abc.Iterator[str] [source]#
- myst_parser.inventory.match_with_wildcard(name: str, pattern: str | None) bool [source]#
Match a whole name with a pattern, that can include * wildcards, to match 0 or more characters.
To include a literal * in the pattern, use *.
- myst_parser.inventory.filter_inventories(inventories: dict[str, myst_parser.inventory.InventoryType], *, invs: str | None = None, domains: str | None = None, otypes: str | None = None, targets: str | None = None) collections.abc.Iterator[myst_parser.inventory.InvMatch] [source]#
Filter a set of inventories.
- Filters are strings that can include * wildcards, to match 0 or more characters.
To include a literal * in the pattern, use *.
- Parameters:
inventories – Mapping of inventory name to inventory data
invs – the inventory key filter
domains – the domain name filter
otypes – the object type filter
targets – the target name filter
- myst_parser.inventory.filter_sphinx_inventories(inventories: dict[str, sphinx.util.typing.Inventory], *, invs: str | None = None, domains: str | None = None, otypes: str | None = None, targets: str | None = None) collections.abc.Iterator[myst_parser.inventory.InvMatch] [source]#
Filter a set of sphinx style inventories.
- Filters are strings that can include * wildcards, to match 0 or more characters.
To include a literal * in the pattern, use *.
- Parameters:
inventories – Mapping of inventory name to inventory data
invs – the inventory key filter
domains – the domain name filter
otypes – the object type filter
targets – the target name filter
- myst_parser.inventory.filter_string(invs: str | None, domains: str | None, otype: str | None, target: str | None, *, delimiter: str = ':') str [source]#
Create a string representation of the filter, from the given arguments.