Skip to content

feat(api): expose PDF heading hierarchy options in ConvertDocumentOptions - #756

Merged
edeandrea merged 3 commits into
docling-project:mainfrom
edeandrea:feature/heading-hierarchy-options
Oct 22, 2026
Merged

edeandrea merged 3 commits into
docling-project:mainfrom
edeandrea:feature/heading-hierarchy-options

Conversation

@edeandrea

@edeandrea edeandrea commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Expose Docling's HeadingHierarchyOptions in the docling-java API so callers can enable PDF section-header level inference from bookmarks, outline numbering and visual style.

What changed

HeadingHierarchyOptions (new)

  • 8 fields mirroring docling-serve: useBookmarks, useNumbering, useStyle, useFontStyle, styleSizeTolerance, numberingSchemes, maxLevel, bookmarkMatchThreshold
  • No enabled field — the presence of headingHierarchyOptions on ConvertDocumentOptions is the switch

ConvertDocumentOptions (modified)

  • New headingHierarchyOptions field (serialises as pdf_heading_hierarchy_options)
  • Derived doPdfHeadingHierarchy() getter — returns true when options are non-null, false otherwise
  • @Builder no longer has a doPdfHeadingHierarchy parameter

Tests

  • HeadingHierarchyOptionsTests — builder, getters, immutability, toBuilder
  • ConvertDocumentOptionsTests — with/without hierarchy, toBuilder preservation
  • AbstractDoclingServeClientTests.shouldInferHeadingHierarchyFromPdfNumbering — real-container test that converts a PDF with numbering and asserts multiple distinct heading levels are assigned

Docs

  • Updated whats-new.md (Docling Serve section)
  • Updated serve-api.md options list

Closes #754

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The derived JSON flag breaks strict Jackson 2 round-trips, and the reordered imports violate the enforced formatting configuration.

2 open issues
What changed in this PR

This PR exposes PDF heading hierarchy inference through the Java conversion API, addressing #754 by letting callers configure heading levels from bookmarks, numbering, and visual style.

Changes:

  • Adds eight configuration fields in HeadingHierarchyOptions and derives the enable flag from its presence in ConvertDocumentOptions.
  • Adds builder and copying tests, plus a real-container PDF hierarchy test.
  • Documents the new conversion capability.
File Description
docs/​src/​doc/​docs/​whats-new.md Announces heading hierarchy support.
docs/​src/​doc/​docs/​docling-serve/​serve-api.md Lists the new conversion option.
docling-serve/​docling-serve-client/​src/​test/​java/​ai/​docling/​serve/​client/​AbstractDoclingServeClientTests.java Tests inferred heading levels using a PDF.
docling-serve/​docling-serve-api/​src/​test/​java/​ai/​docling/​serve/​api/​convert/​request/​options/​HeadingHierarchyOptionsTests.java Tests configuration builders, getters, and immutability.
docling-serve/​docling-serve-api/​src/​test/​java/​ai/​docling/​serve/​api/​convert/​request/​options/​ConvertDocumentOptionsTests.java Tests hierarchy enablement and copying.
docling-serve/​docling-serve-api/​src/​main/​java/​ai/​docling/​serve/​api/​convert/​request/​options/​HeadingHierarchyOptions.java Defines heading inference configuration.
docling-serve/​docling-serve-api/​src/​main/​java/​ai/​docling/​serve/​api/​convert/​request/​options/​ConvertDocumentOptions.java Adds hierarchy options and the derived JSON enable flag.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 22, 2026 16:10
@edeandrea
edeandrea force-pushed the feature/heading-hierarchy-options branch from 6b05da2 to 5b6f6e9 Compare October 22, 2026 16:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The derived JSON flag lacks builder deserialization handling, breaking round trips with a default Jackson 2 mapper.

2 open issues
1 resolved since last review

Review effort: Balanced

@github-actions

Copy link
Copy Markdown

:java_duke: JaCoCo coverage report

Overall Project 52% 🟢

There is no coverage information present for the Files changed

@github-actions

