|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Repository Overview |
| 6 | + |
| 7 | +This is a **documentation aggregation repository** that combines documentation from multiple Infrahub-related projects into a single documentation website using Docusaurus. The content here is mostly read-only and automatically synced from source repositories. |
| 8 | + |
| 9 | +**Important**: Most documentation changes should be made in the source repositories, not here: |
| 10 | + |
| 11 | +- Core Infrahub docs: `opsmill/infrahub` |
| 12 | +- Python SDK docs: `opsmill/infrahub-sdk-python` |
| 13 | +- Ansible collection docs: `opsmill/infrahub-ansible` |
| 14 | +- Service catalog docs: `opsmill/infrahub-demo-service-catalog` |
| 15 | +- Nornir integration docs: `opsmill/nornir-infrahub` |
| 16 | +- Schema library docs: `opsmill/schema-library` |
| 17 | +- Infrahub Sync docs: `opsmill/infrahub-sync` |
| 18 | +- Emma docs: `opsmill/emma` |
| 19 | + |
| 20 | +## Development Commands |
| 21 | + |
| 22 | +Run all commands from the `docs/` directory: |
| 23 | + |
| 24 | +```bash |
| 25 | +cd docs |
| 26 | +``` |
| 27 | + |
| 28 | +### Setup |
| 29 | + |
| 30 | +```bash |
| 31 | +npm install |
| 32 | +``` |
| 33 | + |
| 34 | +### Development |
| 35 | + |
| 36 | +```bash |
| 37 | +npm start # Start local development server with hot reload |
| 38 | +npm run build # Build static site for production |
| 39 | +npm run serve # Serve built site locally |
| 40 | +npm run typecheck # Run TypeScript type checking |
| 41 | +``` |
| 42 | + |
| 43 | +### Docusaurus Commands |
| 44 | + |
| 45 | +```bash |
| 46 | +npm run docusaurus -- <command> # Run any Docusaurus command |
| 47 | +npm run clear # Clear build cache |
| 48 | +``` |
| 49 | + |
| 50 | +### Linting and Quality Checks |
| 51 | + |
| 52 | +Run these commands from the repository root: |
| 53 | + |
| 54 | +```bash |
| 55 | +# Markdown linting (using repository config) |
| 56 | +markdownlint --config .markdownlint.yaml docs/**/*.mdx docs/**/*.md |
| 57 | + |
| 58 | +# Documentation style validation (requires Vale installation) |
| 59 | +vale --glob='!{docs/docs-schema-library/reference/*}' $(find ./docs -type f \( -name "*.mdx" -o -name "*.md" \) ) |
| 60 | + |
| 61 | +# Python linting (if applicable) |
| 62 | +ruff check . |
| 63 | +ruff format --check --diff |
| 64 | + |
| 65 | +# YAML linting (if applicable) |
| 66 | +yamllint -s . |
| 67 | +``` |
| 68 | + |
| 69 | +**Linting Configuration Files:** |
| 70 | +- `.markdownlint.yaml`: Markdown linting rules (disables line length, allows HTML, etc.) |
| 71 | +- `.vale.ini`: Documentation style rules and vocabulary |
| 72 | +- `.yamllint.yml`: YAML formatting and style rules |
| 73 | + |
| 74 | +## Architecture |
| 75 | + |
| 76 | +### Multi-Plugin Documentation Structure |
| 77 | + |
| 78 | +This site uses multiple Docusaurus plugin instances to combine documentation from different sources: |
| 79 | + |
| 80 | +- **Main docs** (`docs/`): Core Infrahub documentation at root path `/` |
| 81 | +- **Python SDK** (`docs-python-sdk/python-sdk/`): Python SDK docs at `/python-sdk` |
| 82 | +- **Infrahubctl** (`docs-python-sdk/infrahubctl/`): CLI tool docs at `/infrahubctl` |
| 83 | +- **Integrations**: Ansible (`/ansible`), Sync (`/sync`), Nornir (`/nornir`) |
| 84 | +- **Demos**: DC Fabric (`/demo`), Service Catalog (`/demo-service-catalog`) |
| 85 | +- **Schema Library** (`/schema-library`): Reusable schema documentation |
| 86 | +- **Emma** (`/emma`): AI Assistant documentation |
| 87 | + |
| 88 | +### Configuration Files |
| 89 | + |
| 90 | +- `docusaurus.config.ts`: Main Docusaurus configuration with all plugin definitions |
| 91 | +- `sidebars-*.ts`: Individual sidebar configurations for each documentation section |
| 92 | +- `globalVars.js`: Global variables used across documentation |
| 93 | +- `package.json`: Dependencies and npm scripts |
| 94 | + |
| 95 | +### Content Organization |
| 96 | + |
| 97 | +- Each documentation section has its own `docs-<name>/` directory |
| 98 | +- Sidebar configuration is managed separately for each section |
| 99 | +- Cross-references between sections use absolute paths |
| 100 | +- Media files are stored in section-specific directories |
| 101 | + |
| 102 | +### Key Features |
| 103 | + |
| 104 | +- **Multi-section navigation**: Dropdown menus organize different documentation types |
| 105 | +- **Search integration**: Local search across all documentation sections |
| 106 | +- **Redirects**: Handles URL changes from previous documentation structure |
| 107 | +- **Variable substitution**: Global variables can be used in Markdown content |
| 108 | +- **Analytics**: Plausible analytics integration when `ANALYTICS` env var is set |
| 109 | + |
| 110 | +## Working with Documentation |
| 111 | + |
| 112 | +### Adding New Documentation Sections |
| 113 | + |
| 114 | +1. Create new `docs-<name>/` directory |
| 115 | +2. Add plugin configuration to `docusaurus.config.ts` |
| 116 | +3. Create corresponding `sidebars-<name>.ts` file |
| 117 | +4. Add navigation entry to navbar configuration |
| 118 | + |
| 119 | +### Local Development |
| 120 | + |
| 121 | +- Use `npm start` for live development with hot reload |
| 122 | +- The site runs on `http://localhost:3000` by default |
| 123 | +- Changes to most files trigger automatic browser refresh |
| 124 | +- Configuration changes require server restart |
| 125 | + |
| 126 | +### Content Synchronization |
| 127 | + |
| 128 | +Documentation content is automatically synced from source repositories. Manual changes to synced content will be overwritten during the next sync cycle. |
| 129 | + |
| 130 | +### Documentation Writing Guidelines |
| 131 | + |
| 132 | +**Applies to:** All MDX files (`**/*.mdx`) |
| 133 | + |
| 134 | +**Role:** Expert Technical Writer and MDX Generator with: |
| 135 | + |
| 136 | +- Deep understanding of Infrahub and its capabilities |
| 137 | +- Expertise in network automation and infrastructure management |
| 138 | +- Proficiency in writing structured MDX documents |
| 139 | +- Awareness of developer ergonomics |
| 140 | + |
| 141 | +**Documentation Purpose:** |
| 142 | + |
| 143 | +- Guide users through installing, configuring, and using Infrahub in real-world workflows |
| 144 | +- Explain concepts and system architecture clearly, including new paradigms introduced by Infrahub |
| 145 | +- Support troubleshooting and advanced use cases with actionable, well-organized content |
| 146 | +- Enable adoption by offering approachable examples and hands-on guides that lower the learning curve |
| 147 | + |
| 148 | +**Structure:** Follows [Diataxis framework](https://diataxis.fr/) |
| 149 | + |
| 150 | +- **Tutorials** (learning-oriented) |
| 151 | +- **How-to guides** (task-oriented) |
| 152 | +- **Explanation** (understanding-oriented) |
| 153 | +- **Reference** (information-oriented) |
| 154 | + |
| 155 | +**Tone and Style:** |
| 156 | + |
| 157 | +- Professional but approachable: Avoid jargon unless well defined. Use plain language with technical precision |
| 158 | +- Concise and direct: Prefer short, active sentences. Reduce fluff |
| 159 | +- Informative over promotional: Focus on explaining how and why, not on marketing |
| 160 | +- Consistent and structured: Follow a predictable pattern across sections and documents |
| 161 | + |
| 162 | +**For Guides:** |
| 163 | + |
| 164 | +- Use conditional imperatives: "If you want X, do Y. To achieve W, do Z." |
| 165 | +- Focus on practical tasks and problems, not the tools themselves |
| 166 | +- Address the user directly using imperative verbs: "Configure...", "Create...", "Deploy..." |
| 167 | +- Maintain focus on the specific goal without digressing into explanations |
| 168 | +- Use clear titles that state exactly what the guide shows how to accomplish |
| 169 | + |
| 170 | +**For Topics:** |
| 171 | + |
| 172 | +- Use a more discursive, reflective tone that invites understanding |
| 173 | +- Include context, background, and rationale behind design decisions |
| 174 | +- Make connections between concepts and to users' existing knowledge |
| 175 | +- Present alternative perspectives and approaches where appropriate |
| 176 | +- Use illustrative analogies and examples to deepen understanding |
| 177 | + |
| 178 | +**Terminology and Naming:** |
| 179 | + |
| 180 | +- Always define new terms when first used. Use callouts or glossary links if possible |
| 181 | +- Prefer domain-relevant language that reflects the user's perspective (e.g., playbooks, branches, schemas, commits) |
| 182 | +- Be consistent: follow naming conventions established by Infrahub's data model and UI |
| 183 | + |
| 184 | +**Reference Files:** |
| 185 | + |
| 186 | +- Documentation guidelines: `docs/docs/development/docs.mdx` |
| 187 | +- Vale styles: `.vale/styles/` |
| 188 | +- Markdown linting: `.markdownlint.yaml` |
| 189 | + |
| 190 | +### Document Structure Patterns (Following Diataxis) |
| 191 | + |
| 192 | +**How-to Guides Structure (Task-oriented, practical steps):** |
| 193 | + |
| 194 | +```markdown |
| 195 | +- Title and Metadata |
| 196 | + - Title should clearly state what problem is being solved (YAML frontmatter) |
| 197 | + - Begin with "How to..." to signal the guide's purpose |
| 198 | + - Optional: Imports for components (e.g., Tabs, TabItem, CodeBlock, VideoPlayer) |
| 199 | +- Introduction |
| 200 | + - Brief statement of the specific problem or goal this guide addresses |
| 201 | + - Context or real-world use case that frames the guide |
| 202 | + - Clearly indicate what the user will achieve by following this guide |
| 203 | + - Optional: Links to related topics or more detailed documentation |
| 204 | +- Prerequisites / Assumptions |
| 205 | + - What the user should have or know before starting |
| 206 | + - Environment setup or requirements |
| 207 | + - What prior knowledge is assumed |
| 208 | +- Step-by-Step Instructions |
| 209 | + - Step 1: [Action/Goal] |
| 210 | + - Clear, actionable instructions focused on the task |
| 211 | + - Code snippets (YAML, GraphQL, shell commands, etc.) |
| 212 | + - Screenshots or images for visual guidance |
| 213 | + - Tabs for alternative methods (e.g., Web UI, GraphQL, Shell/cURL) |
| 214 | + - Notes, tips, or warnings as callouts |
| 215 | + - Step 2: [Action/Goal] |
| 216 | + - Repeat structure as above for each step |
| 217 | + - Step N: [Action/Goal] |
| 218 | + - Continue as needed |
| 219 | +- Validation / Verification |
| 220 | + - How to check that the solution worked as expected |
| 221 | + - Example outputs or screenshots |
| 222 | + - Potential failure points and how to address them |
| 223 | +- Advanced Usage / Variations |
| 224 | + - Optional: Alternative approaches for different circumstances |
| 225 | + - Optional: How to adapt the solution for related problems |
| 226 | + - Optional: Ways to extend or optimize the solution |
| 227 | +- Related Resources |
| 228 | + - Links to related guides, reference materials, or explanation topics |
| 229 | + - Optional: Embedded videos or labs for further learning |
| 230 | +``` |
| 231 | + |
| 232 | +**Topics Structure (Understanding-oriented, theoretical knowledge):** |
| 233 | + |
| 234 | +```markdown |
| 235 | +- Title and Metadata |
| 236 | + - Title should clearly indicate the topic being explained (YAML frontmatter) |
| 237 | + - Consider using "About..." or "Understanding..." in the title |
| 238 | + - Optional: Imports for components (e.g., Tabs, TabItem, CodeBlock, VideoPlayer) |
| 239 | +- Introduction |
| 240 | + - Brief overview of what this explanation covers |
| 241 | + - Why this topic matters in the context of Infrahub |
| 242 | + - Questions this explanation will answer |
| 243 | +- Main Content Sections |
| 244 | + - Concepts & Definitions |
| 245 | + - Clear explanations of key terms and concepts |
| 246 | + - How these concepts fit into the broader system |
| 247 | + - Background & Context |
| 248 | + - Historical context or evolution of the concept/feature |
| 249 | + - Design decisions and rationale behind implementations |
| 250 | + - Technical constraints or considerations |
| 251 | + - Architecture & Design (if applicable) |
| 252 | + - Diagrams, images, or explanations of structure |
| 253 | + - How components interact or relate to each other |
| 254 | + - Mental Models |
| 255 | + - Analogies and comparisons to help understanding |
| 256 | + - Different ways to think about the topic |
| 257 | + - Connection to Other Concepts |
| 258 | + - How this topic relates to other parts of Infrahub |
| 259 | + - Integration points and relationships |
| 260 | + - Alternative Approaches |
| 261 | + - Different perspectives or methodologies |
| 262 | + - Pros and cons of different approaches |
| 263 | +- Further Reading |
| 264 | + - Links to related topics, guides, or reference materials |
| 265 | + - External resources for deeper understanding |
| 266 | +``` |
| 267 | + |
| 268 | +### Quality and Clarity Checklist |
| 269 | + |
| 270 | +**General Documentation:** |
| 271 | + |
| 272 | +- Content is accurate and reflects the latest version of Infrahub |
| 273 | +- Instructions are clear, with step-by-step guidance where needed |
| 274 | +- Markdown formatting is correct and compliant with Infrahub's style |
| 275 | +- Spelling and grammar are checked |
| 276 | + |
| 277 | +**For Guides:** |
| 278 | + |
| 279 | +- The guide addresses a specific, practical problem or task |
| 280 | +- The title clearly indicates what will be accomplished |
| 281 | +- Steps follow a logical sequence that maintains flow |
| 282 | +- Each step focuses on actions, not explanations |
| 283 | +- The guide omits unnecessary details that don't serve the goal |
| 284 | +- Validation steps help users confirm their success |
| 285 | +- The guide addresses real-world complexity rather than oversimplified scenarios |
| 286 | + |
| 287 | +**For Topics:** |
| 288 | + |
| 289 | +- The explanation is bounded to a specific topic area |
| 290 | +- Content provides genuine understanding, not just facts |
| 291 | +- Background and context are included to deepen understanding |
| 292 | +- Connections are made to related concepts and the bigger picture |
| 293 | +- Different perspectives or approaches are acknowledged where relevant |
| 294 | +- The content remains focused on explanation without drifting into tutorial or reference material |
| 295 | +- The explanation answers "why" questions, not just "what" or "how" |
0 commit comments