Skip to content

Rename the Section fields, require metadata.id and freeze the models - #38

Merged
Gal-Gilor merged 1 commit into
mainfrom
refactor/section-fields
Oct 18, 2026
Merged

Gal-Gilor merged 1 commit into
mainfrom
refactor/section-fields

Conversation

@Gal-Gilor

@Gal-Gilor Gal-Gilor commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Renamed Section.section_header, section_text and header_level to header, content and level, matching OutlineNode, and merged MarkdownContent into Section (field order: header, content, level, metadata). to_markdown() and breadcrumb() use the new names.
  • SectionMetadata.id is a required int (description kept).
  • Section, SectionMetadata and OutlineNode have model_config = ConfigDict(frozen=True). The splitter never assigns attributes after construction, so it needed only the renamed keyword arguments. It does rely on appending to a parent node's children list in get_document_outline, which still works on a frozen model.
  • Updated the splitter docstrings and doctests, the tests, the CI wheel check (split_text('# Café')[0].header == 'Café') and the README (field names, examples, Data Models section without MarkdownContent, a sentence on frozen models and model_copy).
  • CHANGELOG 0.3.0 "Breaking changes": entries for the renames, the removed MarkdownContent, the required metadata.id and the frozen models. The normalization entry now says anyascii(section.content).
  • Renamed test_header_level_counting and test_header_levels_up_to_six to test_level_counting and test_levels_up_to_six, because the issue's grep for header_level must print nothing.

Testing

  • uv run ruff check --no-fix .: All checks passed
  • uv run ruff format --check .: 9 files already formatted
  • uv run pytest -q: 99 passed, including the new test_metadata_requires_id (SectionMetadata(span=(0, 0)) raises ValidationError) and test_models_are_frozen (assigning section.content, section.metadata.id or an outline node's header raises ValidationError; model_copy(update={"content": "x"}) returns a changed copy)
  • doctest.testmod on markdown_chunkify.splitter: 13 attempted, 0 failed; on markdown_chunkify.models: 0 attempted, 0 failed
  • uv build and the CI wheel check in a fresh venv: passed
  • grep -rnE --exclude-dir=__pycache__ "section_header|section_text|header_level|MarkdownContent" markdown_chunkify tests README.md .github: no output

Section uses header, content and level like OutlineNode, and
MarkdownContent is merged into it. SectionMetadata.id is a required int.
Section, SectionMetadata and OutlineNode are frozen; model_copy(update=...)
returns a changed copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015guwcb2VbULqaendfa6d3k
@Gal-Gilor
Gal-Gilor force-pushed the refactor/section-fields branch from 9bf69d2 to b5fe741 Compare October 18, 2026 17:24
@Gal-Gilor
Gal-Gilor merged commit eec8733 into main Oct 18, 2026
5 checks passed
@Gal-Gilor
Gal-Gilor deleted the refactor/section-fields branch October 18, 2026 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants