markdowndocs 0.2.1 → 0.2.3
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 +9 -0
- data/app/assets/javascripts/markdowndocs/application.js +11 -0
- data/app/controllers/markdowndocs/application_controller.rb +29 -31
- data/config/importmap.rb +1 -0
- data/lib/generators/markdowndocs/install/install_generator.rb +14 -23
- data/lib/markdowndocs/engine.rb +9 -0
- data/lib/markdowndocs/version.rb +1 -1
- metadata +4 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1a94678490cfbf0ad5351412ccb04dcf9938d0bfae47184b333a18f06d8a605c
|
|
4
|
+
data.tar.gz: 9214f78fe1209a67c633909bbe8abd2e09af3fc229e3aee016cbb59604e79b77
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 24d803af2159fc9deedb4a2b681d2689b4329a88fb384391e820df9adeff787ca9c2206bfae41f511340b0b78d4c0066f1639b0f48462ab42fcb2e80b021ec90
|
|
7
|
+
data.tar.gz: '02359d490827c09532c4e063e6fc1596cbdaa89b0632404fe18d40cdb16513780f4b19029e60e9b3619174f8f3cc1f4186b91f476b7d799a3d833e41ee4f7b35'
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,14 @@ 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.2.2] - 2026-03-18
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Stimulus controllers now auto-register via a single JS entry point (`import "markdowndocs"`), following the ActionText/Trix pattern. Host apps no longer need to pin individual controllers in their importmap.
|
|
13
|
+
- Install generator adds `import "markdowndocs"` to the host app's `application.js` instead of injecting importmap pins.
|
|
14
|
+
- Added engine and generator specs for the new JS registration flow.
|
|
15
|
+
|
|
8
16
|
## [0.2.1] - 2026-02-21
|
|
9
17
|
|
|
10
18
|
### Fixed
|
|
@@ -76,6 +84,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
76
84
|
- i18n support for all UI strings
|
|
77
85
|
- Install generator (`rails generate markdowndocs:install`)
|
|
78
86
|
|
|
87
|
+
[0.2.2]: https://github.com/dschmura/markdowndocs/releases/tag/v0.2.2
|
|
79
88
|
[0.2.1]: https://github.com/dschmura/markdowndocs/releases/tag/v0.2.1
|
|
80
89
|
[0.2.0]: https://github.com/dschmura/markdowndocs/releases/tag/v0.2.0
|
|
81
90
|
[0.1.5]: https://github.com/dschmura/markdowndocs/releases/tag/v0.1.5
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import DocsSearchController from "markdowndocs/controllers/docs_search_controller"
|
|
2
|
+
import DocsModeController from "markdowndocs/controllers/docs_mode_controller"
|
|
3
|
+
|
|
4
|
+
// Auto-register if Stimulus application exists on window, otherwise
|
|
5
|
+
// the host app can import and register these controllers manually.
|
|
6
|
+
if (window.Stimulus) {
|
|
7
|
+
window.Stimulus.register("docs-search", DocsSearchController)
|
|
8
|
+
window.Stimulus.register("docs-mode", DocsModeController)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { DocsSearchController, DocsModeController }
|
|
@@ -4,37 +4,19 @@ module Markdowndocs
|
|
|
4
4
|
class ApplicationController < ::ApplicationController
|
|
5
5
|
protect_from_forgery with: :exception
|
|
6
6
|
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def root_url(*args)
|
|
23
|
-
main_app.root_url(*args)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def method_missing(method, *args, &block)
|
|
27
|
-
if main_app.respond_to?(method)
|
|
28
|
-
main_app.send(method, *args, &block)
|
|
29
|
-
else
|
|
30
|
-
super
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def respond_to_missing?(method, include_private = false)
|
|
35
|
-
main_app.respond_to?(method, include_private) || super
|
|
36
|
-
end
|
|
37
|
-
end
|
|
7
|
+
# Fix route helper isolation caused by isolate_namespace.
|
|
8
|
+
#
|
|
9
|
+
# The problem: host app route helpers (about_path, contact_path, etc.)
|
|
10
|
+
# exist in the view context but resolve against the engine's namespace,
|
|
11
|
+
# so about_path returns "/docs/about" instead of "/about".
|
|
12
|
+
#
|
|
13
|
+
# method_missing doesn't help because the methods already exist —
|
|
14
|
+
# they just resolve wrong. We need to override them explicitly.
|
|
15
|
+
#
|
|
16
|
+
# This before_action builds a helper module on first request (when
|
|
17
|
+
# routes are fully loaded) that defines every host app route helper
|
|
18
|
+
# as a delegation to main_app.
|
|
19
|
+
before_action :ensure_host_route_helpers
|
|
38
20
|
|
|
39
21
|
# Support Rails 8 built-in authentication (allow_unauthenticated_access)
|
|
40
22
|
# without requiring it — works with any auth system or none at all
|
|
@@ -44,5 +26,21 @@ module Markdowndocs
|
|
|
44
26
|
|
|
45
27
|
# Resume session if the host app supports it (Rails 8 auth)
|
|
46
28
|
before_action :resume_session, if: -> { respond_to?(:resume_session, true) }
|
|
29
|
+
|
|
30
|
+
private
|
|
31
|
+
|
|
32
|
+
def ensure_host_route_helpers
|
|
33
|
+
return if self.class.instance_variable_get(:@host_routes_delegated)
|
|
34
|
+
|
|
35
|
+
helper_module = Module.new do
|
|
36
|
+
Rails.application.routes.named_routes.names.each do |name|
|
|
37
|
+
define_method(:"#{name}_path") { |*args, **kwargs| main_app.send(:"#{name}_path", *args, **kwargs) }
|
|
38
|
+
define_method(:"#{name}_url") { |*args, **kwargs| main_app.send(:"#{name}_url", *args, **kwargs) }
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
self.class.helper(helper_module)
|
|
43
|
+
self.class.instance_variable_set(:@host_routes_delegated, true)
|
|
44
|
+
end
|
|
47
45
|
end
|
|
48
46
|
end
|
data/config/importmap.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
# Importmap pins for Markdowndocs engine.
|
|
4
4
|
# These are automatically registered with the host app when importmap-rails is present.
|
|
5
5
|
|
|
6
|
+
pin "markdowndocs", to: "markdowndocs/application.js"
|
|
6
7
|
pin "markdowndocs/controllers/docs_search_controller", to: "markdowndocs/controllers/docs_search_controller.js"
|
|
7
8
|
pin "markdowndocs/controllers/docs_mode_controller", to: "markdowndocs/controllers/docs_mode_controller.js"
|
|
8
9
|
pin "minisearch", to: "markdowndocs/vendor/minisearch.min.js"
|
|
@@ -20,25 +20,18 @@ module Markdowndocs
|
|
|
20
20
|
route 'mount Markdowndocs::Engine, at: "/docs"'
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
def
|
|
24
|
-
|
|
25
|
-
return unless File.exist?(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
pins.each do |pin_line, name|
|
|
36
|
-
if importmap_content.include?(pin_line)
|
|
37
|
-
say_status :skip, "importmap pin for #{name} already present", :yellow
|
|
38
|
-
else
|
|
39
|
-
append_to_file importmap_file, "\n#{pin_line}\n"
|
|
40
|
-
say_status :pin, name, :green
|
|
41
|
-
end
|
|
23
|
+
def add_markdowndocs_import
|
|
24
|
+
js_file = Rails.root.join("app/javascript/application.js").to_s
|
|
25
|
+
return unless File.exist?(js_file)
|
|
26
|
+
|
|
27
|
+
js_content = File.read(js_file)
|
|
28
|
+
import_line = 'import "markdowndocs"'
|
|
29
|
+
|
|
30
|
+
if js_content.include?(import_line)
|
|
31
|
+
say_status :skip, "markdowndocs import already present in application.js", :yellow
|
|
32
|
+
else
|
|
33
|
+
append_to_file js_file, "\n#{import_line}\n"
|
|
34
|
+
say_status :import, "markdowndocs in application.js", :green
|
|
42
35
|
end
|
|
43
36
|
end
|
|
44
37
|
|
|
@@ -76,10 +69,8 @@ module Markdowndocs
|
|
|
76
69
|
say " @source \"#{Markdowndocs::Engine.root.join("app", "views")}/**/*.erb\";"
|
|
77
70
|
say ""
|
|
78
71
|
end
|
|
79
|
-
say " Stimulus controllers are auto-registered via
|
|
80
|
-
say " If
|
|
81
|
-
say " - markdowndocs/controllers/docs_mode_controller"
|
|
82
|
-
say " - markdowndocs/controllers/docs_search_controller (when search is enabled)"
|
|
72
|
+
say " Stimulus controllers are auto-registered via: import \"markdowndocs\"", :green
|
|
73
|
+
say " If this was not added automatically, add it to app/javascript/application.js"
|
|
83
74
|
say ""
|
|
84
75
|
end
|
|
85
76
|
|
data/lib/markdowndocs/engine.rb
CHANGED
|
@@ -19,5 +19,14 @@ module Markdowndocs
|
|
|
19
19
|
app.config.importmap.paths << root.join("config/importmap.rb")
|
|
20
20
|
end
|
|
21
21
|
end
|
|
22
|
+
|
|
23
|
+
initializer "markdowndocs.stimulus" do
|
|
24
|
+
Rails.application.config.after_initialize do
|
|
25
|
+
if defined?(Importmap)
|
|
26
|
+
# The pin is already added via importmap.rb
|
|
27
|
+
# Host app just needs: import "markdowndocs" in their application.js
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
22
31
|
end
|
|
23
32
|
end
|
data/lib/markdowndocs/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: markdowndocs
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dave Chmura
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: exe
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rails
|
|
@@ -78,6 +77,7 @@ files:
|
|
|
78
77
|
- CHANGELOG.md
|
|
79
78
|
- README.md
|
|
80
79
|
- Rakefile
|
|
80
|
+
- app/assets/javascripts/markdowndocs/application.js
|
|
81
81
|
- app/assets/javascripts/markdowndocs/controllers/docs_mode_controller.js
|
|
82
82
|
- app/assets/javascripts/markdowndocs/controllers/docs_search_controller.js
|
|
83
83
|
- app/assets/javascripts/markdowndocs/vendor/minisearch.min.js
|
|
@@ -111,7 +111,6 @@ metadata:
|
|
|
111
111
|
homepage_uri: https://github.com/dschmura/markdowndocs
|
|
112
112
|
source_code_uri: https://github.com/dschmura/markdowndocs
|
|
113
113
|
changelog_uri: https://github.com/dschmura/markdowndocs/blob/main/CHANGELOG.md
|
|
114
|
-
post_install_message:
|
|
115
114
|
rdoc_options: []
|
|
116
115
|
require_paths:
|
|
117
116
|
- lib
|
|
@@ -126,8 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
126
125
|
- !ruby/object:Gem::Version
|
|
127
126
|
version: '0'
|
|
128
127
|
requirements: []
|
|
129
|
-
rubygems_version: 3.
|
|
130
|
-
signing_key:
|
|
128
|
+
rubygems_version: 3.6.9
|
|
131
129
|
specification_version: 4
|
|
132
130
|
summary: A drop-in markdown documentation site for Rails apps
|
|
133
131
|
test_files: []
|