|
| 1 | +# mugdoc |
| 2 | + |
| 3 | +Generate a documentation site from your project's README using Astro and Starlight. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +<img height="50" src="assets/star.svg" alt="if you liked it, give it a star" /> |
| 8 | + |
| 9 | +--- |
| 10 | + |
| 11 | +## How it works |
| 12 | + |
| 13 | +Clone this repo into your project, run `setup.sh`, and get a static documentation site. The setup script detects your project name and description, converts your README into the site content, copies referenced images, installs dependencies, and removes itself. |
| 14 | + |
| 15 | +The generated site is a single page with your README content, no sidebar, and a table of contents on the right. |
| 16 | + |
| 17 | +## Usage |
| 18 | + |
| 19 | +```bash |
| 20 | +git clone --depth 1 git@github.com:skvggor/mugdoc.git docs && rm -rf docs/.git && ./docs/setup.sh |
| 21 | +``` |
| 22 | + |
| 23 | +### Options |
| 24 | + |
| 25 | +| Flag | Description | Required | |
| 26 | +|---|---|---| |
| 27 | +| `--domain` | Base domain for the site URL | Yes | |
| 28 | +| `--deploy` | Absolute path on the server to deploy via SSH | No | |
| 29 | +| `--port` | Container port for the docs site (requires --deploy) | No | |
| 30 | + |
| 31 | +### Examples |
| 32 | + |
| 33 | +With a custom domain: |
| 34 | + |
| 35 | +```bash |
| 36 | +./docs/setup.sh --domain example.com |
| 37 | +``` |
| 38 | + |
| 39 | +Deploy to a VPS: |
| 40 | + |
| 41 | +```bash |
| 42 | +./docs/setup.sh --domain example.com --deploy /root/projects/my-project |
| 43 | +``` |
| 44 | + |
| 45 | +Deploy with custom port: |
| 46 | + |
| 47 | +```bash |
| 48 | +./docs/setup.sh --domain example.com --deploy /root/projects/my-project --port 3001 |
| 49 | +``` |
| 50 | + |
| 51 | +After setup: |
| 52 | + |
| 53 | +```bash |
| 54 | +cd docs && npm run dev # development server |
| 55 | +cd docs && npm run build # build static site |
| 56 | +cd docs && npm run preview # preview build |
| 57 | +``` |
| 58 | + |
| 59 | +## Project detection |
| 60 | + |
| 61 | +The setup script detects your project name from (in order): |
| 62 | + |
| 63 | +| File | Field | |
| 64 | +|---|---| |
| 65 | +| `package.json` | `name` | |
| 66 | +| `Cargo.toml` | `[package] name` | |
| 67 | +| `go.mod` | `module` | |
| 68 | +| `pyproject.toml` | `[project] name` | |
| 69 | + |
| 70 | +Falls back to the parent directory name. |
| 71 | + |
| 72 | +Description is extracted from the first text line in the README (skipping headings, HTML tags, links, and code blocks), then from `package.json` description, then a generic fallback. |
| 73 | + |
| 74 | +## Images |
| 75 | + |
| 76 | +Local images referenced in the README (both markdown and HTML `<img>` syntax) are automatically copied to the site's public directory and their paths are rewritten. External URLs are left unchanged. |
| 77 | + |
| 78 | +If the project has an `assets/` directory at the root, its contents are also copied. |
| 79 | + |
| 80 | +## Deploy |
| 81 | + |
| 82 | +The `--deploy` flag generates everything needed to deploy the docs site to a VPS using Docker, Caddy, and GitHub Actions. |
| 83 | + |
| 84 | +This creates: |
| 85 | + |
| 86 | +- `docs/Dockerfile` -- multi-stage build: Node builds the Astro site, Caddy serves the static files |
| 87 | +- `docs/compose.yml` -- Docker Compose service with [caddy-docker-proxy](https://github.com/lucaslorentz/caddy-docker-proxy) labels for automatic HTTPS |
| 88 | +- `.github/workflows/deploy-docs.yml` -- GitHub Actions workflow that deploys via SSH on push to `main` |
| 89 | + |
| 90 | +The site URL is `https://{project-name}.{domain}`. |
| 91 | + |
| 92 | +The workflow uses [appleboy/ssh-action](https://github.com/appleboy/ssh-action) and requires these repository secrets: |
| 93 | + |
| 94 | +| Secret | Description | |
| 95 | +|---|---| |
| 96 | +| `HOST` | Server IP or hostname | |
| 97 | +| `USERNAME` | SSH user | |
| 98 | +| `SSH_PRIVATE_KEY` | Private key for authentication | |
| 99 | +| `PORT` | SSH port (optional, defaults to 22) | |
| 100 | + |
| 101 | +Without `--deploy`, the deploy files are removed and only the local development setup is kept. |
| 102 | + |
| 103 | +## Requirements |
| 104 | + |
| 105 | +- Node.js |
| 106 | +- npm, pnpm, or yarn |
| 107 | + |
| 108 | +## Stack |
| 109 | + |
| 110 | +- [Astro](https://astro.build) + [Starlight](https://starlight.astro.build) |
| 111 | +- [Tailwind CSS](https://tailwindcss.com) via `@astrojs/starlight-tailwind` |
| 112 | + |
| 113 | +## License |
| 114 | + |
| 115 | +[GNU General Public License v3.0](LICENSE) |
0 commit comments