docs-kit 1.4.0 → 1.4.1
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +162 -17
- data/README.md +71 -12
- data/config/importmap.rb +12 -10
- data/lib/docs_kit/engine.rb +14 -3
- data/lib/docs_kit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 29ec90ecec4c794dcfd2f0dfa7254a02844ccafa76019303b2b2bdbaf87c62c3
|
|
4
|
+
data.tar.gz: 3b8e8d345e6f795d00f44cea26529c9433eeb9ebb60e36cd07ce07541eec0fd5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cb1ef7f9d6c3673f48d965b3bdd71c85b38b0f7c053d492078046f8fd37b094a98cb92ace7b6b777e986e00fd1cd2be187f455f591ab23437a9da8dee4ac31a6
|
|
7
|
+
data.tar.gz: 573e0e3db675e201e7457c8adee993d69e239789d08a3019b89c2409dd1cd6ec154e37fc6977c1a40e95369118ea78fa815e0e1da48ba4d551c6375a81692063
|
data/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,48 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
### Upgrading from 1.4
|
|
6
|
+
|
|
7
|
+
Nothing to change for a site that registers the controller with
|
|
8
|
+
`eagerLoadControllersFrom("docs_kit/controllers", application)`, as the
|
|
9
|
+
generated `index.js` does: `docs-nav` still registers on every page. It is no
|
|
10
|
+
longer preloaded, so on docs pages the eager loader's `import()` fetches it
|
|
11
|
+
one request later instead of from the preload cache. To keep the preload, set
|
|
12
|
+
`config.docs_kit.preload = true` in `config/application.rb`.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- **`config.docs_kit.controllers_under`** (default `"docs_kit/controllers"`)
|
|
17
|
+
sets the auto-pin's module namespace. `"controllers"` pins the controller as
|
|
18
|
+
`controllers/docs_nav_controller` (same asset), so the host's own loader for
|
|
19
|
+
`controllers` finds it, with no docs-kit line in `index.js`; with
|
|
20
|
+
`lazyLoadControllersFrom("controllers", application)` a page fetches it only
|
|
21
|
+
if it renders `data-controller="docs-nav"`. Set it in
|
|
22
|
+
`config/application.rb`. (#107)
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
|
|
26
|
+
- **`docs-nav` is no longer preloaded on every page.** The auto-pin took
|
|
27
|
+
importmap-rails' default `preload: true`, so in a host whose docs share the
|
|
28
|
+
application's import map every page, docs or not, carried a
|
|
29
|
+
`<link rel="modulepreload">` for the 24 KB controller, and a host `pin` with
|
|
30
|
+
`preload: false` could not override it (a `pin_all_from` directory expands
|
|
31
|
+
over plain pins). `config.docs_kit.preload` (default `false`) is now the
|
|
32
|
+
pin's `preload:`: `true` restores 1.4's behaviour, an entry-point name
|
|
33
|
+
(importmap-rails 2.x) preloads it only where that entry point is rendered.
|
|
34
|
+
(#107)
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
|
|
38
|
+
- **One documented registration.** The README and the pin file's header now
|
|
39
|
+
point at one "Registering the controller" section. The README no longer
|
|
40
|
+
recommends `lazyLoadControllersFrom("docs_kit/controllers", application)`,
|
|
41
|
+
which in a host with its own controllers requests
|
|
42
|
+
`docs_kit/controllers/<identifier>_controller` for every host
|
|
43
|
+
`data-controller` and logs a "Failed to autoload controller" error for each,
|
|
44
|
+
on every page. (#107)
|
|
45
|
+
|
|
46
|
+
## [1.4.0] — 2026-10-15
|
|
6
47
|
|
|
7
48
|
### Upgrading from 1.3
|
|
8
49
|
|
|
@@ -95,7 +136,15 @@ raises `FrozenError`; so does mutating one of docs-kit's constants.
|
|
|
95
136
|
`on_page` macros inherit from a parent page when unset. Pages using only the
|
|
96
137
|
class macros render byte-identically. (#95)
|
|
97
138
|
|
|
98
|
-
## [1.2.1] — 2026-09-30
|
|
139
|
+
## [1.2.1] — 2026-09-30
|
|
140
|
+
|
|
141
|
+
### Changed
|
|
142
|
+
|
|
143
|
+
- **daisyui 2.x is allowed.** The dependency is now `>= 1.2, < 3`. 1.2.0 was
|
|
144
|
+
tagged but never reached RubyGems (its release run failed a stale spec), so
|
|
145
|
+
1.2.1 is the first published 1.2 release.
|
|
146
|
+
|
|
147
|
+
## [1.2.0] — 2026-09-30 (tagged; never published to RubyGems)
|
|
99
148
|
|
|
100
149
|
### Upgrading from 1.1
|
|
101
150
|
|
|
@@ -130,9 +179,6 @@ bundle exec rspec
|
|
|
130
179
|
|
|
131
180
|
### Changed
|
|
132
181
|
|
|
133
|
-
- **daisyui 2.x is allowed.** The dependency is now `>= 1.2, < 3`. 1.2.0 was
|
|
134
|
-
tagged but never reached RubyGems (its release run failed a stale spec), so
|
|
135
|
-
1.2.1 is the first published 1.2 release.
|
|
136
182
|
- **The reusable deploy workflow runs on Node 24 actions.** `deploy.yml` now
|
|
137
183
|
uses `actions/checkout@v7`, `docker/setup-buildx-action@v4`,
|
|
138
184
|
`docker/login-action@v4`, `docker/build-push-action@v7` and
|
|
@@ -169,21 +215,68 @@ bundle exec rspec
|
|
|
169
215
|
`lexer:` still wins, and a block with neither (or an unguessable filename)
|
|
170
216
|
stays Ruby, so existing output is unchanged.
|
|
171
217
|
|
|
172
|
-
## [1.1.1]
|
|
218
|
+
## [1.1.1] — 2026-08-27
|
|
173
219
|
|
|
174
220
|
### Fixed
|
|
175
221
|
|
|
176
|
-
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
222
|
+
- **`/llms.txt` sends a public max-age** (`expires_in 300, public: true`), so
|
|
223
|
+
shared caches such as dash-proxy can store it; ETag revalidation is
|
|
224
|
+
unchanged. (#75)
|
|
225
|
+
|
|
226
|
+
## [1.1.0] — 2026-08-27
|
|
227
|
+
|
|
228
|
+
### Added
|
|
229
|
+
|
|
230
|
+
- **Docs versions foundation.** `c.versions` (`DocsKit::DocVersion`),
|
|
231
|
+
`c.repo_url` and `c.snapshots_path`, a request-scoped version
|
|
232
|
+
(`DocsKit::Scope`) and a snapshot content source. A site that configures no
|
|
233
|
+
versions renders unchanged. (#67)
|
|
234
|
+
|
|
235
|
+
### Changed
|
|
236
|
+
|
|
237
|
+
- **The reusable deploy workflow uses dash 4.** `deploy.yml` installs
|
|
238
|
+
`dash ~> 4.0` and runs `dash doctor` before deploying; the registry secret is
|
|
239
|
+
now `DASH_REGISTRY_PASSWORD` (`KAMAL_REGISTRY_PASSWORD` is still exported),
|
|
240
|
+
and the `docs-kit new` deploy template turns on dash-proxy compression,
|
|
241
|
+
caching and security headers. (#74)
|
|
242
|
+
|
|
243
|
+
### Fixed
|
|
244
|
+
|
|
245
|
+
- **Repointed at the `zoolutions` org.** The reusable deploy workflow, the
|
|
246
|
+
`docs-kit new` and install templates, the README and the gemspec metadata
|
|
247
|
+
now reference `zoolutions/docs-kit` (reusable-workflow `uses:` refs don't
|
|
248
|
+
follow the repo move's redirect). (#70)
|
|
249
|
+
|
|
250
|
+
## [1.0.8] — 2026-08-04
|
|
251
|
+
|
|
252
|
+
### Added
|
|
253
|
+
|
|
254
|
+
- **`c.brand_logo`.** A config-driven brand mark (`svg:`, `paths:`, `markup:`,
|
|
255
|
+
`file:` or `src:`) rendered by the new `DocsUI::Logo` in the topbar and
|
|
256
|
+
sidebar brand links, falling back to `c.brand`; `c.landing.logo` accepts the
|
|
257
|
+
same forms. `c.topbar_brand = :mobile_only` hides the topbar copy where the
|
|
258
|
+
sidebar brand is already visible. (#68)
|
|
259
|
+
|
|
260
|
+
### Changed
|
|
261
|
+
|
|
262
|
+
- **The sidebar's top-level heading is flattened.** With one nav heading it
|
|
263
|
+
is no longer rendered; with several, each is a static `menu-title` label and
|
|
264
|
+
only subgroups collapse. The landing doc index follows the same rule. (#66)
|
|
265
|
+
|
|
266
|
+
## [1.0.7] — 2026-08-03
|
|
267
|
+
|
|
268
|
+
### Added
|
|
269
|
+
|
|
270
|
+
- **Version-aware `--sync` migrations.** Install and `--sync` stamp the
|
|
271
|
+
initializer with `# docs-kit synced: vX.Y.Z`, and `--sync` runs the ordered
|
|
272
|
+
migrations between that version and the gem's, printing what it can't
|
|
273
|
+
automate. The migration registry ships empty in 1.0.x. (#56)
|
|
274
|
+
- **Two homes: `c.app_link`.** An opt-in `c.app_link = { href:, label: }`
|
|
275
|
+
renders a topbar link back to the hosting app, and the page masthead's link
|
|
276
|
+
now follows `c.brand_href` instead of the host's `root_path` and reads
|
|
277
|
+
"← Docs home". (#63)
|
|
278
|
+
|
|
279
|
+
## [1.0.6] — 2026-07-04
|
|
187
280
|
|
|
188
281
|
### Added
|
|
189
282
|
|
|
@@ -194,6 +287,11 @@ bundle exec rspec
|
|
|
194
287
|
site's asset pipeline). nil (the default) omits it, so it's backwards-compatible.
|
|
195
288
|
This closes the gap a mounted docs app hit — a hero with no way to show the
|
|
196
289
|
product's own logo — the first consumer to try `DocsUI::Landing` on a real site.
|
|
290
|
+
|
|
291
|
+
## [1.0.5] — 2026-07-04
|
|
292
|
+
|
|
293
|
+
### Added
|
|
294
|
+
|
|
197
295
|
- **`DocsUI::Landing` — a config-driven marketing landing page.** Every consuming
|
|
198
296
|
site (and this dogfood site) was hand-rolling a home page; now render
|
|
199
297
|
`DocsUI::Landing` and drive it from a new `c.landing` config block
|
|
@@ -207,6 +305,48 @@ bundle exec rspec
|
|
|
207
305
|
now renders it and the initializer documents `c.landing`. This is the first
|
|
208
306
|
landing pattern proven on a **mounted** docs app (a docs section inside a larger
|
|
209
307
|
Rails app whose `/` is already taken), contributed back from that use case.
|
|
308
|
+
|
|
309
|
+
## [1.0.4] — 2026-07-04
|
|
310
|
+
|
|
311
|
+
### Changed
|
|
312
|
+
|
|
313
|
+
- **rouge 5 is allowed.** The dependency is now `>= 4.0, < 6`; the `< 5` cap
|
|
314
|
+
was downgrading sites already on rouge 5. (#54)
|
|
315
|
+
|
|
316
|
+
### Fixed
|
|
317
|
+
|
|
318
|
+
- **`docs_kit:install --sync` no longer re-injects the commented `/mcp` route
|
|
319
|
+
scaffold** into a site that already draws live MCP routes. (#53)
|
|
320
|
+
|
|
321
|
+
## [1.0.3] — 2026-07-04
|
|
322
|
+
|
|
323
|
+
### Added
|
|
324
|
+
|
|
325
|
+
- **`docs_kit:install` templates a lean multi-stage `Dockerfile` and a
|
|
326
|
+
`.dockerignore`.** The `Dockerfile` is site-owned (skipped if present) and
|
|
327
|
+
carries a `# docs-kit Dockerfile vX.Y.Z` marker that `--sync` warns about
|
|
328
|
+
when it is older than the gem; `docs-kit new` uses the same template. (#52)
|
|
329
|
+
|
|
330
|
+
## [1.0.2] — 2026-07-03
|
|
331
|
+
|
|
332
|
+
### Fixed
|
|
333
|
+
|
|
334
|
+
- **SEO `og:image` 404.** The og:image tag pointed at the raw config path
|
|
335
|
+
(`https://site/og/og.png`), which isn't a served URL — Propshaft serves the
|
|
336
|
+
digested asset under `/assets`. A relative `og_image` is now resolved through
|
|
337
|
+
the site's asset pipeline (`image_url`) to the digested `/assets/og/og-<digest>.png`
|
|
338
|
+
URL, and the image is treated as **site content**: the gem ships none,
|
|
339
|
+
`c.seo.og_image` defaults to **nil** (unset → no og:image tag, never a 404), and
|
|
340
|
+
the `docs_kit:og` task writes into the *site's* `app/assets/images/`. Added a
|
|
341
|
+
booted-app integration test in the dogfood site
|
|
342
|
+
(`docs/test/integration/seo_meta_tags_test.rb`) that asserts og:image resolves
|
|
343
|
+
to a `/assets` URL that actually returns 200 — the coverage isolated component
|
|
344
|
+
specs can't provide.
|
|
345
|
+
|
|
346
|
+
## [1.0.1] — 2026-07-03
|
|
347
|
+
|
|
348
|
+
### Added
|
|
349
|
+
|
|
210
350
|
- **SEO + social sharing.** Every page now emits a complete SEO `<head>` —
|
|
211
351
|
meta description, Open Graph, Twitter Card, canonical, favicon, robots, and
|
|
212
352
|
theme-color — via the new `DocsUI::MetaTags` component, driven entirely by a
|
|
@@ -218,6 +358,11 @@ bundle exec rspec
|
|
|
218
358
|
Backwards-compatible: a site that sets no `c.seo` renders a valid minimal card
|
|
219
359
|
and its `<head>` is a strict superset of before. The install generator documents
|
|
220
360
|
`c.seo` and installs the task; `docs-kit new` reminds the owner to run it. (#48)
|
|
361
|
+
|
|
362
|
+
## [1.0.0] — 2026-07-03
|
|
363
|
+
|
|
364
|
+
### Added
|
|
365
|
+
|
|
221
366
|
- Release tooling matching the sibling gems (daisyui/phlex-reactive/pgbus): a
|
|
222
367
|
`rake release[X.Y.Z]` task (version bump → lockfile update → build-verify →
|
|
223
368
|
commit → push → GitHub Release; `pre`/`force` supported, `main`-only, clean-tree
|
data/README.md
CHANGED
|
@@ -124,7 +124,7 @@ generators:
|
|
|
124
124
|
|-------|---------------|-----|
|
|
125
125
|
| `ApplicationController#render_page` defined by hand | `DocsKit::Controller#render_page` is included (the generator injects `include DocsKit::Controller`) | Delete the method — keep the `include`. |
|
|
126
126
|
| `app/helpers/icon_helper.rb` | docs-kit renders icons via rails_icons (`DocsUI::Icon`) | Delete the file. |
|
|
127
|
-
| Hand-pinned docs-kit lines in `config/importmap.rb` | the engine auto-pins the `docs-nav` controller and its assets | Delete the manual `pin`/`pin_all_from` lines for docs-kit. |
|
|
127
|
+
| Hand-pinned docs-kit lines in `config/importmap.rb` | the engine auto-pins the `docs-nav` controller and its assets | Delete the manual `pin`/`pin_all_from` lines for docs-kit. A line kept only to change `preload:` or `under:` becomes `config.docs_kit.preload` or `config.docs_kit.controllers_under` in `config/application.rb` (see [Registering the controller](#registering-the-controller)). |
|
|
128
128
|
| `Dockerfile` stamped by an older docs-kit (`# docs-kit Dockerfile vX.Y.Z`) | docs-kit ships an optimized, multi-stage Dockerfile; a stale copy misses image-size wins | Diff yours against the current template (`lib/generators/docs_kit/install/templates/Dockerfile.tt` in the gem), adopt the changes or replace it. See [Upgrading your Dockerfile](#upgrading-your-dockerfile). |
|
|
129
129
|
| `app/assets/stylesheets/tailwind.sources.css` committed to git | `bin/build-css` regenerates it on every build with machine-specific absolute gem paths — the committed copy churns per machine/Ruby and no build consumes it. The generator adds the `.gitignore` entry, but gitignoring doesn't untrack an already-committed copy. | `git rm --cached app/assets/stylesheets/tailwind.sources.css` and commit. |
|
|
130
130
|
|
|
@@ -1123,12 +1123,74 @@ server round-trip:
|
|
|
1123
1123
|
of three placements, auto-hiding on short pages. No server-side knowledge of
|
|
1124
1124
|
the headings, no per-page wiring.
|
|
1125
1125
|
|
|
1126
|
+
### Registering the controller
|
|
1127
|
+
|
|
1128
|
+
The engine pins `docs-nav` into the host's import map as
|
|
1129
|
+
`docs_kit/controllers/docs_nav_controller`, with no `<link rel="modulepreload">`
|
|
1130
|
+
on any page. Register it in `app/javascript/controllers/index.js` one of two
|
|
1131
|
+
ways.
|
|
1132
|
+
|
|
1133
|
+
**Eager** — what `docs_kit:install` writes, next to the stock eager loader:
|
|
1134
|
+
|
|
1135
|
+
```js
|
|
1136
|
+
import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
|
|
1137
|
+
eagerLoadControllersFrom("docs_kit/controllers", application)
|
|
1138
|
+
```
|
|
1139
|
+
|
|
1140
|
+
It imports the controller on every page that loads the entry point, whether
|
|
1141
|
+
the page renders `docs-nav` or not. Right for a docs-only site, where every page
|
|
1142
|
+
renders the sidebar.
|
|
1143
|
+
|
|
1144
|
+
**Through the host's own loader** — pin `docs-nav` under the host's
|
|
1145
|
+
`controllers` namespace instead, and add no docs-kit line to `index.js`:
|
|
1146
|
+
|
|
1147
|
+
```ruby
|
|
1148
|
+
# config/application.rb
|
|
1149
|
+
config.docs_kit.controllers_under = "controllers"
|
|
1150
|
+
```
|
|
1151
|
+
|
|
1152
|
+
The module becomes `controllers/docs_nav_controller` (same asset), so the
|
|
1153
|
+
host's existing `eagerLoadControllersFrom("controllers", application)` or
|
|
1154
|
+
`lazyLoadControllersFrom("controllers", application)` finds it by convention.
|
|
1155
|
+
With the lazy loader, a page fetches `docs-nav` only if it renders
|
|
1156
|
+
`data-controller="docs-nav"`: the setup for a host whose docs share an app with
|
|
1157
|
+
other pages. Drop an old `eagerLoadControllersFrom("docs_kit/controllers", ...)`
|
|
1158
|
+
line, which no longer matches anything. Don't keep a host file named
|
|
1159
|
+
`app/javascript/controllers/docs_nav_controller.js`: it has the same module
|
|
1160
|
+
name, and the host's `config/importmap.rb` is drawn after the engine's, so it
|
|
1161
|
+
replaces docs-kit's controller.
|
|
1162
|
+
|
|
1163
|
+
> **Don't** call `lazyLoadControllersFrom("docs_kit/controllers", application)`
|
|
1164
|
+
> in a host with its own controllers. A lazy loader imports
|
|
1165
|
+
> `<under>/<identifier>_controller` for *every* `data-controller` on the page
|
|
1166
|
+
> that isn't registered yet, so `data-controller="dropdown"` makes it request
|
|
1167
|
+
> `docs_kit/controllers/dropdown_controller`, which isn't in the map: one
|
|
1168
|
+
> "Failed to autoload controller" console error per host identifier, on every
|
|
1169
|
+
> page. A second lazy loader is only safe on a namespace that owns every
|
|
1170
|
+
> identifier on the page.
|
|
1171
|
+
|
|
1172
|
+
**Preloading.** `config.docs_kit.preload` (default `false`) is the pin's
|
|
1173
|
+
`preload:`. `true` puts a modulepreload for `docs-nav` on every page that renders
|
|
1174
|
+
the import map (docs-kit 1.4's behaviour). An entry-point name, such as
|
|
1175
|
+
`"docs"`, preloads it only on pages that render that entry point; it needs
|
|
1176
|
+
importmap-rails 2.x (1.x takes only `true`/`false`, and docs-kit doesn't check).
|
|
1177
|
+
|
|
1178
|
+
```ruby
|
|
1179
|
+
# config/application.rb — defaults shown
|
|
1180
|
+
config.docs_kit.preload = false # true | "docs" | %w[docs admin]
|
|
1181
|
+
config.docs_kit.controllers_under = "docs_kit/controllers"
|
|
1182
|
+
```
|
|
1183
|
+
|
|
1184
|
+
importmap-rails draws the pin in its own initializer, before
|
|
1185
|
+
`config/initializers/` run, so set both in `config/application.rb`. With
|
|
1186
|
+
`config.docs_kit.auto_pin = false` neither applies: the host owns the pin.
|
|
1187
|
+
|
|
1126
1188
|
### A dedicated docs import map
|
|
1127
1189
|
|
|
1128
1190
|
By default the Shell loads the host's `application` entry point from
|
|
1129
1191
|
`Rails.application.importmap`, and the engine adds the `docs-nav` pin to that
|
|
1130
1192
|
map. A host with several import maps can give its docs their own entry point
|
|
1131
|
-
and map
|
|
1193
|
+
and map:
|
|
1132
1194
|
|
|
1133
1195
|
```ruby
|
|
1134
1196
|
# config/application.rb — skip the engine's auto-pin into the shared map
|
|
@@ -1150,14 +1212,17 @@ pin "docs"
|
|
|
1150
1212
|
pin "@hotwired/turbo-rails", to: "turbo.min.js"
|
|
1151
1213
|
pin "@hotwired/stimulus", to: "stimulus.min.js"
|
|
1152
1214
|
pin "@hotwired/stimulus-loading", to: "stimulus-loading.js"
|
|
1215
|
+
# This map only loads on docs pages, so preloading docs-nav here is the point.
|
|
1153
1216
|
pin_all_from DocsKit::Engine.root.join("app/javascript/docs_kit/controllers"),
|
|
1154
|
-
under: "docs_kit/controllers", to: "docs_kit/controllers"
|
|
1217
|
+
under: "docs_kit/controllers", to: "docs_kit/controllers", preload: true
|
|
1155
1218
|
```
|
|
1156
1219
|
|
|
1157
1220
|
`c.importmap` takes an `Importmap::Map` or a callable returning one; a callable
|
|
1158
1221
|
is resolved on every render, so a map rebuilt on code reload is picked up. The
|
|
1159
|
-
`docs` entry point registers the
|
|
1160
|
-
|
|
1222
|
+
`docs` entry point registers the controller eagerly, as in
|
|
1223
|
+
[Registering the controller](#registering-the-controller). With one shared map,
|
|
1224
|
+
a `docs` entry point and `config.docs_kit.preload = "docs"` preload `docs-nav`
|
|
1225
|
+
on docs pages only, without a second map.
|
|
1161
1226
|
|
|
1162
1227
|
### On this page (auto-TOC)
|
|
1163
1228
|
|
|
@@ -1183,13 +1248,7 @@ headings, so they need zero per-page data. A page with fewer than 2 sections
|
|
|
1183
1248
|
hides the TOC. Scroll-spy highlights the section you're reading.
|
|
1184
1249
|
|
|
1185
1250
|
`DocsUI::Sidebar` already carries `data-controller="docs-nav"`. Register the
|
|
1186
|
-
controller in the
|
|
1187
|
-
|
|
1188
|
-
```js
|
|
1189
|
-
// app/javascript/controllers/index.js
|
|
1190
|
-
import { lazyLoadControllersFrom } from "@hotwired/stimulus-loading"
|
|
1191
|
-
lazyLoadControllersFrom("docs_kit/controllers", application)
|
|
1192
|
-
```
|
|
1251
|
+
controller as in [Registering the controller](#registering-the-controller).
|
|
1193
1252
|
|
|
1194
1253
|
The **active nav item** needs no JS — it's server-rendered from the request path.
|
|
1195
1254
|
|
data/config/importmap.rb
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# Auto-pins the gem's bundled Stimulus
|
|
4
|
-
#
|
|
3
|
+
# Auto-pins the gem's bundled Stimulus controller (docs-nav) for importmap-rails
|
|
4
|
+
# consumers. With the defaults it is `docs_kit/controllers/docs_nav_controller`,
|
|
5
|
+
# preloaded nowhere. Two engine options, set in the host's config/application.rb,
|
|
6
|
+
# shape the pin:
|
|
5
7
|
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
# eagerLoadControllersFrom("docs_kit/controllers", application)
|
|
8
|
+
# config.docs_kit.preload = false # true, or an entry point ("docs")
|
|
9
|
+
# config.docs_kit.controllers_under = "docs_kit/controllers" # "controllers" rides the host's lazy loader
|
|
9
10
|
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
|
|
11
|
+
# How to register the controller in the host's controllers/index.js, and which
|
|
12
|
+
# loader to avoid: README → "Registering the controller".
|
|
13
|
+
docs_kit = DocsKit::Engine.config.docs_kit
|
|
13
14
|
pin_all_from DocsKit::Engine.root.join("app/javascript/docs_kit/controllers"),
|
|
14
|
-
under:
|
|
15
|
-
to: "docs_kit/controllers"
|
|
15
|
+
under: docs_kit.controllers_under,
|
|
16
|
+
to: "docs_kit/controllers",
|
|
17
|
+
preload: docs_kit.preload
|
data/lib/docs_kit/engine.rb
CHANGED
|
@@ -49,11 +49,22 @@ module DocsKit
|
|
|
49
49
|
app.config.assets.paths << JAVASCRIPT_PATH.to_s if app.config.respond_to?(:assets)
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
# Host-facing engine options
|
|
53
|
-
#
|
|
54
|
-
#
|
|
52
|
+
# Host-facing engine options, set in config/application.rb: importmap-rails
|
|
53
|
+
# draws the auto-pin in its own initializer, before config/initializers run.
|
|
54
|
+
# `config.docs_kit.auto_pin = false` keeps the gem's pin out of the host's
|
|
55
|
+
# shared import map, for a host that pins `docs_kit/controllers` in a
|
|
56
|
+
# dedicated docs map.
|
|
55
57
|
config.docs_kit = ActiveSupport::OrderedOptions.new
|
|
56
58
|
config.docs_kit.auto_pin = true
|
|
59
|
+
# The auto-pin's `preload:`. false (the default) keeps docs-nav out of every
|
|
60
|
+
# page's modulepreloads; true preloads it everywhere; an entry-point name (or
|
|
61
|
+
# an array, importmap-rails 2.x) preloads it only where that entry point loads.
|
|
62
|
+
config.docs_kit.preload = false
|
|
63
|
+
# The auto-pin's module namespace. "controllers" pins docs-nav as
|
|
64
|
+
# `controllers/docs_nav_controller`, so the host's own
|
|
65
|
+
# `lazyLoadControllersFrom("controllers", application)` loads it by convention
|
|
66
|
+
# on the pages that render it. The asset path never changes.
|
|
67
|
+
config.docs_kit.controllers_under = "docs_kit/controllers"
|
|
57
68
|
|
|
58
69
|
# Auto-pin the controller for importmap-rails consumers, so a host app gets
|
|
59
70
|
# `docs_kit/controllers/docs_nav_controller` with no manual pin.
|
data/lib/docs_kit/version.rb
CHANGED