|
| 1 | +# Contributing to wpdocs |
| 2 | + |
| 3 | +Thanks for your interest. This is a small project but contributions are welcome — bug reports, feature requests, and PRs. |
| 4 | + |
| 5 | +## Getting set up |
| 6 | + |
| 7 | +```bash |
| 8 | +git clone https://github.com/iwritec0de/wordpress-dev-docs.git |
| 9 | +cd wordpress-dev-docs |
| 10 | +pnpm install |
| 11 | +pnpm test |
| 12 | +``` |
| 13 | + |
| 14 | +Node 20 or 22 is required. The repo uses **pnpm** (pinned via `packageManager` in `package.json`). Enable it via Corepack (`corepack enable`) or install directly (`npm install -g pnpm`). |
| 15 | + |
| 16 | +## Development loop |
| 17 | + |
| 18 | +```bash |
| 19 | +# One-shot run — exits when the command finishes. |
| 20 | +pnpm run dev -- generate ./examples/example-plugin |
| 21 | + |
| 22 | +# Same, but against the theme fixture |
| 23 | +pnpm run dev -- generate ./examples/example-theme |
| 24 | + |
| 25 | +# Or the collection fixture |
| 26 | +pnpm run dev -- generate ./examples/example-plugin-suite |
| 27 | + |
| 28 | +# Watch mode — reruns on src/ changes. Useful for long-lived commands |
| 29 | +# like `preview` or `mcp` while iterating on the CLI code. |
| 30 | +pnpm run dev:watch -- preview ./examples/example-plugin |
| 31 | +``` |
| 32 | + |
| 33 | +Generated sites are self-contained and don't use pnpm — users run whichever package manager they prefer inside the output directory. `cd` into `<target>/docs-output/` and run `npm install && npm run dev` (or `pnpm install && pnpm run dev`) to serve it in a browser. |
| 34 | + |
| 35 | +## Running checks locally |
| 36 | + |
| 37 | +Before pushing a PR: |
| 38 | + |
| 39 | +```bash |
| 40 | +pnpm run typecheck |
| 41 | +pnpm run lint |
| 42 | +pnpm run format:check |
| 43 | +pnpm test |
| 44 | +pnpm run build |
| 45 | +``` |
| 46 | + |
| 47 | +CI runs the same five jobs on Node 20 and Node 22. |
| 48 | + |
| 49 | +## Branching |
| 50 | + |
| 51 | +- `main` is protected. All work lands on `develop` via PRs. |
| 52 | +- Feature branches: `feature/<short-description>` or `feature/<task-id>-<description>`. |
| 53 | +- Bugfixes: `bugfix/<short-description>`. |
| 54 | + |
| 55 | +## Repository layout |
| 56 | + |
| 57 | +``` |
| 58 | +src/ |
| 59 | + cli/ # Ink CLI app + commands (generate, init, validate, preview, mcp) |
| 60 | + parser/ # PHP, JS, CSS parsers + WordPress-specific extractors |
| 61 | + generator/ # Site scaffold + MCP reference builder |
| 62 | + config/ # Config schema (Zod) + loader |
| 63 | + overrides/ # User-supplied tip/code overrides loader + merge engine |
| 64 | + validator/ # Source validation rules |
| 65 | + mcp-server/ # MCP server runtime (HTTP) |
| 66 | + lib/ # Small shared helpers |
| 67 | +
|
| 68 | +packages/ |
| 69 | + site-template/ # Next.js 16 site template + 8 built-in skins |
| 70 | +
|
| 71 | +examples/ |
| 72 | + example-plugin/ # Single WordPress plugin fixture |
| 73 | + example-theme/ # WordPress block theme fixture |
| 74 | + example-plugin-suite/ # Plugin collection fixture |
| 75 | +``` |
| 76 | + |
| 77 | +## Adding a parser rule |
| 78 | + |
| 79 | +1. Add the extraction logic under `src/parser/<php|js|css>/` or `src/parser/wordpress/` for WP-specific patterns. |
| 80 | +2. Add a test alongside in `__tests__/`. |
| 81 | +3. If the output needs to surface in the generated site, update `src/generator/site/nav.ts` and the relevant page under `packages/site-template/template/app/`. |
| 82 | +4. If it needs to surface in the MCP reference, update `src/generator/mcp/` and the MCP server routes in `src/mcp-server/`. |
| 83 | + |
| 84 | +## Adding a skin |
| 85 | + |
| 86 | +1. Create `packages/site-template/skins/<name>.json` following the shape of `default.json`. |
| 87 | +2. Add the name to `BUILT_IN_SKINS` in `src/generator/site/tokens.ts`. |
| 88 | +3. Add tests under `src/generator/site/__tests__/tokens.test.ts` for any unusual token values. |
| 89 | + |
| 90 | +Skin tokens are validated against a Zod schema — `xl` radius and dark overrides are optional. |
| 91 | + |
| 92 | +## Tests |
| 93 | + |
| 94 | +Tests live next to their source in `__tests__/` directories, named `*.test.ts` or `*.test.tsx`. We use Vitest. Run a single file with `npx vitest run <path>`. |
| 95 | + |
| 96 | +## Commit messages |
| 97 | + |
| 98 | +Conventional-style prefixes are preferred but not required: `feat:`, `fix:`, `chore:`, `docs:`, `test:`, `refactor:`. Include scope when helpful: `feat(parser): …`, `fix(site-template): …`. |
| 99 | + |
| 100 | +## Filing issues |
| 101 | + |
| 102 | +- **Bugs:** include the command run, the expected vs actual output, and the plugin/theme structure (sanitized) that reproduces it. |
| 103 | +- **Features:** describe the use case first, not the implementation. |
| 104 | + |
| 105 | +## License |
| 106 | + |
| 107 | +By contributing you agree that your contributions will be licensed under the repository's [MIT license](LICENSE). |
0 commit comments