mirror of https://github.com/kyverno/website.git
3.2 KiB
3.2 KiB
Development Scripts
This directory contains development scripts and tools for generating content and maintaining the website.
Scripts Overview
render-policies.ts- TypeScript tool for generating policy documentation from GitHub repositoriescodegen-cli-docs.sh- Bash script for generating CLI documentation from Docker images
Policy Render Tool (render-policies.ts)
This TypeScript tool fetches Kyverno policies from a GitHub repository and generates markdown documentation files for the website.
Usage
Via npm script (recommended):
npm run codegen:policies
With custom arguments:
npm run codegen:policies -- <repo-url> <output-dir>
Example:
npm run codegen:policies -- https://github.com/kyverno/policies/main ./src/content/policies/
Direct execution:
tsx scripts/render-policies.ts https://github.com/kyverno/policies/main ./src/content/policies/
How it works
- Clones the specified GitHub repository (shallow clone, single branch)
- Recursively finds all YAML policy files (
.yamlor.yml) - Extracts metadata from policy annotations:
policies.kyverno.io/titlepolicies.kyverno.io/categorypolicies.kyverno.io/minversionpolicies.kyverno.io/subjectpolicies.kyverno.io/description
- Determines policy type (
validate,mutate, orgenerate) from the spec - Generates markdown files with frontmatter and full YAML content
- Preserves the directory structure from the source repository
Output Format
Each generated markdown file includes:
- Frontmatter with policy metadata (title, category, version, subject, policyType, description)
- A link to the raw YAML file on GitHub
- The complete policy YAML in a code block
Dependencies
js-yaml- YAML parsingsimple-git- Git operationstsx- TypeScript execution
Requirements
- Node.js v24 or higher
- Git (for cloning repositories)
CLI Documentation Generator (codegen-cli-docs.sh)
This bash script generates CLI documentation by running the kyverno-cli Docker container and extracting documentation.
Usage
Via npm script (recommended):
npm run codegen:cli-docs
Direct execution:
./scripts/codegen-cli-docs.sh
How it works
- Removes existing CLI documentation files from
src/content/docs/docs/kyverno-cli/reference/ - Runs the
ghcr.io/kyverno/kyverno-cliDocker container - Generates markdown documentation files with the following options:
--autogenTag=false- Disables auto-generated tags--website- Formats output for website--noDate- Omits dates from generated files--markdownLinks- Uses markdown link format
- Outputs files to
src/content/docs/docs/kyverno-cli/reference/
Requirements
- Docker installed and running
- Access to pull
ghcr.io/kyverno/kyverno-cliimage
Running All Code Generation
To regenerate all generated content:
npm run codegen:policies
npm run codegen:cli-docs
Or run both in sequence:
npm run codegen:policies && npm run codegen:cli-docs
See Also
For more information about code generation, see DEVELOPMENT.md.