Skip to content

Commit c441beb

Browse files
authored
Merge pull request #1 from sheldonj/feature/improve-skill-generation
feat: improve SVG diagram embedding and add release automation
2 parents 7fd999a + 3b4baab commit c441beb

13 files changed

Lines changed: 1001 additions & 285 deletions
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Release Please
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
release-please:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: googleapis/release-please-action@v4
16+
with:
17+
token: ${{ secrets.GITHUB_TOKEN }}

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "0.1.0"
3+
}

CONTRIBUTING.md

Lines changed: 67 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -310,23 +310,15 @@ pnpm test -- --update
310310

311311
### Prerequisites
312312

313-
From the repository root:
314-
315313
```bash
316314
pnpm install
317315
pnpm build
318316
```
319317

320-
The plugin package is at `packages/plugins/documentation/`.
321-
322318
### Build
323319

324320
```bash
325-
# Build this package only (run from packages/plugins/documentation/)
326321
pnpm build
327-
328-
# Build from repo root (builds all packages via Turbo)
329-
cd /path/to/zenstack && pnpm build
330322
```
331323

332324
The build uses `tsup-node` for bundling and `tsc --noEmit` for type checking.
@@ -346,22 +338,80 @@ This plugin was built with strict TDD. When adding features:
346338
pnpm lint
347339
```
348340

349-
Uses the shared `@zenstackhq/eslint-config`.
341+
Uses `eslint-config-canonical` with project-specific overrides defined in `eslint.config.js`.
350342

351343
### Preview output
352344

353-
To visually inspect what the plugin generates, point the output at a local directory:
345+
To visually inspect what the plugin generates:
354346

355347
```bash
356-
# In any project with a schema.zmodel:
357-
plugin documentation {
358-
provider = '../path/to/packages/plugins/documentation'
359-
output = './preview-output'
360-
}
361-
pnpm exec zenstack generate
348+
pnpm run build
349+
npx ts-node scripts/preview.ts
350+
```
351+
352+
Then browse the generated Markdown files in `preview-output/` or render them with your preferred viewer.
353+
354+
## Commit conventions
355+
356+
This project uses [Conventional Commits](https://www.conventionalcommits.org/) and [Release Please](https://github.com/googleapis/release-please) for automated versioning and changelog generation.
357+
358+
### Commit message format
359+
360+
```
361+
<type>[optional scope]: <description>
362+
363+
[optional body]
364+
365+
[optional footer(s)]
362366
```
363367

364-
Then browse the generated Markdown files or render them with your preferred viewer.
368+
### Types
369+
370+
| Type | Purpose | Version bump |
371+
|---|---|---|
372+
| `feat` | New feature or capability | minor (0.x → 0.x+1) |
373+
| `fix` | Bug fix | patch (0.x.y → 0.x.y+1) |
374+
| `perf` | Performance improvement | patch |
375+
| `docs` | Documentation only | none |
376+
| `test` | Adding or updating tests | none |
377+
| `refactor` | Code change that neither fixes a bug nor adds a feature | none |
378+
| `chore` | Maintenance tasks (deps, CI config) | none |
379+
| `ci` | CI/CD workflow changes | none |
380+
381+
### Breaking changes
382+
383+
Append `!` after the type to indicate a breaking change:
384+
385+
```
386+
feat!: rename diagramFormat option to svgMode
387+
```
388+
389+
Or include a `BREAKING CHANGE:` footer:
390+
391+
```
392+
feat: overhaul diagram rendering pipeline
393+
394+
BREAKING CHANGE: diagramFormat option renamed to svgMode
395+
```
396+
397+
Breaking changes bump the major version (or minor while pre-1.0).
398+
399+
### Examples
400+
401+
```
402+
feat: add diagramEmbed option for inline SVG embedding
403+
fix: use descriptive alt text in SVG image references
404+
docs: document responsive wrapper behavior
405+
refactor: extract wrapResponsive helper from processDiagrams
406+
test: add inline SVG embedding tests
407+
chore: update dev dependencies
408+
```
409+
410+
### How it works
411+
412+
1. You merge PRs to `main` using conventional commit messages
413+
2. Release Please reads the commit history and opens a "Release PR" with a version bump and auto-generated `CHANGELOG.md`
414+
3. Merging the Release PR creates a GitHub Release, which triggers the npm publish workflow
365415

366416
## Frequently touched files
367417

README.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ plugin documentation {
142142
generateErd = true
143143
erdTheme = 'github-light'
144144
diagramFormat = 'svg'
145+
diagramEmbed = 'inline'
145146
}
146147
```
147148

