markdowndocs 0.8.0 → 0.9.0
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 +11 -0
- data/README.md +85 -8
- data/app/controllers/markdowndocs/preferences_controller.rb +20 -6
- data/app/models/markdowndocs/documentation.rb +18 -5
- data/app/services/markdowndocs/markdown_renderer.rb +33 -5
- data/config/routes.rb +8 -5
- data/lib/generators/markdowndocs/install/templates/initializer.rb +20 -2
- data/lib/markdowndocs/configuration.rb +43 -3
- data/lib/markdowndocs/version.rb +1 -1
- metadata +6 -6
- data/docs/superpowers/plans/2026-05-15-path-based-audience-routing.md +0 -1619
- data/docs/superpowers/specs/2026-05-15-path-based-audience-routing-design.md +0 -311
- data/log/test.log +0 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 764b5150885d6a306eae6d49fbabd8dedee96dffa9bc55a6f290da57e3b53123
|
|
4
|
+
data.tar.gz: 2a75805e06c5caa6fcdbf8e4860836bcf886fc5453b4d394761f8f45ae8ba114
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8502ba23be6b2ccafa8abc6f0388fddfaf1eae79da276b2ec676087195f04ddc000c576b636c5f81473c10fe30f2786faa9fa7b901419a3f8689226d6440a86e
|
|
7
|
+
data.tar.gz: 0d71e8284d7a5ed9efcdd8841e0a7e760bb26906e4ac61fb27a1ec32e259357c920e6b86ff66bc16e7d3fdda632c2ed5c12b216ff2b71c1f025f3f1ab73aab99
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.9.0] - 2026-06-21
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- **Collapsible disclosure (`<details>` / `<summary>`).** Both tags — plus the
|
|
13
|
+
`open` attribute — are now in the sanitizer allow-list, so docs can use native,
|
|
14
|
+
no-JS click-to-expand sections. Rides the same curated raw-HTML passthrough as
|
|
15
|
+
inline SVG (requires `config.allow_svg = true`, which flips commonmarker to
|
|
16
|
+
unsafe so the markup reaches the sanitizer). Scripts and `on*` handlers inside
|
|
17
|
+
a disclosure are still stripped.
|
|
18
|
+
|
|
8
19
|
## [0.8.0] - 2026-05-29
|
|
9
20
|
|
|
10
21
|
### Added
|
data/README.md
CHANGED
|
@@ -118,13 +118,7 @@ Add optional YAML front matter to set metadata:
|
|
|
118
118
|
---
|
|
119
119
|
title: "Quick Start Guide"
|
|
120
120
|
description: "Get up and running in five minutes"
|
|
121
|
-
|
|
122
|
-
- guide
|
|
123
|
-
- technical
|
|
124
|
-
modes:
|
|
125
|
-
- guide
|
|
126
|
-
- technical
|
|
127
|
-
default_mode: guide
|
|
121
|
+
keywords: [setup, install]
|
|
128
122
|
---
|
|
129
123
|
|
|
130
124
|
# Quick Start Guide
|
|
@@ -132,6 +126,17 @@ default_mode: guide
|
|
|
132
126
|
Your content here...
|
|
133
127
|
```
|
|
134
128
|
|
|
129
|
+
Recognized keys:
|
|
130
|
+
|
|
131
|
+
| Key | Type | Purpose |
|
|
132
|
+
| -------------- | ---------------- | -------------------------------------------------------------------------------- |
|
|
133
|
+
| `title` | String | Overrides the H1-derived title shown in nav and `<title>` |
|
|
134
|
+
| `description` | String | Card description on the index page; defaults to the first paragraph |
|
|
135
|
+
| `keywords` | Array of String | Tags surfaced to the search indexer |
|
|
136
|
+
| `modes` | Array of String | Per-doc override of which modes contain block-filtered content (see Mode Blocks) |
|
|
137
|
+
| `default_mode` | String | Per-doc default mode (overrides `config.default_mode`) |
|
|
138
|
+
| `audience` | String / Array | **Deprecated.** Use filesystem-path scoping instead — see below |
|
|
139
|
+
|
|
135
140
|
If front matter is omitted, the title is extracted from the first H1 heading and the description from the first paragraph.
|
|
136
141
|
|
|
137
142
|
### Audience Filtering by Filesystem Path
|
|
@@ -157,12 +162,47 @@ URLs follow the filesystem layout: `app/docs/billing.md` is served at
|
|
|
157
162
|
Subdirectories whose name does not match a configured mode are ignored
|
|
158
163
|
by document discovery, with a one-line warning at boot.
|
|
159
164
|
|
|
165
|
+
#### Linking to Docs from Your Host App
|
|
166
|
+
|
|
167
|
+
The engine exposes two named route helpers under its mount point:
|
|
168
|
+
|
|
169
|
+
```erb
|
|
170
|
+
<%# Shared (root) doc — /docs/billing %>
|
|
171
|
+
<%= link_to "Billing", markdowndocs.doc_path(slug: "billing") %>
|
|
172
|
+
|
|
173
|
+
<%# Mode-scoped doc — /docs/technical/architecture %>
|
|
174
|
+
<%= link_to "Architecture",
|
|
175
|
+
markdowndocs.scoped_doc_path(mode: "technical", slug: "architecture") %>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
The `:mode` segment is constrained at the route level; unknown modes
|
|
179
|
+
404 rather than reach the controller.
|
|
180
|
+
|
|
181
|
+
#### Switching Modes
|
|
182
|
+
|
|
183
|
+
The mode switcher in the docs UI is *smart* about navigation. When the
|
|
184
|
+
viewer toggles modes, the engine attempts to keep them on the
|
|
185
|
+
equivalent document in the target mode:
|
|
186
|
+
|
|
187
|
+
- On `/docs/billing` (shared root), switching to `technical` redirects
|
|
188
|
+
to `/docs/technical/billing` if that scoped sibling exists; otherwise
|
|
189
|
+
it stays on the shared doc.
|
|
190
|
+
- On `/docs/technical/architecture`, switching to `guide` redirects to
|
|
191
|
+
`/docs/architecture` if a shared sibling exists; otherwise it stays
|
|
192
|
+
on the current page.
|
|
193
|
+
- Toggling from the index (`/docs`) just reloads the index in the new
|
|
194
|
+
mode.
|
|
195
|
+
|
|
196
|
+
URLs remain stable across the toggle — bookmarks and shared links to
|
|
197
|
+
mode-scoped docs keep working.
|
|
198
|
+
|
|
160
199
|
### Audience Filtering by Frontmatter (deprecated)
|
|
161
200
|
|
|
162
201
|
The `audience:` frontmatter key from v0.6.0 still works in v0.7.x but is
|
|
163
202
|
deprecated. A warning is logged the first time each affected file is
|
|
164
203
|
read. Move the file into the matching mode subdirectory and remove the
|
|
165
|
-
`audience:` key
|
|
204
|
+
`audience:` key — see [Migrating from v0.6.x to v0.7.0](#migrating-from-v06x-to-v070)
|
|
205
|
+
for step-by-step diffs.
|
|
166
206
|
|
|
167
207
|
```yaml
|
|
168
208
|
audience: technical # deprecated — move to app/docs/technical/
|
|
@@ -216,6 +256,43 @@ function hello() {
|
|
|
216
256
|
|
|
217
257
|
Supported languages include Ruby, JavaScript, Python, Bash, YAML, JSON, HTML, CSS, SQL, and [many more](https://github.com/rouge-ruby/rouge/wiki/List-of-supported-languages-and-lexers).
|
|
218
258
|
|
|
259
|
+
### Inline SVG (Hand-Authored Diagrams)
|
|
260
|
+
|
|
261
|
+
Set `config.allow_svg = true` to opt into a curated, safe subset of inline
|
|
262
|
+
SVG for diagrams written directly in markdown. The sanitizer remains the
|
|
263
|
+
security boundary: `<script>`, `<foreignObject>`, `on*` event handlers, and
|
|
264
|
+
`javascript:` URIs are always stripped, regardless of this setting.
|
|
265
|
+
|
|
266
|
+
Allowed structural elements: `svg g path rect circle ellipse line polyline
|
|
267
|
+
polygon text tspan defs marker desc`.
|
|
268
|
+
|
|
269
|
+
#### Giving an SVG an accessible name
|
|
270
|
+
|
|
271
|
+
Inline SVGs need an accessible name so screen readers can announce them.
|
|
272
|
+
Use `role="img"` plus `aria-label`, or pair the SVG with a `<desc>` and
|
|
273
|
+
`aria-describedby`:
|
|
274
|
+
|
|
275
|
+
```html
|
|
276
|
+
<svg role="img" aria-label="High-level system architecture"
|
|
277
|
+
viewBox="0 0 100 100">
|
|
278
|
+
…
|
|
279
|
+
</svg>
|
|
280
|
+
|
|
281
|
+
<svg role="img" aria-labelledby="t1" aria-describedby="d1"
|
|
282
|
+
viewBox="0 0 100 100">
|
|
283
|
+
<desc id="d1">Three-tier diagram: browser → Rails → Postgres.</desc>
|
|
284
|
+
…
|
|
285
|
+
</svg>
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
Decorative SVGs (icons, dividers) should be marked `aria-hidden="true"`
|
|
289
|
+
so assistive technology skips them.
|
|
290
|
+
|
|
291
|
+
> The `<title>` SVG element is intentionally NOT in the safelist: the
|
|
292
|
+
> HTML5 parser treats it as a raw-text element in HTML context, so the
|
|
293
|
+
> name would silently escape into surrounding text. `aria-label` is the
|
|
294
|
+
> reliable path.
|
|
295
|
+
|
|
219
296
|
### Categories
|
|
220
297
|
|
|
221
298
|
To organize docs on the index page, map category names to slugs in your configuration:
|
|
@@ -43,22 +43,36 @@ module Markdowndocs
|
|
|
43
43
|
slug = extract_slug_from_path(current_path)
|
|
44
44
|
return index_path if slug.nil?
|
|
45
45
|
|
|
46
|
-
docs_path = Markdowndocs.config.resolved_docs_path
|
|
47
|
-
scoped_file = docs_path.join(target_mode, "#{slug}.md")
|
|
48
|
-
root_file = docs_path.join("#{slug}.md")
|
|
49
|
-
|
|
50
46
|
scoped_url = markdowndocs.scoped_doc_path(mode: target_mode, slug: slug)
|
|
51
47
|
root_url = markdowndocs.doc_path(slug: slug)
|
|
52
48
|
|
|
53
|
-
|
|
49
|
+
# Use Documentation.find_by_slug for existence so symlink-escape
|
|
50
|
+
# rejection (and any other reachability rules) match what the show
|
|
51
|
+
# action would actually serve. Bypassing this — e.g. with raw
|
|
52
|
+
# File.exist? — can redirect the user into a 404.
|
|
53
|
+
if scoped_sibling_reachable?(slug, target_mode) && current_path != scoped_url
|
|
54
54
|
scoped_url
|
|
55
|
-
elsif
|
|
55
|
+
elsif root_sibling_reachable?(slug) && current_path != root_url
|
|
56
56
|
root_url
|
|
57
57
|
else
|
|
58
58
|
current_path
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
+
def scoped_sibling_reachable?(slug, target_mode)
|
|
63
|
+
docs_path = Markdowndocs.config.resolved_docs_path
|
|
64
|
+
scoped_file = docs_path.join(target_mode, "#{slug}.md")
|
|
65
|
+
return false unless scoped_file.exist?
|
|
66
|
+
Documentation.inside_docs_path?(scoped_file, docs_path.realpath)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def root_sibling_reachable?(slug)
|
|
70
|
+
docs_path = Markdowndocs.config.resolved_docs_path
|
|
71
|
+
root_file = docs_path.join("#{slug}.md")
|
|
72
|
+
return false unless root_file.exist?
|
|
73
|
+
Documentation.inside_docs_path?(root_file, docs_path.realpath)
|
|
74
|
+
end
|
|
75
|
+
|
|
62
76
|
# Pulls the slug from a docs path. Returns nil if the path is the index
|
|
63
77
|
# or doesn't match the docs URL shape. Recognizes both /docs/<slug> and
|
|
64
78
|
# /docs/<mode>/<slug>.
|
|
@@ -19,15 +19,24 @@ module Markdowndocs
|
|
|
19
19
|
docs_path = Markdowndocs.config.resolved_docs_path
|
|
20
20
|
return [] unless docs_path.exist?
|
|
21
21
|
|
|
22
|
+
docs_root_real = docs_path.realpath
|
|
23
|
+
|
|
22
24
|
files = Dir.glob(docs_path.join("*.md"))
|
|
23
25
|
|
|
24
26
|
modes = Markdowndocs.config.modes
|
|
25
27
|
modes.each do |mode|
|
|
26
28
|
mode_dir = docs_path.join(mode)
|
|
27
|
-
|
|
29
|
+
next unless mode_dir.exist?
|
|
30
|
+
next unless inside_docs_path?(mode_dir, docs_root_real)
|
|
31
|
+
files.concat(Dir.glob(mode_dir.join("*.md")))
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# Drop symlink-escapes from the merged file list.
|
|
35
|
+
files = files.select do |f|
|
|
36
|
+
inside_docs_path?(Pathname.new(f), docs_root_real)
|
|
28
37
|
end
|
|
29
38
|
|
|
30
|
-
warn_about_non_mode_subdirectories(docs_path, modes)
|
|
39
|
+
warn_about_non_mode_subdirectories(docs_path, modes, docs_root_real)
|
|
31
40
|
|
|
32
41
|
files.map { |f| new(Pathname.new(f)) }.sort_by(&:path_slug)
|
|
33
42
|
end
|
|
@@ -36,8 +45,9 @@ module Markdowndocs
|
|
|
36
45
|
# subdirectory under docs_path that isn't a configured mode. Files
|
|
37
46
|
# inside such subdirectories are silently dropped by discovery —
|
|
38
47
|
# the warning makes that visible.
|
|
39
|
-
def self.warn_about_non_mode_subdirectories(docs_path, modes)
|
|
48
|
+
def self.warn_about_non_mode_subdirectories(docs_path, modes, docs_root_real = nil)
|
|
40
49
|
warned = Markdowndocs.config.non_mode_subdirs_warned
|
|
50
|
+
docs_root_real ||= docs_path.realpath
|
|
41
51
|
|
|
42
52
|
children = begin
|
|
43
53
|
docs_path.children
|
|
@@ -48,6 +58,8 @@ module Markdowndocs
|
|
|
48
58
|
|
|
49
59
|
children.each do |child|
|
|
50
60
|
next unless child.directory?
|
|
61
|
+
# Don't follow symlinked subdirs that escape docs_path.
|
|
62
|
+
next unless inside_docs_path?(child, docs_root_real)
|
|
51
63
|
name = child.basename.to_s
|
|
52
64
|
next if modes.include?(name)
|
|
53
65
|
next if warned.include?(name)
|
|
@@ -92,7 +104,9 @@ module Markdowndocs
|
|
|
92
104
|
|
|
93
105
|
# Returns true when file_path resolves (after following symlinks) to a
|
|
94
106
|
# location inside docs_root_real. Defense against symlinks that point
|
|
95
|
-
# outside the docs tree.
|
|
107
|
+
# outside the docs tree. Callers outside this class (e.g. smart-nav in
|
|
108
|
+
# PreferencesController) use this to keep reachability checks aligned
|
|
109
|
+
# with what the show action would actually serve.
|
|
96
110
|
def self.inside_docs_path?(file_path, docs_root_real)
|
|
97
111
|
resolved = file_path.realpath
|
|
98
112
|
resolved.to_s == docs_root_real.to_s ||
|
|
@@ -100,7 +114,6 @@ module Markdowndocs
|
|
|
100
114
|
rescue Errno::ENOENT, Errno::ELOOP
|
|
101
115
|
false
|
|
102
116
|
end
|
|
103
|
-
private_class_method :inside_docs_path?
|
|
104
117
|
|
|
105
118
|
def self.by_category(category)
|
|
106
119
|
all.select { |doc| doc.category == category }
|
|
@@ -51,9 +51,19 @@ module Markdowndocs
|
|
|
51
51
|
html = apply_syntax_highlighting(html)
|
|
52
52
|
sanitize_html(html)
|
|
53
53
|
rescue => e
|
|
54
|
+
# Bare rescue is intentional: third-party errors from commonmarker,
|
|
55
|
+
# Gumbo (Nokogiri::HTML5), Rouge, and Loofah are diverse and not
|
|
56
|
+
# worth enumerating. We never want a single malformed doc — e.g.
|
|
57
|
+
# a deeply nested inline SVG — to blank-render the page. Logs
|
|
58
|
+
# carry the diagnostic; the user sees their content as text.
|
|
54
59
|
Rails.logger.error("Markdowndocs::MarkdownRenderer error: #{e.message}")
|
|
55
|
-
Rails.logger.error(e.backtrace.join("\n"))
|
|
56
|
-
|
|
60
|
+
Rails.logger.error(e.backtrace.first(20).join("\n"))
|
|
61
|
+
render_fallback(markdown)
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def render_fallback(markdown)
|
|
65
|
+
escaped = ERB::Util.html_escape(markdown.to_s)
|
|
66
|
+
%(<pre class="markdowndocs-render-error">#{escaped}</pre>)
|
|
57
67
|
end
|
|
58
68
|
|
|
59
69
|
def apply_syntax_highlighting(html)
|
|
@@ -111,17 +121,35 @@ module Markdowndocs
|
|
|
111
121
|
a img
|
|
112
122
|
strong em b i u del
|
|
113
123
|
code pre span div
|
|
124
|
+
details summary
|
|
114
125
|
].freeze
|
|
115
126
|
|
|
116
|
-
|
|
127
|
+
# ARIA labelling/role attributes are useful on any element. Adding them
|
|
128
|
+
# to BASE keeps non-SVG inline HTML accessible too (when allow_svg=true).
|
|
129
|
+
# No security risk — ARIA attributes carry no executable content.
|
|
130
|
+
BASE_SANITIZE_ATTRS = %w[
|
|
131
|
+
href title src alt align class lang
|
|
132
|
+
role aria-label aria-labelledby aria-describedby aria-hidden
|
|
133
|
+
open
|
|
134
|
+
].freeze
|
|
117
135
|
|
|
118
136
|
# Curated structural SVG subset. Deliberately excludes script,
|
|
119
137
|
# foreignObject, and SMIL animate/set tags, plus all on* handlers — the
|
|
120
138
|
# SafeListSanitizer drops anything not listed, so scripts/handlers and
|
|
121
139
|
# javascript: URIs are stripped even with unsafe HTML enabled.
|
|
140
|
+
#
|
|
141
|
+
# Note: `<title>` is NOT included. Despite appearing safe, the HTML5
|
|
142
|
+
# parser treats `<title>` as a raw-text element when encountered in
|
|
143
|
+
# HTML context, so its content escapes into the surrounding text and
|
|
144
|
+
# the `<title>` element itself is dropped. Authors who want an
|
|
145
|
+
# accessible name for an inline SVG should use:
|
|
146
|
+
#
|
|
147
|
+
# <svg role="img" aria-label="Architecture diagram">…</svg>
|
|
148
|
+
#
|
|
149
|
+
# or pair the SVG with a `<desc>` element and aria-describedby.
|
|
122
150
|
SVG_SANITIZE_TAGS = %w[
|
|
123
151
|
svg g path rect circle ellipse line polyline polygon
|
|
124
|
-
text tspan defs marker
|
|
152
|
+
text tspan defs marker desc
|
|
125
153
|
].freeze
|
|
126
154
|
|
|
127
155
|
SVG_SANITIZE_ATTRS = %w[
|
|
@@ -131,7 +159,7 @@ module Markdowndocs
|
|
|
131
159
|
transform opacity text-anchor dominant-baseline
|
|
132
160
|
font-size font-family font-weight
|
|
133
161
|
marker-start marker-end markerWidth markerHeight refX refY orient
|
|
134
|
-
|
|
162
|
+
id xmlns focusable tabindex
|
|
135
163
|
].freeze
|
|
136
164
|
|
|
137
165
|
def sanitize_html(html)
|
data/config/routes.rb
CHANGED
|
@@ -7,12 +7,15 @@ Markdowndocs::Engine.routes.draw do
|
|
|
7
7
|
# Mode-scoped doc route: matches /<mode>/<slug> where <mode> is one of
|
|
8
8
|
# the configured modes. Must come BEFORE the unconstrained :slug route
|
|
9
9
|
# so the more specific match wins.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
#
|
|
11
|
+
# The constraint reads live config so dev-reload edits to config.modes
|
|
12
|
+
# take effect without a full server restart. Proc constraints apply only
|
|
13
|
+
# to request recognition; URL generation remains permissive.
|
|
14
|
+
mode_constraint = lambda do |request|
|
|
15
|
+
mode = request.path_parameters[:mode]
|
|
16
|
+
Array(Markdowndocs.config.modes).include?(mode)
|
|
14
17
|
end
|
|
15
|
-
get ":mode/:slug", to: "docs#show", as: :scoped_doc, constraints:
|
|
18
|
+
get ":mode/:slug", to: "docs#show", as: :scoped_doc, constraints: mode_constraint
|
|
16
19
|
|
|
17
20
|
get ":slug", to: "docs#show", as: :doc
|
|
18
21
|
resource :preference, only: [:update]
|
|
@@ -5,14 +5,27 @@ Markdowndocs.configure do |config|
|
|
|
5
5
|
# config.docs_path = Rails.root.join("app", "docs")
|
|
6
6
|
|
|
7
7
|
# Category → slug mapping
|
|
8
|
-
# Maps category names to arrays of markdown file slugs (filenames without .md)
|
|
8
|
+
# Maps category names to arrays of markdown file slugs (filenames without .md).
|
|
9
|
+
# Bare slugs ("welcome") match files at app/docs/. Path-prefixed slugs
|
|
10
|
+
# ("technical/architecture") match files in mode subdirectories — see modes
|
|
11
|
+
# below.
|
|
9
12
|
config.categories = {
|
|
10
13
|
# "Getting Started" => %w[introduction quickstart],
|
|
11
14
|
# "Guides" => %w[authentication deployment],
|
|
12
|
-
# "Reference" => %w[api-reference
|
|
15
|
+
# "Reference" => %w[api-reference technical/architecture]
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
# Available documentation modes (default: %w[guide technical])
|
|
19
|
+
#
|
|
20
|
+
# Each entry in `modes` also doubles as a path-based audience scope: files
|
|
21
|
+
# under `app/docs/<mode>/` are visible ONLY in that mode and served at
|
|
22
|
+
# `/docs/<mode>/<slug>`. Files at the docs root are shared across all modes.
|
|
23
|
+
#
|
|
24
|
+
# app/docs/
|
|
25
|
+
# ├── welcome.md → shared, visible in every mode
|
|
26
|
+
# └── technical/
|
|
27
|
+
# └── architecture.md → technical mode only
|
|
28
|
+
#
|
|
16
29
|
# config.modes = %w[guide technical]
|
|
17
30
|
|
|
18
31
|
# Default mode (default: "guide")
|
|
@@ -28,6 +41,11 @@ Markdowndocs.configure do |config|
|
|
|
28
41
|
# Adds a search bar that filters docs by title, description, and content
|
|
29
42
|
# config.search_enabled = true
|
|
30
43
|
|
|
44
|
+
# Allow a curated, safe subset of inline SVG for hand-authored diagrams
|
|
45
|
+
# (default: false). Scripts, event handlers, and javascript: URIs are
|
|
46
|
+
# always stripped by the sanitizer regardless of this setting.
|
|
47
|
+
# config.allow_svg = true
|
|
48
|
+
|
|
31
49
|
# Optional: Resolve current user's mode preference from database
|
|
32
50
|
# Return nil to fall back to cookie/default
|
|
33
51
|
# config.user_mode_resolver = ->(controller) {
|
|
@@ -2,16 +2,24 @@
|
|
|
2
2
|
|
|
3
3
|
module Markdowndocs
|
|
4
4
|
class Configuration
|
|
5
|
-
|
|
5
|
+
# Route segments owned by the engine itself. A mode name matching any
|
|
6
|
+
# of these would collide with built-in routes / controller actions.
|
|
7
|
+
RESERVED_MODE_NAMES = %w[search_index preference preferences].freeze
|
|
8
|
+
|
|
9
|
+
attr_accessor :docs_path, :categories, :default_mode,
|
|
6
10
|
:markdown_options, :rouge_theme, :cache_expiry,
|
|
7
11
|
:user_mode_resolver, :user_mode_saver, :search_enabled,
|
|
8
12
|
:layout, :allow_svg
|
|
9
|
-
attr_reader :non_mode_subdirs_warned, :audience_deprecation_emitted
|
|
13
|
+
attr_reader :modes, :non_mode_subdirs_warned, :audience_deprecation_emitted
|
|
14
|
+
|
|
15
|
+
def modes=(value)
|
|
16
|
+
@modes = normalize_modes(value)
|
|
17
|
+
end
|
|
10
18
|
|
|
11
19
|
def initialize
|
|
12
20
|
@docs_path = nil # Resolved lazily so Rails.root is available
|
|
13
21
|
@categories = {}
|
|
14
|
-
|
|
22
|
+
self.modes = %w[guide technical]
|
|
15
23
|
@default_mode = "guide"
|
|
16
24
|
@markdown_options = default_markdown_options
|
|
17
25
|
@rouge_theme = "github"
|
|
@@ -36,6 +44,38 @@ module Markdowndocs
|
|
|
36
44
|
|
|
37
45
|
private
|
|
38
46
|
|
|
47
|
+
def normalize_modes(value)
|
|
48
|
+
list = Array(value).map do |entry|
|
|
49
|
+
unless entry.is_a?(String)
|
|
50
|
+
raise ArgumentError,
|
|
51
|
+
"config.modes entries must be strings; got #{entry.inspect}"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
name = entry.strip
|
|
55
|
+
|
|
56
|
+
if name.empty?
|
|
57
|
+
raise ArgumentError, "config.modes contains an invalid empty entry"
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
if name.match?(%r{[/?#&\s]})
|
|
61
|
+
raise ArgumentError,
|
|
62
|
+
"config.modes entry #{entry.inspect} is invalid — names cannot contain " \
|
|
63
|
+
"path separators, URL-significant characters, or whitespace"
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
if RESERVED_MODE_NAMES.include?(name)
|
|
67
|
+
raise ArgumentError,
|
|
68
|
+
"config.modes entry #{name.inspect} is reserved by the engine " \
|
|
69
|
+
"(conflicts with built-in route or controller). " \
|
|
70
|
+
"Reserved names: #{RESERVED_MODE_NAMES.join(", ")}"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
name
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
list.uniq
|
|
77
|
+
end
|
|
78
|
+
|
|
39
79
|
def default_markdown_options
|
|
40
80
|
{
|
|
41
81
|
parse: {
|
data/lib/markdowndocs/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: markdowndocs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dave Chmura
|
|
8
|
+
autorequire:
|
|
8
9
|
bindir: exe
|
|
9
10
|
cert_chain: []
|
|
10
|
-
date:
|
|
11
|
+
date: 2026-06-23 00:00:00.000000000 Z
|
|
11
12
|
dependencies:
|
|
12
13
|
- !ruby/object:Gem::Dependency
|
|
13
14
|
name: rails
|
|
@@ -97,15 +98,12 @@ files:
|
|
|
97
98
|
- config/importmap.rb
|
|
98
99
|
- config/locales/en.yml
|
|
99
100
|
- config/routes.rb
|
|
100
|
-
- docs/superpowers/plans/2026-05-15-path-based-audience-routing.md
|
|
101
|
-
- docs/superpowers/specs/2026-05-15-path-based-audience-routing-design.md
|
|
102
101
|
- lib/generators/markdowndocs/install/install_generator.rb
|
|
103
102
|
- lib/generators/markdowndocs/install/templates/initializer.rb
|
|
104
103
|
- lib/markdowndocs.rb
|
|
105
104
|
- lib/markdowndocs/configuration.rb
|
|
106
105
|
- lib/markdowndocs/engine.rb
|
|
107
106
|
- lib/markdowndocs/version.rb
|
|
108
|
-
- log/test.log
|
|
109
107
|
- sig/markdowndocs.rbs
|
|
110
108
|
homepage: https://github.com/dschmura/markdowndocs
|
|
111
109
|
licenses:
|
|
@@ -114,6 +112,7 @@ metadata:
|
|
|
114
112
|
homepage_uri: https://github.com/dschmura/markdowndocs
|
|
115
113
|
source_code_uri: https://github.com/dschmura/markdowndocs
|
|
116
114
|
changelog_uri: https://github.com/dschmura/markdowndocs/blob/main/CHANGELOG.md
|
|
115
|
+
post_install_message:
|
|
117
116
|
rdoc_options: []
|
|
118
117
|
require_paths:
|
|
119
118
|
- lib
|
|
@@ -128,7 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
128
127
|
- !ruby/object:Gem::Version
|
|
129
128
|
version: '0'
|
|
130
129
|
requirements: []
|
|
131
|
-
rubygems_version: 3.
|
|
130
|
+
rubygems_version: 3.4.19
|
|
131
|
+
signing_key:
|
|
132
132
|
specification_version: 4
|
|
133
133
|
summary: A drop-in markdown documentation site for Rails apps
|
|
134
134
|
test_files: []
|