inventory¶
Types
- inventory.Error :: enum u8¶
-
- None¶
- Unknown_Version¶
-
the header names no inventory version Sphinx writes.
- Truncated¶
-
the header ends early.
- Bad_Compression¶
-
the zlib data does not inflate.
- Out_Of_Memory¶
-
the allocator refused memory: the inventory may be incomplete.
- inventory.Inventory :: struct¶
-
- project: string¶
- version: string¶
- by_type: map[string]map[string]int¶
-
by_type[type][name] is the index of the item in items.
- folded: map[string]map[string]string¶
-
folded[type][lowercase name] is the first name of that spelling, for the types Sphinx matches ignoring case (labels and terms).
- inventory.Item :: struct¶
-
- project: string¶
-
the inventory’s project and version, for “(in Python v3.14)”.
- version: string¶
- name: string¶
- type: string¶
-
domain:objtype, such as “py:function”.
- priority: int¶
- uri: string¶
-
absolute, or relative to the inventory’s base.
- display: string¶
-
“-“ when it is the name itself.
Procedures
- inventory.add :: proc(inv: ^Inventory, item: Item) -> bool¶
-
add appends an item and indexes it; a later item of the same type and name replaces the earlier one in the index, as a later line overwrites in Sphinx’s dictionaries. It allocates with context.allocator, the arena the inventory lives in, and keeps item’s strings, which must live as long. It is false, and the item may be left out, when the allocator refuses memory.
- inventory.find :: proc(inv: ^Inventory, type, name: string) -> (Item, bool)¶
-
find returns the item of a type and name, which borrows the inventory.
- inventory.find_folded :: proc(inv: ^Inventory, type, name: string) -> (Item, bool)¶
-
find_folded returns the item of a type whose name matches ignoring case: the first such name listed, as Sphinx matches labels and terms. The item borrows the inventory; the lowercase key is made in the temp allocator.
- inventory.load :: proc(data: []u8, base: string, allocator := context.allocator) -> (inv: Inventory, err: Error)¶
-
load reads an inventory. base joins relative locations, as Sphinx joins them with the URL or folder the inventory came from; “” leaves them as written. It allocates the inventory and its temporary work with allocator, an arena the caller frees; data is only borrowed. A header it does not know, or data that does not inflate, is an Error.
- inventory.sort_items :: proc(items: []Item)¶
-
sort_items orders items as Sphinx writes them: by domain, then by the name, display, type, and location of each object.
- inventory.write :: proc(project, version: string, items: []Item, allocator := context.allocator) -> []u8¶
-
write returns an inventory in version 2 format, lines in the order given, as Sphinx writes them sorted. Locations ending in the name are shortened with $, and a display equal to the name is written as -. It allocates the bytes, and its temporary work, with allocator, an arena the caller frees.