A Node.js script to validate the Jito Omnidocs documentation structure according to project guidelines.
yarn installnode validate-docs-structure.jsnode validate-docs-structure.js --only-criticalnode validate-docs-structure.js --path /path/to/docs# Skip terminal directory checks
node validate-docs-structure.js --skip-terminal
# Skip parent directory checks
node validate-docs-structure.js --skip-parent
# Skip folder naming checks
node validate-docs-structure.js --skip-naming
# Skip sibling order checks
node validate-docs-structure.js --skip-order# Run all validations
yarn validate
# Run only critical validations
yarn validate:critical
# Test the validator
yarn testThe script validates four main aspects of the documentation structure:
- Rule: Terminal directories (those with no child directories containing
index.md) must have exactly oneindex.mdfile withsection_type: 'page' - Purpose: Ensures content pages are properly structured
- Example:
jitosol/faqs/general-faqs/should only containindex.mdwithsection_type: 'page'
- Rule: Parent directories (those with child directories containing
index.md) must have exactly oneindex.mdfile withsection_type: 'header'orsection_type: 'expandable' - Purpose: Ensures section organization is consistent
- Example:
jitosol/faqs/should haveindex.mdwithsection_type: 'header'orsection_type: 'expandable'
- Rule: No folder should end with the same name as its parent collection
- Purpose: Prevents Decap CMS navigation issues
- Bad:
jitosol/intro-to-jitosol/(ends with "jitosol") - Good:
jitosol/introduction/orjitosol/getting-started/
- Rule: Sibling directories should have different
ordernumbers in theirindex.mdfrontmatter - Purpose: Prevents navigation ordering conflicts
- Example: If
faqs/has childrengeneral-faqs/(order: 1) andtechnical-faqs/(order: 2), both must have different order values
- 0: All checks passed
- 1: One or more validation errors found
For GitHub Actions or other CI/CD systems, use the --only-critical flag to run only the most important checks:
# Example GitHub Action step
- name: Validate Documentation Structure
run: |
yarn install --frozen-lockfile
node validate-docs-structure.js --only-criticalThe script provides clear, actionable error messages:
🔍 Jito Documentation Structure Validator
==================================================
📁 Scanning documentation at: /path/to/docs
📚 Found collections: jitosol, governance, restaking, stakenet, tiprouter
🔍 Checking terminal directories...
🔍 Checking parent directories...
❌ ERRORS FOUND:
• Terminal directory jitosol/faqs/general-faqs should have section_type: 'page', found: 'header'
• Folder name violation: 'jitosol/intro-to-jitosol' ends with collection name 'jitosol'
Summary: 2 errors, 0 warnings
-
"Could not parse frontmatter": Ensure your
index.mdfiles start with valid YAML frontmatter:--- title: "Page Title" section_type: "page" order: 1 ---
-
Missing dependencies: Run
yarn installto install required packages -
Permission errors: Make sure the script has read permissions for all directories
To modify validation rules, edit the respective methods in validate-docs-structure.js:
checkTerminalDirectories()- Terminal directory validationcheckParentDirectories()- Parent directory validationcheckFolderNaming()- Folder naming validationcheckSiblingOrderNumbers()- Order number validation