API¶
Glossary class reference¶
mkdocs_ezglossary_plugin.glossary.Glossary
¶
The complete glossary for all sections.
Methods:
Name | Description |
---|---|
add |
Add a new entry to the glossary. |
clear |
Clear the glossary. |
definition |
Get the definition for a term. |
get |
Get all entries for a term, including singular/plural variants. |
get_best_definition |
Get the best matching definition for a term. |
get_defs |
Get all definition entries for a term. |
get_refs |
Get all reference entries for a term. |
has |
Check if the glossary has a section named section. |
ref_by_id |
Get a reference entry by its ID. |
terms |
Get all terms in a section. |
Functions¶
add(section, term, linktype, page, definition=None, anchor=None)
¶
Add a new entry to the glossary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
section
|
str
|
Section name to add the entry to. |
required |
term
|
str
|
The term (can be plural or singular). |
required |
linktype
|
str
|
Type of entry ('refs' or 'defs'). |
required |
page
|
str
|
Page object where the entry is located. |
required |
definition
|
str
|
Optional definition text. |
None
|
anchor
|
str
|
Optional anchor ID. |
None
|
Returns:
Name | Type | Description |
---|---|---|
str |
The ID of the added entry. |
clear()
¶
Clear the glossary.
definition(section, term)
¶
Get the definition for a term.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
section
|
str
|
The name of the section. |
required |
term
|
str
|
The term to get the definition for. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The definition of the term. |
get(section, term, linktype)
¶
Get all entries for a term, including singular/plural variants.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
section
|
str
|
Section to search in. |
required |
term
|
str
|
Term to find (can be plural or singular). |
required |
linktype
|
str
|
Type of entries to find ('refs' or 'defs'). |
required |
Returns:
Type | Description |
---|---|
list[Entry]
|
list[Entry]: List of matching Entry objects. |
get_best_definition(section, term)
¶
Get the best matching definition for a term.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
section
|
str
|
The glossary section. |
required |
term
|
str
|
The base term (usually singular). |
required |
Returns:
Name | Type | Description |
---|---|---|
Entry |
Entry
|
The best matching definition entry, or None if no match found. |
get_defs(section, term)
¶
Get all definition entries for a term.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
section
|
The name of the section. |
required | |
term
|
The term to get definitions for. |
required |
Returns:
Type | Description |
---|---|
list[Entry]: List of definition entries. |
get_refs(section, term)
¶
Get all reference entries for a term.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
section
|
The name of the section. |
required | |
term
|
The term to get references for. |
required |
Returns:
Type | Description |
---|---|
list[Entry]: List of reference entries. |
has(section)
¶
Check if the glossary has a section named section.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
section
|
str
|
The name of the section to check. |
required |
Returns:
Name | Type | Description |
---|---|---|
bool |
bool
|
True if a section with the given name exists. |
ref_by_id(id)
¶
Get a reference entry by its ID.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
str
|
The ID of the reference to find. |
required |
Returns:
Name | Type | Description |
---|---|---|
Entry |
Entry
|
The matching reference entry. |
Raises:
Type | Description |
---|---|
KeyError
|
If no reference with the given ID exists. |
terms(section)
¶
Get all terms in a section.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
section
|
str
|
The name of the section. |
required |
Returns:
Type | Description |
---|---|
list[str]
|
list[str]: List of terms in the section. |
Entry class reference¶
mkdocs_ezglossary_plugin.glossary.Entry
¶
An entry in the glossary.
Methods:
Name | Description |
---|---|
__repr__ |
Return a string representation of the entry showing all fields. |
Attributes:
Name | Type | Description |
---|---|---|
definition |
The definition of the term. |
|
page |
The URL of the page to which this entry points. |
|
ref_id |
The ID of the reference link to this entry. |
|
section |
The section of the term of this entry. (Since v1.7.0a1) |
|
target |
The anchor to directly point to this specific link. |
|
term |
The term of this entry. (Since v1.7.0a1) |
Attributes¶
definition = definition
instance-attribute
¶
The definition of the term.
page = page
instance-attribute
¶
The URL of the page to which this entry points.
ref_id = ref_id
instance-attribute
¶
The ID of the reference link to this entry.
section = section
instance-attribute
¶
The section of the term of this entry. (Since v1.7.0a1)
target = target
instance-attribute
¶
The anchor to directly point to this specific link.
term = term
instance-attribute
¶
The term of this entry. (Since v1.7.0a1)
Functions¶
__repr__()
¶
Return a string representation of the entry showing all fields.