|
| 1 | +# Documentation Automation |
| 2 | + |
| 3 | +This document describes the automated documentation generation process for sequelize-guard. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +API documentation is automatically generated from TypeScript source code and updated after each npm release. |
| 8 | + |
| 9 | +## Process Flow |
| 10 | + |
| 11 | +``` |
| 12 | +1. Push tag (e.g., v6.0.1) |
| 13 | + ↓ |
| 14 | +2. Release workflow runs (.github/workflows/release.yml) |
| 15 | + - Runs tests |
| 16 | + - Builds package |
| 17 | + - Publishes to npm |
| 18 | + ↓ |
| 19 | +3. Update docs workflow triggers (.github/workflows/update-docs.yml) |
| 20 | + - Generates API docs from source |
| 21 | + - Creates PR with updated documentation |
| 22 | + ↓ |
| 23 | +4. Review and merge PR |
| 24 | + - Documentation site automatically updates |
| 25 | +``` |
| 26 | + |
| 27 | +## Files Involved |
| 28 | + |
| 29 | +### Scripts |
| 30 | + |
| 31 | +- **`scripts/generate-api-docs.mjs`** - Main script that generates API documentation |
| 32 | +- **`typedoc.json`** - TypeDoc configuration |
| 33 | + |
| 34 | +### Workflows |
| 35 | + |
| 36 | +- **`.github/workflows/release.yml`** - Handles npm publishing |
| 37 | +- **`.github/workflows/update-docs.yml`** - Handles documentation updates |
| 38 | + |
| 39 | +### Output |
| 40 | + |
| 41 | +- **`apps/sequelize-guard-docs/content/docs/api.mdx`** - Generated API documentation |
| 42 | + |
| 43 | +## Manual Usage |
| 44 | + |
| 45 | +### Generate API Documentation |
| 46 | + |
| 47 | +```bash |
| 48 | +# Install dependencies (if not already installed) |
| 49 | +yarn install |
| 50 | + |
| 51 | +# Generate API documentation |
| 52 | +yarn docs:generate |
| 53 | +``` |
| 54 | + |
| 55 | +This will: |
| 56 | + |
| 57 | +1. Run TypeDoc to extract API information from `packages/sequelize-guard/src/` |
| 58 | +2. Convert the output to MDX format |
| 59 | +3. Write to `apps/sequelize-guard-docs/content/docs/api.mdx` |
| 60 | + |
| 61 | +### Test Locally |
| 62 | + |
| 63 | +```bash |
| 64 | +# Generate docs |
| 65 | +yarn docs:generate |
| 66 | + |
| 67 | +# Check the changes |
| 68 | +git diff apps/sequelize-guard-docs/content/docs/api.mdx |
| 69 | + |
| 70 | +# If satisfied, commit |
| 71 | +git add apps/sequelize-guard-docs/content/docs/api.mdx |
| 72 | +git commit -m "docs: update API documentation" |
| 73 | +``` |
| 74 | + |
| 75 | +## Customization |
| 76 | + |
| 77 | +### Modify Output Format |
| 78 | + |
| 79 | +Edit `scripts/generate-api-docs.mjs`: |
| 80 | + |
| 81 | +```javascript |
| 82 | +function generateMDX(apiJson) { |
| 83 | + // Customize the MDX output here |
| 84 | + // Modify frontmatter, content structure, etc. |
| 85 | +} |
| 86 | +``` |
| 87 | + |
| 88 | +### Change TypeDoc Configuration |
| 89 | + |
| 90 | +Edit `typedoc.json`: |
| 91 | + |
| 92 | +```json |
| 93 | +{ |
| 94 | + "entryPoints": ["./packages/sequelize-guard/src/index.ts"], |
| 95 | + "excludePrivate": true |
| 96 | + // Add more options as needed |
| 97 | +} |
| 98 | +``` |
| 99 | + |
| 100 | +## Workflow Configuration |
| 101 | + |
| 102 | +### Update Docs Workflow |
| 103 | + |
| 104 | +The workflow is triggered automatically after a successful release, but can also be run manually: |
| 105 | + |
| 106 | +1. Go to **Actions** tab on GitHub |
| 107 | +2. Select **"Update API Documentation"** workflow |
| 108 | +3. Click **"Run workflow"** |
| 109 | + |
| 110 | +### Customize Workflow |
| 111 | + |
| 112 | +Edit `.github/workflows/update-docs.yml`: |
| 113 | + |
| 114 | +- Change the target branch (default: `dev-v6`) |
| 115 | +- Modify PR labels or assignees |
| 116 | +- Adjust commit messages |
| 117 | + |
| 118 | +## Dependencies |
| 119 | + |
| 120 | +The following packages are required (already in `package.json`): |
| 121 | + |
| 122 | +```json |
| 123 | +{ |
| 124 | + "devDependencies": { |
| 125 | + "typedoc": "^0.27.5", |
| 126 | + "typedoc-plugin-markdown": "^4.4.1" |
| 127 | + } |
| 128 | +} |
| 129 | +``` |
| 130 | + |
| 131 | +## Troubleshooting |
| 132 | + |
| 133 | +### Workflow Not Triggering |
| 134 | + |
| 135 | +**Problem:** Update docs workflow doesn't run after release |
| 136 | + |
| 137 | +**Solution:** |
| 138 | + |
| 139 | +- Check that release workflow completed successfully |
| 140 | +- Verify workflow permissions in repository settings |
| 141 | +- Manually trigger the workflow from Actions tab |
| 142 | + |
| 143 | +### Generated Documentation is Empty |
| 144 | + |
| 145 | +**Problem:** API documentation file is empty or incomplete |
| 146 | + |
| 147 | +**Solution:** |
| 148 | + |
| 149 | +- Check TypeDoc configuration in `typedoc.json` |
| 150 | +- Verify entry points are correct |
| 151 | +- Run `yarn docs:generate` locally to debug |
| 152 | + |
| 153 | +### PR Not Created |
| 154 | + |
| 155 | +**Problem:** Workflow runs but no PR is created |
| 156 | + |
| 157 | +**Solution:** |
| 158 | + |
| 159 | +- Check if there are actual changes in the API documentation |
| 160 | +- Verify GitHub token has correct permissions |
| 161 | +- Check workflow logs for errors |
| 162 | + |
| 163 | +## Best Practices |
| 164 | + |
| 165 | +1. **Review PRs Carefully** - Always review auto-generated PRs before merging |
| 166 | +2. **Keep Script Updated** - Update `generate-api-docs.mjs` as API evolves |
| 167 | +3. **Test Locally First** - Run `yarn docs:generate` locally before pushing changes |
| 168 | +4. **Version Documentation** - Consider adding version tags to generated docs |
| 169 | + |
| 170 | +## Future Improvements |
| 171 | + |
| 172 | +Potential enhancements to consider: |
| 173 | + |
| 174 | +- [ ] Add more detailed API examples in generated docs |
| 175 | +- [ ] Include parameter descriptions from JSDoc comments |
| 176 | +- [ ] Generate separate pages for each major class |
| 177 | +- [ ] Add interactive API playground |
| 178 | +- [ ] Version-specific documentation archives |
| 179 | + |
| 180 | +## Support |
| 181 | + |
| 182 | +For issues related to documentation automation: |
| 183 | + |
| 184 | +1. Check this document first |
| 185 | +2. Review workflow logs in GitHub Actions |
| 186 | +3. Open an issue with the `documentation` label |
| 187 | +4. Tag @pankajvaghela for assistance |
| 188 | + |
| 189 | +--- |
| 190 | + |
| 191 | +**Last Updated:** December 2025 |
| 192 | +**Maintainer:** Pankaj Vaghela |
0 commit comments