Skip to content

docx_plus.notes.registry

Footnote and endnote id registries. The two kinds use disjoint namespaces — a footnote with id 1 and an endnote with id 1 can coexist. Ids -1 (separator) and 0 (continuation separator) are reserved by Word; the registries refuse to issue or reserve them (the underlying range check on _IdRegistryBase.reserve rejects values outside [1, 2**31 - 1] before any duplicate check runs).

docx_plus.notes.registry

Footnote / endnote id registries.

Footnote and endnote ids are two separate uniqueness namespaces. Ids -1 and 0 are reserved by Word for the separator and continuation separator entries respectively, so both registries refuse to issue those.

This module imports only from docx_plus.core (SPEC §9.1).

FootnoteIdRegistry

FootnoteIdRegistry(doc: Document)

Bases: _NoteIdRegistryBase

Tracks issued footnote w:id values for one document-edit session.

Source code in docx_plus/core/ids.py
def __init__(self, doc: Document) -> None:
    """Scan ``doc`` for IDs already issued in this namespace.

    Args:
        doc: A python-docx :class:`~docx.document.Document`.
    """
    self._issued: set[int] = set()
    self._seed_from_document(doc)

EndnoteIdRegistry

EndnoteIdRegistry(doc: Document)

Bases: _NoteIdRegistryBase

Tracks issued endnote w:id values for one document-edit session.

Source code in docx_plus/core/ids.py
def __init__(self, doc: Document) -> None:
    """Scan ``doc`` for IDs already issued in this namespace.

    Args:
        doc: A python-docx :class:`~docx.document.Document`.
    """
    self._issued: set[int] = set()
    self._seed_from_document(doc)