Skip to content

fix: require name key in each toc.yaml entry#1965

Open
kings9527 wants to merge 1 commit into
diplodoc-platform:masterfrom
kings9527:master
Open

fix: require name key in each toc.yaml entry#1965
kings9527 wants to merge 1 commit into
diplodoc-platform:masterfrom
kings9527:master

Conversation

@kings9527
Copy link
Copy Markdown

Problem

Every table of contents item must have a human-readable name field. Currently, the loader silently accepts items without a name key, which leads to broken navigation or empty TOC labels at render time.

Fixes #1400

Changes

  • Schema: Added required: ['name'] to the TocItem definition in schemas/toc-schema.yaml.
  • Validation: Introduced checkTocItemNames() in src/core/toc/loader.ts that recursively validates every item (including nested ones) has a name key.
  • Error handling: Updated validateToc() to throw Error immediately when any item is missing name, failing the build with a clear message: Invalid toc structure in <path>: N toc item(s) missing required 'name' key.
  • Tests: Added two unit tests covering direct and nested missing-name scenarios.
  • Compatibility: Fixed all existing tests and watch-feature tests that had toc items without a name key so they comply with the new requirement.

Verification

All 1186 tests pass (52 test files).

Implements the lint rule from diplodoc-platform#1400 that requires every toc.yaml item
to have a required 'name' key.

Changes:
- Add checkTocItemNames() in src/core/toc/loader.ts to recursively
  validate that every toc item has a 'name' key.
- Update validateToc() to throw Error when any item is missing 'name',
  causing the build to fail fast with a clear error message.
- Add 'required: [name]' to TocItem schema in schemas/toc-schema.yaml.
- Add unit tests covering both direct and nested missing-name scenarios.
- Fix existing tests/watch tests that had toc items without 'name' keys
to comply with the new requirement.

Closes diplodoc-platform#1400
@kings9527 kings9527 requested a review from a team as a code owner May 31, 2026 05:17
@kings9527 kings9527 requested review from reazy015 and removed request for a team May 31, 2026 05:17
Copy link
Copy Markdown
Contributor

@reazy015 reazy015 left a comment

Choose a reason for hiding this comment

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

We've updated our infra package. Please rebase your fork to trigger the CI checks.

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.

Lint: Require name key in each toc.yaml entry

2 participants