github-actions Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
TestsPassed ☑️SkippedFailed ❌️
Gradle Test Results (all modules & JDKs)2296 ran2290 passed0 skipped6 failed
TestResult
Gradle Test Results (all modules & JDKs)
ai.docling.serve.client.AbstractDoclingServeClientTests$ConvertTests
AbstractDoclingServeClientTests$ConvertTests.shouldConvertFileSuccessfully()❌ failure
ai.docling.serve.client.AbstractDoclingServeClientTests$ConvertTests
AbstractDoclingServeClientTests$ConvertTests.shouldConvertFileSuccessfully()❌ failure
ai.docling.serve.client.AbstractDoclingServeClientTests$ChunkTests
AbstractDoclingServeClientTests$ChunkTests.shouldChunkFilesWithHierarchicalChunker()❌ failure
AbstractDoclingServeClientTests$ChunkTests.shouldChunkFileWithHybridChunker()❌ failure
ai.docling.serve.client.AbstractDoclingServeClientTests$ChunkTests
AbstractDoclingServeClientTests$ChunkTests.shouldChunkFilesWithHierarchicalChunker()❌ failure
AbstractDoclingServeClientTests$ChunkTests.shouldChunkFileWithHybridChunker()❌ failure

@github-actions

Copy link
Copy Markdown

HTML test reports are available as workflow artifacts (zipped HTML).

• Download: Artifacts for this run

Copilot AI balanced review requested due to automatic review settings October 22, 2026 16:21
@edeandrea edeandrea changed the title feat(docling-serve-api): expose PDF heading hierarchy options in ConvertDocumentOptions feat(api): expose PDF heading hierarchy options in ConvertDocumentOptions Oct 22, 2026
@edeandrea
edeandrea force-pushed the feature/heading-hierarchy-options branch from 5b6f6e9 to 2de081d Compare October 22, 2026 16:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved public-API Javadoc links need correction to satisfy the repository’s requirement to treat Javadoc errors as fatal.

3 open issues
1 resolved since last review

Review effort: Balanced

@github-actions

Copy link
Copy Markdown

HTML test reports are available as workflow artifacts (zipped HTML).

• Download: Artifacts for this run

Copilot AI balanced review requested due to automatic review settings October 22, 2026 16:43
…ions

Introduce HeadingHierarchyOptions with all docling-serve fields except
enabled (which is derived from the presence of this options object).
Add a derived doPdfHeadingHierarchy() getter that returns true when
headingHierarchyOptions is non-null.

Add unit tests for both options classes and a real-client integration
test that verifies heading levels are inferred from PDF numbering.

Update serve-api.md documentation to list the new option.

Closes docling-project#754

Signed-off-by: Eric Deandrea <eric.deandrea@ibm.com>
Add feature note for HeadingHierarchyOptions in the Docling Serve
section of what is new.

Signed-off-by: Eric Deandrea <eric.deandrea@ibm.com>
…options

The flag is derived from headingHierarchyOptions and has no builder
setter, so reading serialized options back would otherwise fail on the
unknown property. Also fix two Javadoc links to the Lombok getters.

Signed-off-by: Eric Deandrea <eric.deandrea@ibm.com>
@edeandrea
edeandrea force-pushed the feature/heading-hierarchy-options branch from 743d355 to db7421d Compare October 22, 2026 16:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The additive API changes have focused test coverage and no identified blocking issues; tests were not executed during this review.

1 open issue
2 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 22, 2026 16:47
@edeandrea
edeandrea enabled auto-merge (squash) October 22, 2026 16:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The additive API change has no identified blocking issues; the remaining serialization-test coverage suggestion is non-blocking.

2 open issues

Review effort: Balanced

@github-actions

Copy link
Copy Markdown

HTML test reports are available as workflow artifacts (zipped HTML).

• Download: Artifacts for this run

@edeandrea
edeandrea merged commit a932fe4 into docling-project:main Oct 22, 2026
29 checks passed
@edeandrea
edeandrea deleted the feature/heading-hierarchy-options branch October 22, 2026 17:11
@docling-java-ops docling-java-ops Bot added the released Issue has been released label Oct 22, 2026
@docling-java-ops

Copy link
Copy Markdown
Contributor

🎉 This issue has been resolved in v0.7.1 (Release Notes)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Issue has been released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Improvement] Support PDF heading hierarchy inference (HeadingHierarchyOptions) in ConvertDocumentOptions

2 participants