Skip to content

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.

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.

has

Check if the glossary has a section named section.

ref_by_id

Get a reference entry by its ID.

Functions
_get_term_variants(term)

Get all singular/plural variants of a term.

Parameters:

Name Type Description Default
term str

Term to find variants for

required

Returns:

Type Description
set[str]

Set of variant terms (including original)

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
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:

Type Description
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 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

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:

Type Description
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

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 to.

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 to.

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.