|
| 1 | +# Helm Chart README Generator |
| 2 | + |
| 3 | +This directory contains the source code and automation script for generating the `README.md` files for our various Helm charts. The purpose of this tool is to solve the problem of keeping multiple, similar `README.md` files in sync. |
| 4 | + |
| 5 | +## How It Works |
| 6 | + |
| 7 | +The system is based on two key concepts: **Partials** and **Templates**. |
| 8 | + |
| 9 | +- **Partials (`_partials/`):** These are small, reusable Markdown files that contain a single, specific piece of documentation, like installation instructions or prerequisites. |
| 10 | +- **Templates (`templates/`):** These are the master "blueprint" files for each final `README.md`. They define the structure of the document and use a special directive, `@@include(...)`, to pull in the content from the partials. |
| 11 | + |
| 12 | +The `generate.py` script reads a template, finds all the `@@include` directives, replaces them with the content from the corresponding partial files, and writes the final, assembled `README.md` to the correct chart directory. |
| 13 | + |
| 14 | +### Directory Structure |
| 15 | + |
| 16 | +The project is organized by product to keep the source files separate and clean. |
| 17 | + |
| 18 | +``` |
| 19 | +_readme_gen/ |
| 20 | +├── README.md # This file |
| 21 | +├── generate.py # The master Python script |
| 22 | +│ |
| 23 | +├── flex/ # Source files for the "flex" product |
| 24 | +│ ├── _partials/ # Reusable Markdown snippets for flex |
| 25 | +│ │ └── _... .md |
| 26 | +│ └── templates/ # Master templates for each flex README |
| 27 | +│ └── flex.template.md |
| 28 | +│ |
| 29 | +└── kpow/ # Source files for the "kpow" product |
| 30 | + ├── _partials/ # Reusable Markdown snippets for kpow |
| 31 | + │ └── _... .md |
| 32 | + └── templates/ # Master templates for each kpow README |
| 33 | + └── kpow.template.md |
| 34 | +``` |
| 35 | + |
| 36 | +--- |
| 37 | + |
| 38 | +## Usage |
| 39 | + |
| 40 | +The script can be run from the command line to generate READMEs for a specific product or for all products at once. |
| 41 | + |
| 42 | +### Generating READMEs for a Specific Product |
| 43 | + |
| 44 | +Provide the product name (`kpow`, `flex`, etc.) as an argument to the script. This is useful for local development when you are only working on one product. |
| 45 | + |
| 46 | +**Syntax:** |
| 47 | + |
| 48 | +```bash |
| 49 | +python generate.py <product_name> |
| 50 | +``` |
| 51 | + |
| 52 | +**Examples:** |
| 53 | + |
| 54 | +```bash |
| 55 | +# Generate all READMEs for Kpow |
| 56 | +python generate.py kpow |
| 57 | + |
| 58 | +# Generate all READMEs for Flex |
| 59 | +python generate.py flex |
| 60 | +``` |
| 61 | + |
| 62 | +### Generating All READMEs |
| 63 | + |
| 64 | +Running the script without any arguments will default to generating the READMEs for **all** products defined in the configuration. This is the mode used by our CI/CD automation. |
| 65 | + |
| 66 | +**Examples:** |
| 67 | + |
| 68 | +```bash |
| 69 | +# Generate all READMEs for all products |
| 70 | +python generate.py |
| 71 | +``` |
| 72 | + |
| 73 | +Or explicitly: |
| 74 | + |
| 75 | +```bash |
| 76 | +python generate.py all |
| 77 | +``` |
| 78 | + |
| 79 | +### Getting Help |
| 80 | + |
| 81 | +To see the list of available products and options, use the `--help` flag. |
| 82 | + |
| 83 | +```bash |
| 84 | +python generate.py --help |
| 85 | +``` |
| 86 | + |
| 87 | +--- |
| 88 | + |
| 89 | +## Adding a New Product |
| 90 | + |
| 91 | +To add a new product (e.g., "platform") to the generator, follow these steps: |
| 92 | + |
| 93 | +1. **Create the Directory Structure:** |
| 94 | + Create a new folder inside `_readme_gen/` with the product's name, and add `_partials` and `templates` subdirectories. |
| 95 | + |
| 96 | + ``` |
| 97 | + _readme_gen/ |
| 98 | + └── platform/ |
| 99 | + ├── _partials/ |
| 100 | + └── templates/ |
| 101 | + ``` |
| 102 | +
|
| 103 | +2. **Add Content:** |
| 104 | + Create your reusable `.md` files in `_partials/` and your master `platform.template.md` files in `templates/`. |
| 105 | +
|
| 106 | +3. **Update the Configuration:** |
| 107 | + Open `generate.py` and add a new top-level entry for `"platform"` inside the `README_CONFIG` dictionary. Follow the existing structure to define the template and output paths for each of your new chart's READMEs. |
| 108 | +
|
| 109 | + **Example addition to `README_CONFIG`:** |
| 110 | +
|
| 111 | + ```python |
| 112 | + "gizmo": [ |
| 113 | + { |
| 114 | + "template": BASE_DIR / "platform" / "templates/platform.template.md", |
| 115 | + "output": BASE_DIR / f"../{CHART_FOLDER}/gizmo/README.md", |
| 116 | + }, |
| 117 | + # ... more chart variations for platform |
| 118 | + ], |
| 119 | + ``` |
0 commit comments