docugate 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +252 -251
- package/dist/api.js +12 -0
- package/dist/init.js +218 -51
- package/dist/rules.js +1 -1
- package/dist/tour-init.js +23 -1
- package/dist/tour-server.js +114 -5
- package/package.json +1 -1
- package/pill/dist/pill.js +926 -422
package/README.md
CHANGED
|
@@ -1,251 +1,252 @@
|
|
|
1
|
-
# docugate
|
|
2
|
-
|
|
3
|
-
DocuGate publishes documentation straight from the markdown in your GitHub repositories and shows a walkthrough pill on your running app so any developer can see what each element on screen is and where its data comes from.
|
|
4
|
-
|
|
5
|
-
```sh
|
|
6
|
-
npm i -g docugate
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Quick start
|
|
12
|
-
|
|
13
|
-
`cd` into your app's repository, then run:
|
|
14
|
-
|
|
15
|
-
```sh
|
|
16
|
-
docugate init
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
It walks you through four steps:
|
|
20
|
-
|
|
21
|
-
1. **Repository role.** Say whether this repository is the frontend, the backend, or both.
|
|
22
|
-
2. **Sign in and connect.** Sign in to DocuGate with GitHub and connect this repository to a space.
|
|
23
|
-
3. **IBM Bob writes the tour.** Bob reads the code and writes one `.docugate/tour/*.md` file for each screen it finds.
|
|
24
|
-
4. **The pill is added to your app.** The dev-only loader snippet is inserted into your HTML or layout file.
|
|
25
|
-
|
|
26
|
-
Once that is done:
|
|
27
|
-
|
|
28
|
-
```sh
|
|
29
|
-
docugate tour serve
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
Start your app in another terminal, open it in the browser, and the pill appears in the corner.
|
|
33
|
-
|
|
34
|
-
---
|
|
35
|
-
|
|
36
|
-
## Tours
|
|
37
|
-
|
|
38
|
-
A tour helps a developer who is new to a codebase see what each element on screen is and where its data comes from. For each screen there is one markdown file in `.docugate/tour/`. Each file has front matter with a `route` and a `title`, then one `##` section per stop.
|
|
39
|
-
|
|
40
|
-
**Example stop:**
|
|
41
|
-
|
|
42
|
-
```markdown
|
|
43
|
-
---
|
|
44
|
-
route: /invoices/:id
|
|
45
|
-
title: Invoice detail
|
|
46
|
-
---
|
|
47
|
-
|
|
48
|
-
## Total
|
|
49
|
-
target: [data-tour="invoice-total"]
|
|
50
|
-
data: GET /api/invoices/:id → total
|
|
51
|
-
code: frontend/src/screens/InvoiceDetail.tsx
|
|
52
|
-
source: backend/src/billing.ts
|
|
53
|
-
docs: https://example.com/docs/billing
|
|
54
|
-
|
|
55
|
-
The amount due: the subtotal plus tax, computed by `totals()` in the backend.
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
Fields:
|
|
59
|
-
|
|
60
|
-
| Field | Required | Meaning |
|
|
61
|
-
| --- | --- | --- |
|
|
62
|
-
| `target` | yes | CSS selector for the element. Prefer `[data-tour="…"]`. |
|
|
63
|
-
| `data` | no | Request and field: `METHOD /path → field`. |
|
|
64
|
-
| `code` | yes | File that renders the element, relative to the repository root. |
|
|
65
|
-
| `source` | no | File where the value is computed, when that is elsewhere. |
|
|
66
|
-
| `docs` | no | URL to relevant documentation. |
|
|
67
|
-
|
|
68
|
-
The prose paragraph after the fields explains what the element is and why its value is what it is.
|
|
69
|
-
|
|
70
|
-
Tour files are yours. `docugate tour init` never overwrites a file that already exists.
|
|
71
|
-
|
|
72
|
-
---
|
|
73
|
-
|
|
74
|
-
## The pill
|
|
75
|
-
|
|
76
|
-
When `docugate tour serve` is running, the pill appears in the corner of your app. It has two modes:
|
|
77
|
-
|
|
78
|
-
- **Walkthrough.** Steps through every stop on the current screen in order, highlighting each element and showing its tour card.
|
|
79
|
-
- **Inspector.** Hovering highlights an element; clicking it shows its stop: what it is and where its data comes from. An element with no stop yet offers **Add to tour**, a small form that saves the stop straight into the tour file, and tells you which `data-tour` attribute to add when the element has none.
|
|
80
|
-
|
|
81
|
-
The pill stays on every page while the server runs, including pages with no tour yet, so their first stop can be added from the browser. Edits to the tour files show up on the page as you save them.
|
|
82
|
-
|
|
83
|
-
`docugate tour install` adds the pill for you. It only loads when the app runs on `localhost` and the tour server answers, so it never shows in production.
|
|
84
|
-
|
|
85
|
-
---
|
|
86
|
-
|
|
87
|
-
## Keeping tours true
|
|
88
|
-
|
|
89
|
-
A tour is only useful while it is true, so `docugate check` verifies every claim in `.docugate/tour/` against the code. For each stop it warns when:
|
|
90
|
-
|
|
91
|
-
- the `code` file, or the `source` file, no longer exists;
|
|
92
|
-
- the `code` file, and the files it imports, no longer mention the endpoint in `data`;
|
|
93
|
-
- the `code` file no longer contains the `data-tour` value in `target` (a value passed through a prop counts);
|
|
94
|
-
- a required field is missing, or two stops on one screen point at the same element.
|
|
95
|
-
|
|
96
|
-
Rename `invoice-total` in a component and `check` tells you which stop went stale.
|
|
97
|
-
|
|
98
|
-
It checks your docs folder too:
|
|
99
|
-
|
|
100
|
-
- **Errors:** broken links between pages, links that leave the docs folder, two files that become the same URL, an unreadable `docugate.json`, an empty docs folder, or more than 300 pages.
|
|
101
|
-
- **Warnings:** pages with no `# Title`, front matter, `.mdx` files, no landing page, and `sidebar` entries that match nothing.
|
|
102
|
-
|
|
103
|
-
It exits with 1 when there are errors. Add `--strict` to fail on warnings too, which is how stale tour stops fail a build.
|
|
104
|
-
|
|
105
|
-
Use it in CI:
|
|
106
|
-
|
|
107
|
-
```yaml
|
|
108
|
-
# .github/workflows/docs.yml
|
|
109
|
-
name: Docs
|
|
110
|
-
on: [push, pull_request]
|
|
111
|
-
jobs:
|
|
112
|
-
check:
|
|
113
|
-
runs-on: ubuntu-latest
|
|
114
|
-
steps:
|
|
115
|
-
- uses: actions/checkout@v4
|
|
116
|
-
- uses: actions/setup-node@v4
|
|
117
|
-
with:
|
|
118
|
-
node-version: 22
|
|
119
|
-
- run: npx docugate@0.2 check --strict
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
Pin the version in CI, as above. Without a pin, the rules being enforced can change between two runs of the same workflow, which turns a green build red with nothing in the commit to explain it.
|
|
123
|
-
|
|
124
|
-
---
|
|
125
|
-
|
|
126
|
-
## Commands
|
|
127
|
-
|
|
128
|
-
| Command | Main flags | What it does |
|
|
129
|
-
| --- | --- | --- |
|
|
130
|
-
| `docugate init` | `--dir`, `--title`, `--role frontend\|backend\|both`, `--yes` | Set up this repository for DocuGate (interactive). |
|
|
131
|
-
| `docugate check` | `--dir`, `--strict` | Check docs and tour files the way DocuGate will read them. |
|
|
132
|
-
| `docugate openapi` | `--from`, `--out`, `--include`, `--exclude`, `--redact`, `--check` | Prepare an OpenAPI spec for the API reference. |
|
|
133
|
-
| `docugate login` | | Sign in to DocuGate with GitHub. |
|
|
134
|
-
| `docugate logout` | | Sign out and delete saved credentials. |
|
|
135
|
-
| `docugate whoami` | | Print the currently signed-in user. |
|
|
136
|
-
| `docugate tour init` | `--max-cost <n>`, `--team-id <id>` | Write the first tour with IBM Bob (uses Bob Shell). |
|
|
137
|
-
| `docugate tour serve` | `--port <n>` (default 4178) | Start the local server that serves tour data for the pill. |
|
|
138
|
-
| `docugate tour install` | `--port <n>`, `--remove` | Add (or remove) the pill loader from your app's HTML or layout. |
|
|
139
|
-
| `docugate tour export <file>` | | Write every tour screen to a single JSON file. |
|
|
140
|
-
|
|
141
|
-
Run every command from the root of your repository.
|
|
142
|
-
|
|
143
|
-
---
|
|
144
|
-
|
|
145
|
-
## Try it on the demo
|
|
146
|
-
|
|
147
|
-
Clone [docugate-demo](https://github.com/Docugate/docugate-demo), a small full-stack app with a pre-written tour:
|
|
148
|
-
|
|
149
|
-
```sh
|
|
150
|
-
git clone https://github.com/Docugate/docugate-demo
|
|
151
|
-
cd docugate-demo
|
|
152
|
-
|
|
153
|
-
# install dependencies and start the app
|
|
154
|
-
npm install
|
|
155
|
-
npm run dev
|
|
156
|
-
```
|
|
157
|
-
|
|
158
|
-
In a second terminal:
|
|
159
|
-
|
|
160
|
-
```sh
|
|
161
|
-
cd docugate-demo
|
|
162
|
-
docugate tour serve
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
Open the app in the browser. The pill appears in the bottom-right corner.
|
|
166
|
-
|
|
167
|
-
---
|
|
168
|
-
|
|
169
|
-
## Several repositories in one space
|
|
170
|
-
|
|
171
|
-
A space can merge docs from a frontend, a backend, and a mobile app into one set of pages. `docugate init` connects the repository it runs in to one of your spaces once you are signed in; you can also add repositories from a space's settings on [trydocugate.site](https://www.trydocugate.site/dashboard).
|
|
172
|
-
|
|
173
|
-
Run `init` and `check` in each repository that contributes docs, and answer the role question in each: the tour lives in the frontend, and its `source` lines can point into the backend. Every one gets its own `docugate.json`, naming its own docs folder. `check` reads the repository it is run in, which is why its 300-page limit is per repository rather than per space.
|
|
174
|
-
|
|
175
|
-
See [Merging repositories](https://www.trydocugate.site/docs/merging-repositories).
|
|
176
|
-
|
|
177
|
-
---
|
|
178
|
-
|
|
179
|
-
## `openapi`
|
|
180
|
-
|
|
181
|
-
Takes the OpenAPI 3 spec your backend already produces and writes the version you want published: only the public paths, without sensitive fields, with keys in a stable order so it reviews cleanly in a pull request.
|
|
182
|
-
|
|
183
|
-
```sh
|
|
184
|
-
docugate openapi --from http://localhost:3000/openapi.json \
|
|
185
|
-
--exclude "/internal/**" --redact passwordHash --out openapi.json
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
- `--from`: a `.json`, `.yaml` or `.yml` file, or a URL serving one.
|
|
189
|
-
- `--include` / `--exclude`: path globs; `*` matches within one segment and `**` matches across segments. Both can be repeated.
|
|
190
|
-
- `--redact`: a property name to remove from every schema and example. Can be repeated.
|
|
191
|
-
- `--check`: do not write anything; exit with 1 if the committed file is out of date. Useful in CI.
|
|
192
|
-
|
|
193
|
-
Instead of passing flags every time, set the same options in `docugate.json`:
|
|
194
|
-
|
|
195
|
-
```json
|
|
196
|
-
{
|
|
197
|
-
"docsDir": "docs",
|
|
198
|
-
"api": {
|
|
199
|
-
"generate": {
|
|
200
|
-
"from": "http://localhost:3000/openapi.json",
|
|
201
|
-
"output": "openapi.json",
|
|
202
|
-
"exclude": ["/internal/**"],
|
|
203
|
-
"redact": ["passwordHash"]
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
---
|
|
210
|
-
|
|
211
|
-
## `docugate.json`
|
|
212
|
-
|
|
213
|
-
One per repository, at its root.
|
|
214
|
-
|
|
215
|
-
| Key | Meaning |
|
|
216
|
-
| --- | --- |
|
|
217
|
-
| `docsDir` | The folder DocuGate reads. Defaults to `docs`. |
|
|
218
|
-
| `title` | The space's title. |
|
|
219
|
-
| `role` | Repository role: `frontend`, `backend`, or `both`. Set by `docugate init`. |
|
|
220
|
-
| `
|
|
221
|
-
| `
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
|
235
|
-
|
|
|
236
|
-
|
|
|
237
|
-
|
|
|
238
|
-
|
|
|
239
|
-
|
|
|
240
|
-
|
|
|
241
|
-
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
1
|
+
# docugate
|
|
2
|
+
|
|
3
|
+
DocuGate publishes documentation straight from the markdown in your GitHub repositories and shows a walkthrough pill on your running app so any developer can see what each element on screen is and where its data comes from.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm i -g docugate
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Quick start
|
|
12
|
+
|
|
13
|
+
`cd` into your app's repository, then run:
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
docugate init
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
It walks you through four steps:
|
|
20
|
+
|
|
21
|
+
1. **Repository role.** Say whether this repository is the frontend, the backend, or both.
|
|
22
|
+
2. **Sign in and connect.** Sign in to DocuGate with GitHub and connect this repository to a space.
|
|
23
|
+
3. **IBM Bob writes the tour.** Bob reads the code and writes one `.docugate/tour/*.md` file for each screen it finds.
|
|
24
|
+
4. **The pill is added to your app.** The dev-only loader snippet is inserted into your HTML or layout file.
|
|
25
|
+
|
|
26
|
+
Once that is done:
|
|
27
|
+
|
|
28
|
+
```sh
|
|
29
|
+
docugate tour serve
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Start your app in another terminal, open it in the browser, and the pill appears in the corner.
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## Tours
|
|
37
|
+
|
|
38
|
+
A tour helps a developer who is new to a codebase see what each element on screen is and where its data comes from. For each screen there is one markdown file in `.docugate/tour/`. Each file has front matter with a `route` and a `title`, then one `##` section per stop.
|
|
39
|
+
|
|
40
|
+
**Example stop:**
|
|
41
|
+
|
|
42
|
+
```markdown
|
|
43
|
+
---
|
|
44
|
+
route: /invoices/:id
|
|
45
|
+
title: Invoice detail
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## Total
|
|
49
|
+
target: [data-tour="invoice-total"]
|
|
50
|
+
data: GET /api/invoices/:id → total
|
|
51
|
+
code: frontend/src/screens/InvoiceDetail.tsx
|
|
52
|
+
source: backend/src/billing.ts
|
|
53
|
+
docs: https://example.com/docs/billing
|
|
54
|
+
|
|
55
|
+
The amount due: the subtotal plus tax, computed by `totals()` in the backend.
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Fields:
|
|
59
|
+
|
|
60
|
+
| Field | Required | Meaning |
|
|
61
|
+
| --- | --- | --- |
|
|
62
|
+
| `target` | yes | CSS selector for the element. Prefer `[data-tour="…"]`. |
|
|
63
|
+
| `data` | no | Request and field: `METHOD /path → field`. |
|
|
64
|
+
| `code` | yes | File that renders the element, relative to the repository root. |
|
|
65
|
+
| `source` | no | File where the value is computed, when that is elsewhere. |
|
|
66
|
+
| `docs` | no | URL to relevant documentation. |
|
|
67
|
+
|
|
68
|
+
The prose paragraph after the fields explains what the element is and why its value is what it is.
|
|
69
|
+
|
|
70
|
+
Tour files are yours. `docugate tour init` never overwrites a file that already exists.
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## The pill
|
|
75
|
+
|
|
76
|
+
When `docugate tour serve` is running, the pill appears in the corner of your app. It has two modes:
|
|
77
|
+
|
|
78
|
+
- **Walkthrough.** Steps through every stop on the current screen in order, highlighting each element and showing its tour card.
|
|
79
|
+
- **Inspector.** Hovering highlights an element; clicking it shows its stop: what it is and where its data comes from. An element with no stop yet offers **Add to tour**, a small form that saves the stop straight into the tour file, and tells you which `data-tour` attribute to add when the element has none.
|
|
80
|
+
|
|
81
|
+
The pill stays on every page while the server runs, including pages with no tour yet, so their first stop can be added from the browser. Edits to the tour files show up on the page as you save them.
|
|
82
|
+
|
|
83
|
+
`docugate tour install` adds the pill for you. It only loads when the app runs on `localhost` and the tour server answers, so it never shows in production.
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## Keeping tours true
|
|
88
|
+
|
|
89
|
+
A tour is only useful while it is true, so `docugate check` verifies every claim in `.docugate/tour/` against the code. For each stop it warns when:
|
|
90
|
+
|
|
91
|
+
- the `code` file, or the `source` file, no longer exists;
|
|
92
|
+
- the `code` file, and the files it imports, no longer mention the endpoint in `data`;
|
|
93
|
+
- the `code` file no longer contains the `data-tour` value in `target` (a value passed through a prop counts);
|
|
94
|
+
- a required field is missing, or two stops on one screen point at the same element.
|
|
95
|
+
|
|
96
|
+
Rename `invoice-total` in a component and `check` tells you which stop went stale.
|
|
97
|
+
|
|
98
|
+
It checks your docs folder too:
|
|
99
|
+
|
|
100
|
+
- **Errors:** broken links between pages, links that leave the docs folder, two files that become the same URL, an unreadable `docugate.json`, an empty docs folder, or more than 300 pages.
|
|
101
|
+
- **Warnings:** pages with no `# Title`, front matter, `.mdx` files, no landing page, and `sidebar` entries that match nothing.
|
|
102
|
+
|
|
103
|
+
It exits with 1 when there are errors. Add `--strict` to fail on warnings too, which is how stale tour stops fail a build.
|
|
104
|
+
|
|
105
|
+
Use it in CI:
|
|
106
|
+
|
|
107
|
+
```yaml
|
|
108
|
+
# .github/workflows/docs.yml
|
|
109
|
+
name: Docs
|
|
110
|
+
on: [push, pull_request]
|
|
111
|
+
jobs:
|
|
112
|
+
check:
|
|
113
|
+
runs-on: ubuntu-latest
|
|
114
|
+
steps:
|
|
115
|
+
- uses: actions/checkout@v4
|
|
116
|
+
- uses: actions/setup-node@v4
|
|
117
|
+
with:
|
|
118
|
+
node-version: 22
|
|
119
|
+
- run: npx docugate@0.2 check --strict
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
Pin the version in CI, as above. Without a pin, the rules being enforced can change between two runs of the same workflow, which turns a green build red with nothing in the commit to explain it.
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## Commands
|
|
127
|
+
|
|
128
|
+
| Command | Main flags | What it does |
|
|
129
|
+
| --- | --- | --- |
|
|
130
|
+
| `docugate init` | `--dir`, `--title`, `--role frontend\|backend\|both`, `--yes` | Set up this repository for DocuGate (interactive). |
|
|
131
|
+
| `docugate check` | `--dir`, `--strict` | Check docs and tour files the way DocuGate will read them. |
|
|
132
|
+
| `docugate openapi` | `--from`, `--out`, `--include`, `--exclude`, `--redact`, `--check` | Prepare an OpenAPI spec for the API reference. |
|
|
133
|
+
| `docugate login` | | Sign in to DocuGate with GitHub. |
|
|
134
|
+
| `docugate logout` | | Sign out and delete saved credentials. |
|
|
135
|
+
| `docugate whoami` | | Print the currently signed-in user. |
|
|
136
|
+
| `docugate tour init` | `--max-cost <n>`, `--team-id <id>` | Write the first tour with IBM Bob (uses Bob Shell). |
|
|
137
|
+
| `docugate tour serve` | `--port <n>` (default 4178) | Start the local server that serves tour data for the pill. |
|
|
138
|
+
| `docugate tour install` | `--port <n>`, `--remove` | Add (or remove) the pill loader from your app's HTML or layout. |
|
|
139
|
+
| `docugate tour export <file>` | | Write every tour screen to a single JSON file. |
|
|
140
|
+
|
|
141
|
+
Run every command from the root of your repository.
|
|
142
|
+
|
|
143
|
+
---
|
|
144
|
+
|
|
145
|
+
## Try it on the demo
|
|
146
|
+
|
|
147
|
+
Clone [docugate-demo](https://github.com/Docugate/docugate-demo), a small full-stack app with a pre-written tour:
|
|
148
|
+
|
|
149
|
+
```sh
|
|
150
|
+
git clone https://github.com/Docugate/docugate-demo
|
|
151
|
+
cd docugate-demo
|
|
152
|
+
|
|
153
|
+
# install dependencies and start the app
|
|
154
|
+
npm install
|
|
155
|
+
npm run dev
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
In a second terminal:
|
|
159
|
+
|
|
160
|
+
```sh
|
|
161
|
+
cd docugate-demo
|
|
162
|
+
docugate tour serve
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Open the app in the browser. The pill appears in the bottom-right corner.
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## Several repositories in one space
|
|
170
|
+
|
|
171
|
+
A space can merge docs from a frontend, a backend, and a mobile app into one set of pages. `docugate init` connects the repository it runs in to one of your spaces once you are signed in; you can also add repositories from a space's settings on [trydocugate.site](https://www.trydocugate.site/dashboard).
|
|
172
|
+
|
|
173
|
+
Run `init` and `check` in each repository that contributes docs, and answer the role question in each: the tour lives in the frontend, and its `source` lines can point into the backend. Every one gets its own `docugate.json`, naming its own docs folder. `check` reads the repository it is run in, which is why its 300-page limit is per repository rather than per space.
|
|
174
|
+
|
|
175
|
+
See [Merging repositories](https://www.trydocugate.site/docs/merging-repositories).
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## `openapi`
|
|
180
|
+
|
|
181
|
+
Takes the OpenAPI 3 spec your backend already produces and writes the version you want published: only the public paths, without sensitive fields, with keys in a stable order so it reviews cleanly in a pull request.
|
|
182
|
+
|
|
183
|
+
```sh
|
|
184
|
+
docugate openapi --from http://localhost:3000/openapi.json \
|
|
185
|
+
--exclude "/internal/**" --redact passwordHash --out openapi.json
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
- `--from`: a `.json`, `.yaml` or `.yml` file, or a URL serving one.
|
|
189
|
+
- `--include` / `--exclude`: path globs; `*` matches within one segment and `**` matches across segments. Both can be repeated.
|
|
190
|
+
- `--redact`: a property name to remove from every schema and example. Can be repeated.
|
|
191
|
+
- `--check`: do not write anything; exit with 1 if the committed file is out of date. Useful in CI.
|
|
192
|
+
|
|
193
|
+
Instead of passing flags every time, set the same options in `docugate.json`:
|
|
194
|
+
|
|
195
|
+
```json
|
|
196
|
+
{
|
|
197
|
+
"docsDir": "docs",
|
|
198
|
+
"api": {
|
|
199
|
+
"generate": {
|
|
200
|
+
"from": "http://localhost:3000/openapi.json",
|
|
201
|
+
"output": "openapi.json",
|
|
202
|
+
"exclude": ["/internal/**"],
|
|
203
|
+
"redact": ["passwordHash"]
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## `docugate.json`
|
|
212
|
+
|
|
213
|
+
One per repository, at its root.
|
|
214
|
+
|
|
215
|
+
| Key | Meaning |
|
|
216
|
+
| --- | --- |
|
|
217
|
+
| `docsDir` | The folder DocuGate reads. Defaults to `docs`. |
|
|
218
|
+
| `title` | The space's title. |
|
|
219
|
+
| `role` | Repository role: `frontend`, `backend`, or `both`. Set by `docugate init`. |
|
|
220
|
+
| `freshness` | How often DocuGate checks that the docs still match the code: `push`, `daily`, `weekly` or `off`. Set by `docugate init`; the scheduled check itself is coming soon. |
|
|
221
|
+
| `sidebar` | File and folder names in the order the sidebar should show them. Orders this repository's own pages, not the whole space. |
|
|
222
|
+
| `api.generate` | Defaults for `docugate openapi`. |
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## IBM Bob 2.0 hackathon
|
|
227
|
+
|
|
228
|
+
This repository is DocuGate's entry to the IBM Bob 2.0 hackathon (lablab.ai, September 25 to 27, 2026). To be clear about what was built when:
|
|
229
|
+
|
|
230
|
+
**Before the event:** the CLI that was already in DocuGate's private repository: `docugate init`, `docugate check`, and `docugate openapi`. Moved here with its history.
|
|
231
|
+
|
|
232
|
+
**During the event, with IBM Bob.** Each task has its session summary and export in `bob_sessions/`, and a plan where Bob planned first:
|
|
233
|
+
|
|
234
|
+
| Task | What Bob built |
|
|
235
|
+
| --- | --- |
|
|
236
|
+
| 01 | The first tour: Bob read the Ledgerly demo and wrote `.docugate/tour/invoice-detail.md`, tracing each value to its endpoint and backend file. |
|
|
237
|
+
| 02 | The tour format in code (`parseTourFile`, `serializeTourFile`, `loadTours`, `matchRoute`) and the tour checks in `docugate check`. |
|
|
238
|
+
| 03 | `docugate tour serve` (tour data, live change events, saving stops) and `docugate tour export`. |
|
|
239
|
+
| 04 | The pill: walkthrough, inspector and Add to tour, in a shadow DOM with no dependencies. |
|
|
240
|
+
| 05 | One command: `docugate init` walks through the whole setup, and `docugate tour install` adds the pill to the app. |
|
|
241
|
+
| 06 | `docugate login`, `logout` and `whoami`, and connecting the repository to a space during `init`. |
|
|
242
|
+
| 07 | This README. |
|
|
243
|
+
|
|
244
|
+
`docugate tour init` also runs IBM Bob itself, through Bob Shell. It installs a Tour Writer mode that may only edit `.docugate/tour/`, asks Bob to read the app's code, and never changes a tour file the user already has.
|
|
245
|
+
|
|
246
|
+
**During the event, without Bob:** the Ledgerly demo app; the website side of `docugate login` on trydocugate.site; and fixes found while testing, such as Windows short paths in `tour serve` and the sign-in link on Windows.
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Licence
|
|
251
|
+
|
|
252
|
+
MIT
|
package/dist/api.js
CHANGED
|
@@ -3,6 +3,11 @@ import { loadCredentials, saveCredentials } from './auth.js';
|
|
|
3
3
|
export const BASE_URL = process.env.DOCUGATE_URL ?? 'https://www.trydocugate.site';
|
|
4
4
|
const ERROR_MESSAGES = {
|
|
5
5
|
pro_required_sources: 'Connecting more than one repository to a space needs DocuGate Pro',
|
|
6
|
+
space_limit: 'The free plan has one space. Connect this repository to it, or upgrade to Pro',
|
|
7
|
+
pro_required: 'Private repositories need DocuGate Pro',
|
|
8
|
+
no_repo_access: "DocuGate can't see this repository. Install the DocuGate GitHub App on it first",
|
|
9
|
+
slug_taken: 'You already have a space with this name',
|
|
10
|
+
github_required: 'Sign in with GitHub to create a space',
|
|
6
11
|
};
|
|
7
12
|
function friendlyError(code) {
|
|
8
13
|
return ERROR_MESSAGES[code] ?? `DocuGate said: ${code}`;
|
|
@@ -53,6 +58,13 @@ export async function getSpaces() {
|
|
|
53
58
|
const res = await apiFetch('/api/spaces/mine');
|
|
54
59
|
return res.json();
|
|
55
60
|
}
|
|
61
|
+
export async function createSpace(repo, name, docsDir) {
|
|
62
|
+
const res = await apiFetch('/api/spaces', {
|
|
63
|
+
method: 'POST',
|
|
64
|
+
body: JSON.stringify({ repo, name, docsDir }),
|
|
65
|
+
});
|
|
66
|
+
return (await res.json()).space;
|
|
67
|
+
}
|
|
56
68
|
export async function connectRepo(spaceId, repo, docsDir) {
|
|
57
69
|
await apiFetch(`/api/spaces/${spaceId}/sources`, {
|
|
58
70
|
method: 'POST',
|