feat(webui-press): normalize duplicate folder/filename paths as index#361
Open
mohamedmansour wants to merge 2 commits into
Open
feat(webui-press): normalize duplicate folder/filename paths as index#361mohamedmansour wants to merge 2 commits into
mohamedmansour wants to merge 2 commits into
Conversation
Treat markdown files where the filename matches the parent folder name as index pages, avoiding redundant URL paths. Example: - Before: components/webui-button/webui-button.md → /webui-button/webui-button/ - After: components/webui-button/webui-button.md → /webui-button/ This enables cleaner component documentation URLs while preserving support for additional pages (e.g., webui-button/usage.md → /webui-button/usage). Changes: - Add normalize_path_as_index() helper to strip duplicate filenames - Update build_page_registry() to normalize paths before URL generation - Add comprehensive test coverage (6 test cases) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Treat markdown files where the filename matches the parent folder name as index pages, avoiding redundant URL paths in the generated documentation.
Problem
Currently, a file like
components/webui-button/webui-button.mdgenerates the URL/webui-button/webui-button/, which has an unnecessary duplicate segment.Solution
Added a
normalize_path_as_index()helper function that:Examples
webui-button/webui-button.md/webui-button/webui-button//webui-button/✅webui-button/usage.md/webui-button/usage//webui-button/usage/(unchanged)components/webui-card/webui-card.md/components/webui-card/webui-card//components/webui-card/✅Changes
normalize_path_as_index()- New helper function with clear documentationbuild_page_registry()- Updated to normalize paths before URL generationTesting
cargo test -p microsoft-webui-press normalize_path_as_indexAll tests pass ✅
Impact
folder/folder.mdpattern/index.mdor different filenames are unaffectedCo-authored-by: Copilot 223556219+Copilot@users.noreply.github.com