@@ -160,6 +161,7 @@ plugin documentation {
160161
| `erdFormat` | `"svg"`, `"mmd"`, or `"both"` | `"both"` | Which ERD output format(s) to produce |
161162
| `erdTheme` | `string` | default | [beautiful-mermaid](https://github.com/lukilabs/beautiful-mermaid) theme name for SVG rendering |
162163
| `diagramFormat` | `"mermaid"`, `"svg"`, or `"both"` | `"mermaid"` | How per-page Mermaid diagrams are rendered (see [Per-Page SVG Diagrams](#per-page-svg-diagrams)) |
164+
| `diagramEmbed` | `"file"` or `"inline"` | `"file"` | Whether SVGs are written as companion files or embedded directly in the markdown (see [Per-Page SVG Diagrams](#per-page-svg-diagrams)) |
163165

164166
## ERD SVG Export
165167

@@ -188,7 +190,7 @@ See all 15 themes rendered against the showcase schema in the [theme gallery](./
188190

189191
## Per-Page SVG Diagrams
190192

191-
By default, diagrams on model, view, enum, type, procedure, and relationship pages are rendered as inline Mermaid code blocks. Set `diagramFormat` to render them as SVG images instead:
193+
By default, diagrams on model, view, enum, type, procedure, relationship, and SKILL pages are rendered as inline Mermaid code blocks. Set `diagramFormat` to render them as SVG images instead:
192194

193195
```prisma
194196
plugin documentation {
@@ -199,13 +201,40 @@ plugin documentation {
199201
}
200202
```
201203

204+
### Diagram format
205+
202206
| Value | Behavior |
203207
|---|---|
204208
| `"mermaid"` | Inline ` ```mermaid ` code blocks (default, requires a Mermaid-capable viewer) |
205-
| `"svg"` | SVG content embedded directly in the markdown — works everywhere, including Notion, plain Markdown viewers, and GitHub |
206-
| `"both"` | Embedded SVG with the Mermaid source in a collapsible `<details>` block |
209+
| `"svg"` | Companion `.svg` files referenced via `![Entity diagram](./Entity-diagram.svg)` — works everywhere |
210+
| `"both"` | SVG image reference with the Mermaid source in a collapsible `<details>` block |
211+
212+
### Embed mode
213+
214+
Control whether SVGs are written as separate files or embedded directly in the markdown:
215+
216+
```prisma
217+
plugin documentation {
218+
provider = 'zenstack-docs-plugin'
219+
output = './docs/schema'
220+
diagramFormat = 'svg'
221+
diagramEmbed = 'inline'
222+
}
223+
```
224+
225+
| Value | Behavior |
226+
|---|---|
227+
| `"file"` | SVG written as companion files next to each `.md` page (default) |
228+
| `"inline"` | Raw `<svg>` XML embedded directly in the markdown — fully self-contained, no separate files |
229+
230+
The `diagramEmbed` option only takes effect when `diagramFormat` is `"svg"` or `"both"`.
231+
232+
### Additional features
233+
234+
- **Descriptive alt text** — image references use the entity name (e.g. `![User diagram]`) for accessibility and hover tooltips
235+
- **Responsive wrapper** — all SVG outputs (file references and inline) are wrapped in `<div style="max-width:100%;overflow-x:auto">` so large diagrams scroll horizontally instead of overflowing the page
207236

208-
When set to `"svg"` or `"both"`, the rendered SVG is embedded inline in each `.md` page — no separate files needed. The `erdTheme` option applies to all per-page SVGs as well as the standalone ERD.
237+
The `erdTheme` option applies to all per-page SVGs as well as the standalone ERD.
209238

210239
## Enriching Your Documentation
211240

eslint.config.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ export default tseslint.config(
3737
},
3838
},
3939
{
40-
ignores: ['dist/', 'preview-output/', 'zenstack/'],
40+
files: ['package.json'],
41+
rules: {
42+
// types must precede default in exports conditions for TypeScript resolution
43+
'jsonc/sort-keys': 'off',
44+
},
45+
},
46+
{
47+
ignores: [
48+
'dist/',
49+
'preview-output/',
50+
'zenstack/',
51+
'release-please-config.json',
52+
'.release-please-manifest.json',
53+
],
4154
},
4255
);

release-please-config.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"packages": {
4+
".": {
5+
"release-type": "node",
6+
"changelog-sections": [
7+
{ "type": "feat", "section": "Features" },
8+
{ "type": "fix", "section": "Bug Fixes" },
9+
{ "type": "perf", "section": "Performance" },
10+
{ "type": "docs", "section": "Documentation", "hidden": true },
11+
{ "type": "chore", "section": "Miscellaneous", "hidden": true },
12+
{ "type": "test", "section": "Tests", "hidden": true },
13+
{ "type": "ci", "section": "CI", "hidden": true },
14+
{ "type": "refactor", "section": "Refactoring", "hidden": true }
15+
]
16+
}
17+
}
18+
}

0 commit comments

Comments
 (0)