Skip to content

Restrict docset.yml configs that define toc.yml sections to ONLY link to sub toc.yml files #767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 19, 2025

Conversation

Mpdreamz
Copy link
Member

@Mpdreamz Mpdreamz commented Mar 18, 2025

This introduces a restriction so that if a docset.yml file links to a toc.yml file it may ONLY link to toc.yml files.

This to ensure all folders can be homed by the assembler navigation.yml.

e.g elasticsearch's docset.yml defines:

toc:
  - toc: reference
  - toc: release-notes
  - toc: extend

and the navigation.yml injects them in various places using elasticsearch://reference

There is no valid home for any files that might be placed at the root e.g: elasticsearch://
this PR prevents people from adding such file and folder references.

This also introduces dev_docs configuration for documentation sets that never intend to publish through assembler like our docs-builder docs.

Enabling this relaxes this new toc only restriction.

cc @colleenmcginnis

@Copilot Copilot AI review requested due to automatic review settings March 18, 2025 19:32
@Mpdreamz Mpdreamz requested a review from a team as a code owner March 18, 2025 19:32
@Mpdreamz Mpdreamz self-assigned this Mar 18, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR restricts docset.yml configurations so that toc.yml sections only link to sub toc.yml files, except when in development mode.

  • Added a new "dev_docs" field in the docset configuration to denote development docs.
  • Updated configuration parsing in ConfigurationFile.cs to enforce that, in non-development mode, TOC entries only reference toc sections.
  • Introduced a new TocReference type (extending FolderReference) and modified TableOfContentsConfiguration.cs to return TocReference objects accordingly.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
docs/_docset.yml Adds a "dev_docs: true" flag along with explanatory comments.
src/Elastic.Markdown/IO/Configuration/ConfigurationFile.cs Introduces the DevelopmentDocs property and enforces stricter TOC linking rules depending on mode.
src/Elastic.Markdown/IO/Configuration/ITocItem.cs Adds a new TocReference record to represent TOC-only references.
src/Elastic.Markdown/IO/Configuration/TableOfContentsConfiguration.cs Changes the returned reference from FolderReference to TocReference for TOC sections.
Comments suppressed due to low confidence (2)

src/Elastic.Markdown/IO/Configuration/ConfigurationFile.cs:123

  • [nitpick] Consider clarifying the error message emitted on line 124 for consistency and user clarity, e.g., by capitalizing 'TOC' to 'TOC'.
if (!DevelopmentDocs && tocEntries.Length > 0 && children.Count != tocEntries.Length)

src/Elastic.Markdown/IO/Configuration/TableOfContentsConfiguration.cs:115

  • Ensure that changing the returned reference from FolderReference to TocReference does not break any downstream code assumptions, as this change alters the type contract for TOC referencing.
return [new TocReference(`${parentPath}`.TrimStart(Path.DirectorySeparatorChar), folderFound, inNav, toc.TableOfContents)];

@Mpdreamz Mpdreamz merged commit 7215a40 into main Mar 19, 2025
10 checks passed
@Mpdreamz Mpdreamz deleted the feature/strict-toc-check branch March 19, 2025 06:14
Mpdreamz added a commit that referenced this pull request Mar 19, 2025
… to sub toc.yml files (#767)

* Restrict docset.yml configs that define toc.yml sections to ONLY link to sub toc.yml files

* relax check for narrative docs too, plays by different rules

* dotnet format

* reference Project directly
Mpdreamz added a commit that referenced this pull request Mar 19, 2025
* Add global navigation and improve diagnostic handling

This commit introduces a GlobalNavigation feature, parsing the new `navigation.yml` file to handle global navigation references. It also replaces `BuildContext` with `DiagnosticsCollector` for diagnostics, ensuring clearer separation of concerns. Additionally, it includes new tests and updates project files for better testing and navigation handling.

* Use navigation.yml to control url path prefixes for resolving

* path_prefix is mandatory except for top level docs-content references

* stage commit

* stage commit

* File copy now in a decent place

* temporary home for in flux paths

* fix failing test

* remove not referenced test project

* Restrict docset.yml configs that define toc.yml sections to ONLY link to sub toc.yml files (#767)

* Restrict docset.yml configs that define toc.yml sections to ONLY link to sub toc.yml files

* relax check for narrative docs too, plays by different rules

* dotnet format

* reference Project directly

* Fix layout and horizontal scrollable tables (#772)

* Fix layout and horizontal scrollable tables

mend

* Use spacing var

* Add custom scrollbar

* tweaks

* Add table of contents scope management and refactor diagnostics (#774)

* Add table of contents scope management and refactor diagnostics

Introduced `ITableOfContentsScope` to manage scope boundaries, improving link validation and table of contents processing. Updated diagnostics to emit hints for images outside the ToC scope and refactored functions for better reusability. Adjusted related tests and internal structures accordingly.

* Add TODO to make this an error

* post merge build fixes

* good enough state

---------

Co-authored-by: Jan Calanog <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants