Documentation requirements
This document lists all requirements tested in the pr-validation.yml GitHub workflow. These are the rules that documentation must follow to pass automated validation.
File location requirements
Allowed directories
- Documentation files:
docs/**/*.md - Assignment files:
assignments/**/*.md
Restriction
- Students (non-admin, non-write permission users) can only change files in
/docs/and/assignments/ - Changes to other directories require admin or write permissions
Violation Result: PR validation fails with error Help Link: https://github.com/UWC2-APIDOC/to-do-service-auto/wiki/File-Locations
Filename requirements
Character restrictions
Filenames must not contain:
- Whitespace characters
- Shell meta-characters:
* ? [ ] | & ; $`" ' < > ( ) - Backslashes:
\ - Colons:
:
Validation Tool: tools/test-filenames.py Checked via: CHANGED_FILES environment variable Violation Result: Error annotation, PR fails
Commit requirements
Commit count
- PR must contain exactly 1 commit
- No more, no less
Violation Result: Error with message showing actual count Help Link: https://github.com/UWC2-APIDOC/to-do-service-auto/wiki/Squashing-Commits
Merge commits
- PR must not contain any merge commits
- Use rebase instead
Violation Result: Error with message showing merge commit count Help Link: https://github.com/UWC2-APIDOC/to-do-service-auto/wiki/Avoiding-Merge-Commits
Branch status
- Warning, if PR branch isn’t up to date with base branch
- Recommendation to rebase
Violation Result: Warning annotation Help Link: https://github.com/UWC2-APIDOC/to-do-service-auto/wiki/Updating-Your-Branch
Markdown linting requirements
MarkdownLint rules
Configured in .github/config/.MarkdownLint.jsonc:
MD007: Unordered list indentation
- Required indent: 4 spaces
MD013: Line length
- No longer than 100 characters
MD036: Emphasis used instead of heading
- Disabled
MD049: Emphasis style
- Required style: underscore (
_italic_)
MD050: Strong style
- Required style: asterisk (
**bold**)
MD060: Link style
- Required style: compact
Validation Tool: DavidAnson/MarkdownLint-cli2-action@v21 Violation Result: Error annotations on specific lines
Vale requirements
Configured in .vale.ini:
Enabled style packages
- Vale (core rules)
- Google Developer Documentation Style Guide
- write-good (readability checks)
- Readability (readability metrics)
Specific settings
Ignored scopes
codeblockstt(teletype) elements
Skipped scopes
scripttagsstyletagspre(pre-formatted) blocksfigureelementstext.frontmatter(YAML front matter)
Alert level
- Minimum:
suggestion - Reports all suggestions, warnings, and errors
Enabled rules
Vale.terms: verifies project terminologyGoogle.*: All Google style guide ruleswrite-good.*: All rules except E-PrimeReadability.FleschKincaid: checks reading level (complexity)- Other readability metrics: NO
Disabled rules
write-good.E-Prime: Disabled (allows “to be” verbs)Readability.AutomatedReadability: DisabledReadability.ColemanLiau: DisabledReadability.FleschReadingEase: DisabledReadability.GunningFog: DisabledReadability.LIX: DisabledReadability.SMOG: Disabled
Custom vocabulary
- Location:
.github/valeStyles/projectTerms/ - Project-specific approved terms
Validation Tool: errata-ai/vale-action@v2.1.1 Version: 3.12.0 Violation Result: Error annotations on specific lines Cached: Yes (Vale binary cached for performance)
Front matter requirements
Presence
- All files in
/docs/directory must have YAML front matter - Front matter must be between
---delimiters at start of file - Front matter delimiters must start at the beginning of the line
- Front matter delimiters must be the only characters in the line
- Files with
<!-- front matter not required -->comment in the first 5 lines of the file:- If in
/docs/: An error, front matter is required - If in
/assignments/: a warning, front matter is recommended - If elsewhere: Silently skipped
- If in
Violation Result: Error, can’t test file
Required fields
As defined in .github/schemas/front-matter-schema.json:
layout: string, must bedefault,page, orpostdescription: string, 10-200 characterstopic_type: string, must bereference,tutorial,guide,concept, oroverview
Optional standard fields
Navigation and structure
parent: string, exact match to parent page titlehas_children: Boolean, indicates if page has child pageshas_toc: Boolean, indicates if page should show table of contentsnav_order: integer, minimum 1 (lower numbers appear first)
Content classification
tags: array of strings, unique valuescategories: array of strings, unique valuesai_relevance: string, must behigh,medium, orlowimportance: integer, 1-10
Documentation structure
prerequisites: array of strings (page titles or concepts)related_pages: array of strings (page titles)examples: array of strings (example names for AI indexing)
API-specific
api_endpoints: array of strings matching pattern^(GET|POST|PUT|PATCH|DELETE|OPTIONS|HEAD)? ?/.+version: string matching pattern^v[0-9]+\.[0-9]+(\.[0-9]+)?$last_updated: string, date format
Test configuration
Optional. Used when file contains testable API examples:
test:
test_apps: # Array of npm-installable test servers (optional)
- "json-server@0.17.4"
server_url: # URL where test server runs (optional)
"localhost:3000"
local_database: # Path to test database JSON file (optional)
"/api/to-do-db-source.json"
testable: # Array of testable examples (REQUIRED if test exists)
- "GET example / 200"
- "POST example / 201,204"
Test field rules
- If
testobject exists, the test configuration must have atestablearray test_appspattern:^[a-zA-Z0-9_-]+(@[0-9]+\.[0-9]+\.[0-9]+)?$server_urlpattern:^(https?://)?([a-zA-Z0-9.-]+|localhost)(:[0-9]+)?$local_databasepattern:^(/)?[a-zA-Z0-9/_.-]+\.json$testableitem pattern:^.+( / [0-9,]+)?$- Format: “example name” or “example name / 200,201”
- Default status code if omitted: 200
Validation Tool: tools/test-api-docs.py with JSON schema validation Violation Result: Error annotations with specific schema violation details
API documentation testing requirements
When tests run
- Only runs if files in
docs/orassignments/changed - Only runs if Markdown linting passed
- Only runs if file has valid front matter with
testconfiguration
Test discovery
- Check for
<!-- front matter not required -->comment (see Front Matter requirements) - Parse front matter
- Compare against schema
- Check for
testobject withtestablearray - Skip files without testable examples
Example format requirements
For each item in test.testable array, the Markdown must contain:
Request section
- Heading:
### {example_name} requestor#### {example_name} request- Example name can have words wrapped in backticks:
`GET` example - Case-insensitive heading match
- Example name can have words wrapped in backticks:
- Code block: `
bash ` or `sh ` - Must contain: curl command
- URL substitution:
{server_url}replaced withtest.server_urlvalue
Format Help: https://github.com/UWC2-APIDOC/to-do-service-auto/wiki/Example-Format
Response section
- Heading:
### {example_name} responseor#### {example_name} response- Same flexible matching as request section
- Code block: ` ```json `
- Must contain: valid JSON response body
- Used for: comparing actual API response with documented response
Format Help: https://github.com/UWC2-APIDOC/to-do-service-auto/wiki/Example-Format
Test execution
Database setup
- Test server: json-server@0.17.4 on port 3000
- Database reset: Before testing each file
- Source:
test.local_databasefrom file’s front matter - Default:
api/to-do-db-source.jsonif not specified - Format: JSON file with REST resources
Request execution
- Extract curl command from request section
- Add
-iflag if not present (to get headers) - Replace
{server_url}with actual server URL - Execute with 10-second timeout
- Parse HTTP status code from response headers
Response validation
- Check status code is in expected list
- Ensure response is valid JSON
- Compare response structure with documented response
- Report specific differences if mismatch
Comparison rules
- Type checking: actual and expected must have same type
- Objects:
- All expected keys must exist in actual
- Extra keys in actual generate warnings
- Arrays:
- Length must match
- Elements compared by index
- Primitives: Must match exactly
- Differences reported with JSON path
Test results
- Error if curl command not found or malformed
- Error if response section not found or malformed
- Error if status code doesn’t match expected
- Error if response isn’t valid JSON
- Error if response structure doesn’t match documentation
- Warning if example sections not formatted correctly
Validation Tool: tools/test-api-docs.py Violation Result: Error annotations with specific test failure details
Markdown survey
Not required, but provides these statistics:
Tracked metrics
- Number of files processed
- Heading count per file
- Code block count per file
- Linter exceptions (Vale and MarkdownLint)
Tool: tools/markdown-survey.py Output: Informational annotations (warnings)
Linter exception tracking
Documents use of linter exception comments:
Vale exceptions
Format: <!-- vale RuleName = NO -->
- Tracked and reported
- Not a validation error
MarkdownLint exceptions
Format: <!-- markdownlint-disable MD### -->
- Tracked and reported
- Not a validation error (but noted)
Tool: tools/list-linter-exceptions.py Output: Warning annotations showing location and rule
Validation stages and dependencies
Stage 0: discover changed files
- Identifies all changed Markdown files
- Separates docs from tools
- Flags unauthorized changes
Stage 1: Test tools
- Runs if any files in
tools/have changed - Runs pytest on
tools/tests/ - All other stages blocked if this fails
Stage 2: Lint and validate content
- Depends on:
Test Toolspassing - Runs if: Any Markdown files changed
- Sub-checks:
- Filename validation
- Linter exception listing
- Markdown survey
- MarkdownLint validation
- Vale validation
Stage 3: Test API documentation
- Depends on:
Lint and Validate Contenttest passing - Runs if: Files in
docs/orassignments/have changed - Tests API examples against test server
Stage 4: Check number of commits
- Depends on:
Lint and Validate Contentand theTest API Documentationpassing - Always runs as final check
- Sub-checks:
- Unauthorized file changes
- Feature branch status compared to original branch
- Commit count and merge commits
Failure Behavior: Fail-fast - if earlier stage fails, dependent stages don’t run
Tool locations
Python scripts
tools/test-filenames.py- Filename validationtools/list-linter-exceptions.py- Exception trackingtools/markdown-survey.py- Content statisticstools/test-api-docs.py- API example testingtools/doc_test_utils.py- Shared utilitiestools/schema_validator.py- Front matter schema validationtools/get-database-path.py- Extract database path from front matter
Configuration files
.github/config/.MarkdownLint.jsonc- MarkdownLint rules.vale.ini- Vale configuration.github/schemas/front-matter-schema.json- Front matter schema.github/valeStyles/- Custom Vale styles and vocabulary
GitHub actions
.github/workflows/pr-validation.yml- Main validation workflow
Exit codes and results
Success
- All checks pass
- OK to merge PR
Failure scenarios
- Tool tests fail - Fix tools before proceeding
- Filename invalid - Rename file to remove special characters
- Markdown lint errors - Fix formatting issues
- Vale errors - Fix writing style issues
- Schema validation fails - Fix front matter structure
- API tests fail - Fix example code or expected responses
- Unauthorized files - Remove changes to restricted directories
- Too many commits - Squash into single commit
- Merge commits - Rebase to remove merge commits
Help resources
- GitHub Wiki: https://github.com/UWC2-APIDOC/to-do-service-auto/wiki/
- Specific pages linked in error messages