DocItemLabel Type System#
DocItemLabel is the primary enum that classifies every content-bearing element in a DoclingDocument. It is defined as a str enum in docling_core/types/doc/labels.py and is the value stored in every DocItem.label field.
DocItemLabel Enum Values#
The full label set :
| Label | String value | Notes |
|---|---|---|
CAPTION | "caption" | |
FOOTNOTE | "footnote" | |
FORMULA | "formula" | |
LIST_ITEM | "list_item" | |
PAGE_FOOTER | "page_footer" | |
PAGE_HEADER | "page_header" | |
PICTURE | "picture" | |
SECTION_HEADER | "section_header" | |
TABLE | "table" | |
TEXT | "text" | |
TITLE | "title" | |
DOCUMENT_INDEX | "document_index" | |
CODE | "code" | |
CHECKBOX_SELECTED / CHECKBOX_UNSELECTED | "checkbox_selected" / "checkbox_unselected" | |
FORM | "form" | |
KEY_VALUE_REGION | "key_value_region" | |
GRADING_SCALE | "grading_scale" | Form questionnaire scales |
HANDWRITTEN_TEXT | "handwritten_text" | |
EMPTY_VALUE | "empty_value" | Empty fillable form field |
PARAGRAPH | "paragraph" | Markup-based formats (HTML, Word) |
REFERENCE | "reference" | Markup-based formats |
FIELD_REGION / FIELD_HEADING / FIELD_ITEM / FIELD_KEY / FIELD_VALUE / FIELD_HINT | — | Fine-grained form field sub-labels |
MARKER | "marker" | |
CHART | "chart" | Deprecated — use PICTURE + PictureClassificationLabel |
Each label has a canonical RGB color for visualization, accessible via DocItemLabel.get_color(label).
Base Class: DocItem#
DocItem (in docling_core/types/doc/items/node.py) is the Pydantic base for all content elements. It declares the label field as an open DocItemLabel :
class DocItem(NodeItem):
label: DocItemLabel
prov: list[ProvenanceItem] = []
...
Subclasses narrow this field using typing.Literal to enforce a restricted set of valid labels at Pydantic validation time.
Concrete Item Classes and Their Label Constraints#
Each specialized item class pins label to one or more DocItemLabel values via Literal. This makes it impossible to construct, say, a TitleItem with label=DocItemLabel.CODE.
TextItem — multi-label catch-all#
TextItem accepts 14 labels: CAPTION, CHECKBOX_SELECTED, CHECKBOX_UNSELECTED, FOOTNOTE, PAGE_FOOTER, PAGE_HEADER, PARAGRAPH, REFERENCE, TEXT, EMPTY_VALUE, FIELD_KEY, FIELD_HINT, MARKER, and HANDWRITTEN_TEXT. It also carries orig, text, optional formatting, and optional hyperlink fields.
Single-label text subclasses#
All inherit from TextItem and narrow the label to exactly one value :
| Class | Label | Extra fields |
|---|---|---|
TitleItem | TITLE | — |
SectionHeaderItem | SECTION_HEADER | level: LevelNumber (1–100) |
ListItem | LIST_ITEM | enumerated: bool, marker: str |
FormulaItem | FORMULA | — |
CodeItem#
CodeItem inherits from both FloatingItem and TextItem, pinning label to CODE. It adds code_language: CodeLanguageLabel (see CodeLanguageLabel for the 50+ supported language values).
TableItem — two accepted labels#
TableItem (in docling_core/types/doc/items/table/table.py) accepts either TABLE or DOCUMENT_INDEX, defaulting to TABLE.
PictureItem — two accepted labels#
PictureItem (in docling_core/types/doc/items/picture/picture.py) accepts either PICTURE or CHART (the latter is deprecated), defaulting to PICTURE.
Form and key-value items#
Defined in docling_core/types/doc/items/form.py and key_value.py:
| Class | Label |
|---|---|
FieldRegionItem | FIELD_REGION |
FieldHeadingItem | FIELD_HEADING |
FieldItem | FIELD_ITEM |
FieldValueItem | FIELD_VALUE |
KeyValueItem | KEY_VALUE_REGION |
FormItem | FORM |
Related Label Enums in labels.py#
DocItemLabel is not the only label enum in labels.py. The file also contains:
GroupLabel— used byGroupItemcontainer nodes (LIST,ORDERED_LIST,CHAPTER,SECTION,SLIDE,FORM_AREA, etc.).GroupItemusesGroupLabel, notDocItemLabel.PictureClassificationLabel— fine-grained classification for pictures (chart types, photographs, barcodes, chemistry structures, etc.), stored in picture metadata rather than in thelabelfield.TableCellLabel—COLUMN_HEADER,ROW_HEADER,ROW_SECTION,BODY— applied to individual table cells.CodeLanguageLabel— programming language identifier forCodeItem.code_language.HumanLanguageLabel— BCP-47 two-letter language tags.
Key Design Pattern#
Subclasses use # type: ignore[assignment] to suppress mypy warnings when narrowing the inherited label type . This is the standard pattern throughout the items package — Pydantic enforces the Literal constraint at runtime, and mypy's type-narrowing complaint is suppressed.
Import Path#
from docling_core.types.doc.labels import DocItemLabel
DocItemLabel is also re-exported from docling_core.types.doc .