Skip to main content
Version: latest

agrag.common.data_models.structure.ancestors

ancestors(sections:list[DocumentSection], index:int) -> list[int]

Return the index of a section and of each section above it.

Parameters:

  • sections (list[DocumentSection]) – The sections of a document.
  • index (int) – The index of the section.

Returns:

  • list[int] – The indexes from the outermost ancestor down to the section itself.

Raises:

  • ValueError – The index is outside sections, or the parent links form a cycle or leave sections.