|
| 1 | +# Documentation Development |
| 2 | + |
| 3 | +This guide covers how to work with and contribute to the Hayhooks documentation. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +- Python 3.9+ |
| 8 | +- Hatch installed (`pip install hatch`) |
| 9 | + |
| 10 | +## Building Documentation |
| 11 | + |
| 12 | +### Using Hatch (Recommended) |
| 13 | + |
| 14 | +The documentation can be built and served using Hatch commands: |
| 15 | + |
| 16 | +#### Development Server (Recommended) |
| 17 | + |
| 18 | +Start a local development server with live reloading using the dedicated docs environment: |
| 19 | + |
| 20 | +```bash |
| 21 | +# Using the dedicated docs environment (auto-installs all dependencies) |
| 22 | +hatch run docs:serve |
| 23 | + |
| 24 | +# With custom options |
| 25 | +hatch run docs:serve --open --dirty |
| 26 | +``` |
| 27 | + |
| 28 | +The server will be available at `http://localhost:8000/hayhooks/` |
| 29 | + |
| 30 | +#### Build Production Site |
| 31 | + |
| 32 | +Build the documentation for deployment: |
| 33 | + |
| 34 | +```bash |
| 35 | +# Using the docs environment (recommended) |
| 36 | +hatch run docs:build |
| 37 | + |
| 38 | +# Clean build (removes old files first) |
| 39 | +hatch run docs:build --clean |
| 40 | + |
| 41 | +# Strict build (fails on warnings) |
| 42 | +hatch run docs:build --strict |
| 43 | +``` |
| 44 | + |
| 45 | +The built site will be available in the `site/` directory. |
| 46 | + |
| 47 | +#### Deploy Documentation |
| 48 | + |
| 49 | +Deploy the documentation to GitHub Pages: |
| 50 | + |
| 51 | +```bash |
| 52 | +# Deploy to GitHub Pages |
| 53 | +hatch run docs:deploy |
| 54 | + |
| 55 | +# With custom options |
| 56 | +hatch run docs:deploy --force |
| 57 | +``` |
| 58 | + |
| 59 | +### Direct MkDocs Usage |
| 60 | + |
| 61 | +If you prefer to use MkDocs directly: |
| 62 | + |
| 63 | +```bash |
| 64 | +# Install dependencies |
| 65 | +pip install mkdocs-material |
| 66 | + |
| 67 | +# Serve documentation |
| 68 | +mkdocs serve |
| 69 | + |
| 70 | +# Build documentation |
| 71 | +mkdocs build |
| 72 | +``` |
| 73 | + |
| 74 | +## Documentation Structure |
| 75 | + |
| 76 | +```text |
| 77 | +docs/ |
| 78 | +├── mkdocs.yml # Main configuration |
| 79 | +├── index.md # Homepage |
| 80 | +├── getting-started/ # Getting started guides |
| 81 | +├── concepts/ # Core concepts |
| 82 | +├── features/ # Feature documentation |
| 83 | +├── advanced/ # Advanced topics |
| 84 | +├── deployment/ # Deployment guides |
| 85 | +├── examples/ # Example documentation |
| 86 | +├── reference/ # Reference documentation |
| 87 | +├── about/ # About information |
| 88 | +├── assets/ # Images and static assets |
| 89 | +├── stylesheets/ # Custom CSS |
| 90 | +└── javascripts/ # Custom JavaScript |
| 91 | +``` |
| 92 | + |
| 93 | +## Adding New Documentation |
| 94 | + |
| 95 | +### 1. Create New Files |
| 96 | + |
| 97 | +Add new Markdown files in the appropriate directory: |
| 98 | + |
| 99 | +```bash |
| 100 | +# Create a new feature document |
| 101 | +touch docs/features/new-feature.md |
| 102 | + |
| 103 | +# Create a new example |
| 104 | +touch docs/examples/new-example.md |
| 105 | +``` |
| 106 | + |
| 107 | +### 2. Update Navigation |
| 108 | + |
| 109 | +Update `mkdocs.yml` to include your new documentation in the navigation: |
| 110 | + |
| 111 | +```yaml |
| 112 | +nav: |
| 113 | + - Features: |
| 114 | + - New Feature: features/new-feature.md # Add this line |
| 115 | + - OpenAI Compatibility: features/openai-compatibility.md |
| 116 | + - MCP Support: features/mcp-support.md |
| 117 | +``` |
| 118 | +
|
| 119 | +### 3. Add Images |
| 120 | +
|
| 121 | +Place images in the `docs/assets/` directory: |
| 122 | + |
| 123 | +```bash |
| 124 | +# Add an image |
| 125 | +mv screenshot.png docs/assets/ |
| 126 | +
|
| 127 | +# Reference in Markdown |
| 128 | + |
| 129 | +``` |
| 130 | + |
| 131 | +## Documentation Style Guide |
| 132 | + |
| 133 | +### Writing Style |
| 134 | + |
| 135 | +- Use clear, concise language |
| 136 | +- Include practical examples |
| 137 | +- Provide step-by-step instructions |
| 138 | +- Use proper Markdown formatting |
| 139 | + |
| 140 | +### Avoiding Redundancy |
| 141 | + |
| 142 | +To maintain consistency and reduce maintenance burden: |
| 143 | + |
| 144 | +- **Single Source of Truth**: Each topic should have one canonical location |
| 145 | + - README.md: Quick overview and getting started examples |
| 146 | + - docs/concepts/: Detailed conceptual explanations |
| 147 | + - docs/reference/: Complete API and configuration references |
| 148 | + |
| 149 | +- **Cross-Referencing**: Link to the canonical source instead of duplicating content |
| 150 | + - Good: "For complete configuration options, see [Environment Variables Reference](../reference/environment-variables.md)" |
| 151 | + - Bad: Copying all environment variables into multiple pages |
| 152 | + |
| 153 | +- **Next Steps**: Keep to 2-3 most relevant links per page |
| 154 | + - Focus on logical next actions for the reader |
| 155 | + - Avoid circular references (page A → page B → page A) |
| 156 | + |
| 157 | +### Code Examples |
| 158 | + |
| 159 | +Use proper code block formatting: |
| 160 | + |
| 161 | +```python |
| 162 | +# Python code |
| 163 | +def example_function(): |
| 164 | + return "Hello, World!" |
| 165 | +``` |
| 166 | + |
| 167 | +```bash |
| 168 | +# Shell commands |
| 169 | +hatch run docs-serve |
| 170 | +``` |
| 171 | + |
| 172 | +### Links |
| 173 | + |
| 174 | +- **Internal Documentation**: Use relative links (e.g., `../concepts/pipeline-wrapper.md`) |
| 175 | +- **External Resources**: Use absolute links (e.g., `https://haystack.deepset.ai/`) |
| 176 | +- **README Links**: When linking from docs to README, use absolute GitHub URLs |
| 177 | +- **Test Links**: Always verify links work before committing |
| 178 | + |
| 179 | +## Testing Documentation |
| 180 | + |
| 181 | +### Build Verification |
| 182 | + |
| 183 | +Always test the documentation builds successfully: |
| 184 | + |
| 185 | +```bash |
| 186 | +hatch run docs:build --strict |
| 187 | +``` |
| 188 | + |
| 189 | +### Link Verification |
| 190 | + |
| 191 | +Check for broken links: |
| 192 | + |
| 193 | +```bash |
| 194 | +# Test locally |
| 195 | +hatch run docs:serve |
| 196 | +
|
| 197 | +# Or use a link checker tool |
| 198 | +pip install linkchecker |
| 199 | +linkchecker http://localhost:8000/hayhooks/ |
| 200 | +``` |
| 201 | + |
| 202 | +### Preview Changes |
| 203 | + |
| 204 | +Preview your changes in the browser: |
| 205 | + |
| 206 | +```bash |
| 207 | +hatch run docs:serve --open |
| 208 | +``` |
| 209 | + |
| 210 | +## Deployment |
| 211 | + |
| 212 | +### GitHub Pages |
| 213 | + |
| 214 | +> **Note:** Automatic deployment via GitHub Actions is not yet configured. For now, documentation must be deployed manually. A GitHub Actions workflow will be added in the future. |
| 215 | + |
| 216 | +### Manual Deployment |
| 217 | + |
| 218 | +To deploy manually: |
| 219 | + |
| 220 | +```bash |
| 221 | +# Deploy to GitHub Pages (builds and deploys in one command) |
| 222 | +hatch run docs:deploy |
| 223 | +
|
| 224 | +# Or build only without deploying |
| 225 | +hatch run docs:build |
| 226 | +# The site is now ready in the site/ directory |
| 227 | +``` |
| 228 | + |
| 229 | +## Troubleshooting |
| 230 | + |
| 231 | +### Common Issues |
| 232 | + |
| 233 | +1. **Build Fails** |
| 234 | + - Check for Markdown syntax errors |
| 235 | + - Verify all links are valid |
| 236 | + - Ensure image paths are correct |
| 237 | + |
| 238 | +2. **Navigation Issues** |
| 239 | + - Check `mkdocs.yml` syntax |
| 240 | + - Verify all referenced files exist |
| 241 | + - Test navigation structure |
| 242 | + |
| 243 | +3. **Style Issues** |
| 244 | + - Check CSS file paths |
| 245 | + - Verify JavaScript syntax |
| 246 | + - Test in multiple browsers |
| 247 | + |
| 248 | +### Getting Help |
| 249 | + |
| 250 | +- Check MkDocs documentation: <https://www.mkdocs.org/> |
| 251 | +- Review Material theme docs: <https://squidfunk.github.io/mkdocs-material/> |
| 252 | +- Open an issue on GitHub: <https://github.com/deepset-ai/hayhooks/issues> |
| 253 | + |
| 254 | +## Contributing |
| 255 | + |
| 256 | +1. Fork the repository |
| 257 | +2. Create a feature branch |
| 258 | +3. Make your documentation changes |
| 259 | +4. Test locally with `hatch run docs:serve` |
| 260 | +5. Submit a pull request |
| 261 | + |
| 262 | +Thank you for contributing to Hayhooks documentation! |
0 commit comments