Feature 534495: Documentation Generation (GH Pages)#38
Conversation
This reverts commit 477701d.
- Removed outdated navigation settings for schemas and features in the Jekyll configuration script. - Added explicit configuration for the features section, including navigation orders and parent-child relationships. - Cleaned up the script by removing unnecessary custom CSS creation steps, streamlining the documentation generation process.
- Modified schemas/index.md to include `nav_exclude: true` in the front matter, preventing it from appearing in the navigation structure.
- Replaced inline JavaScript for fixing links with a separate file for better maintainability. - Updated the create-jekyll-config.sh script to copy the link-fixer JavaScript instead of generating it inline. - Removed outdated link adjustments from fix-docs.sh to simplify the documentation processing. - Added `nav_exclude: true` to schemas/index.md and set `toc: false` in the schema reference for improved navigation control.
- Changed the title in both _config.yml and process-docs.sh from "DXT Documentation" to "DXT Docs" to maintain uniformity across documentation files.
Yeah agreed. A lot of the complexity for the schema links lie in how deeply nested they can be, but we can def look to simply later. |
- Created a new SCSS file for custom styling of the site title, enhancing the visual presentation on larger screens. - Updated the create-jekyll-config.sh script to include the new SCSS file in the documentation generation process.
.github/scripts/docs/fix-docs.sh
Outdated
| for location in "." "docs"; do | ||
| if [ -d "$location" ]; then | ||
| echo " Checking $location directory" | ||
| for file in "$location"/*.md "$location"/GETTING_STARTED.md "$location"/PLUGIN_OPTIONS.md "$location"/CONTRIBUTING.md; do |
There was a problem hiding this comment.
"$location"/GETTING_STARTED.md "$location"/PLUGIN_OPTIONS.md "$location"/CONTRIBUTING.md are redundant, no? already covered by the first pattern "$location"/*.md?
There was a problem hiding this comment.
Yh good spot, thats been removed
| # === Fix all .md links to match Jekyll's pretty permalinks AND add baseurl === | ||
| sed "${SED_INPLACE[@]}" -E 's|\[([^]]+)\]\(([^)]+)\.md(#[^)]+)?\)|\[\1\]\(/forms-engine-plugin/\2\3\)|g' "$file" | ||
| sed "${SED_INPLACE[@]}" -E 's|\[([^]]+)\]\(([^)]+)\.md\)|\[\1\]\(/forms-engine-plugin/\2\)|g' "$file" | ||
| # Fix plain / roots to include baseurl | ||
| sed "${SED_INPLACE[@]}" -E 's|\[([^]]+)\]\(\/([^)]+)\)|\[\1\]\(/forms-engine-plugin/\2\)|g' "$file" | ||
| # Fix relative links to be absolute with baseurl | ||
| sed "${SED_INPLACE[@]}" -E 's|\[([^]]+)\]\(\./([^)]+)\)|\[\1\]\(/forms-engine-plugin/\2\)|g' "$file" |
There was a problem hiding this comment.
can you put an example of what these do? as with all regex, they're hard to read 🙂
| # Fix common schema reference patterns | ||
| sed "${SED_INPLACE[@]}" -E 's/\[([^\]]+)\]\(([a-zA-Z0-9_-]+-schema[a-zA-Z0-9_-]*)(\.md)?\)/[\1](\2)/g' "$file" | ||
| sed "${SED_INPLACE[@]}" -E 's/\[([^\]]+)\]\(([a-zA-Z0-9_-]+-schema-[a-zA-Z0-9_-]*)(\.md)?\)/[\1](\2)/g' "$file" | ||
|
|
||
| # Handle properties references | ||
| sed "${SED_INPLACE[@]}" -E 's/\[([^\]]+)\]\(([a-zA-Z0-9_-]+-properties-[a-zA-Z0-9_-]*)(\.md)?\)/[\1](\2)/g' "$file" | ||
|
|
||
| # Fix references to validation schemas | ||
| sed "${SED_INPLACE[@]}" -E 's/\[([^\]]+)\]\((min|max)(-length|-schema|-future|-past)?(\.md)?\)/[\1](\2\3)/g' "$file" | ||
|
|
||
| # Handle other schema patterns | ||
| sed "${SED_INPLACE[@]}" -E 's/\[([^\]]+)\]\((search|sorting|query|list)-options-schema(-[a-zA-Z0-9_-]*)?(\.md)?\)/[\1](\2-options-schema\3)/g' "$file" | ||
| sed "${SED_INPLACE[@]}" -E 's/\[([^\]]+)\]\((page|form|component)-([a-zA-Z0-9_-]+)(-[a-zA-Z0-9_-]*)?(\.md)?\)/[\1](\2-\3\4)/g' "$file" | ||
|
|
||
| # Extra pass for nested property references | ||
| sed "${SED_INPLACE[@]}" -E 's/\[([^\]]+)\]\(([a-zA-Z0-9_-]+)-schema-properties-([a-zA-Z0-9_-]+)(-[a-zA-Z0-9_-]*)?(\.md)?\)/[\1](\2-schema-properties-\3\4)/g' "$file" |
There was a problem hiding this comment.
ditto to the above comment
| sed "${SED_INPLACE[@]}" -E 's|\[see our guidance on page events\]([^)]*)/PAGE_EVENTS\.md|\[see our guidance on page events\]\(\.\.\/configuration-based\/PAGE_EVENTS\)|g' "./features/code-based/PAGE_VIEWS.md" | ||
| fi | ||
|
|
||
| if [ -f "./features/configuration-based/PAGE_TEMPLATES.md" ]; then | ||
| echo " Fixing PAGE_TEMPLATES.md links" | ||
| sed "${SED_INPLACE[@]}" -E 's|\[see our guidance on page events\]([^)]*)/PAGE_EVENTS\.md|\[see our guidance on page events\]\(\.\.\/configuration-based\/PAGE_EVENTS\)|g' "./features/configuration-based/PAGE_TEMPLATES.md" |
There was a problem hiding this comment.
these will break fairly easily. Can you add a comment about what exactly is being fixed? we can come back to these as a follow-up,
There was a problem hiding this comment.
This can be removed as was before we started absolute links in the md files themselves.
| sed "${SED_INPLACE[@]}" -E 's|\[([^]]+)\]\(\.\./configuration-based/PAGE_EVENTS\.?m?d?\)|\[\1\]\(\/features\/configuration-based\/PAGE_EVENTS\)|g' "./features/code-based/PAGE_VIEWS.md" | ||
| sed "${SED_INPLACE[@]}" -E 's|\[([^]]+)\]\(PAGE_EVENTS\.?m?d?\)|\[\1\]\(\/features\/configuration-based\/PAGE_EVENTS\)|g' "./features/code-based/PAGE_VIEWS.md" |
There was a problem hiding this comment.
these will break fairly easily. Can you add a comment about what exactly is being fixed? we can come back to these as a follow-up.
There was a problem hiding this comment.
This can be removed as was before we started absolute links in the md files themselves.
| @@ -0,0 +1,282 @@ | |||
| #!/bin/bash | |||
| # process-docs.sh - Fixed to properly format front matter AND set correct navigation | |||
There was a problem hiding this comment.
Do we need this script if we just hardcode the front matter in the .md files directly?
There was a problem hiding this comment.
Yes and no. We're already producing front matter in the schema docs script, but in this script is fixes the schema property via the regex and handles the schema specific navigation. A large chunk has been removed as we're handling the links in the non-schema markdown files directly though.
There was a problem hiding this comment.
In a later ticket, we could prob look to simplify it.
…ove redundant file writing - Copied custom SCSS for site title styling from the script to a dedicated file, enhancing maintainability. - Updated the create-jekyll-config.sh script to reflect the new SCSS file structure. - Removed redundant file writing for README.md in the generate-schema-docs.js script to simplify the documentation generation process.
- Updated fix-docs.sh to process only markdown files in specified directories, simplifying the script. - Enhanced fix-schema-links.sh with detailed comments and additional regex patterns to standardize schema links and remove .md extensions. - Adjusted links in CUSTOM_SERVICES.md to use absolute paths for better navigation consistency.
- Updated regex patterns to exclude external links from base URL adjustments, ensuring that only internal links are modified. - Added comments for clarity on the changes made to link handling in the script.
- Modified links in CUSTOM_SERVICES.md, PAGE_EVENTS.md, and PAGE_TEMPLATES.md to use absolute paths for the forms-engine-plugin directory, improving navigation accuracy across the documentation.
- Updated fix-schema-links.sh to ensure schema links have the correct prefix, improving link accuracy. - Modified fix-links.js to handle schema links and other internal links more effectively, ensuring proper base URL application. - Adjusted PAGE_VIEWS.md to use the updated link format for consistency across documentation.
…orkflow triggers - Removed unnecessary blank line in fix-schema-links.sh for cleaner code. - Updated documentation-generation.yml to ensure it triggers on pushes to the main branch, enhancing workflow reliability.
- Changed the link to the GitHub workflows in CONTRIBUTING.md to an absolute URL, improving accessibility and clarity for contributors.
|


Ticket Link:
https://dev.azure.com/defragovuk/DEFRA-CDP/_workitems/edit/534495
Proposed change
This PR introduces:
Azure DevOps work item:
Type of change
Checklist
README.mdanddocs/*(where appropriate, e.g. new features).npm run test).npm run lint).npm run format).