markdowndocs 0.2.1 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cebbfbc9bd8562902775c6661f2241c7c5556b1ccecdc4cc6b993804d4c58e02
4
- data.tar.gz: af7ab61db222e6dbd9dbecb557cc713068809fdd26604ed629c7b6a49c122e42
3
+ metadata.gz: a6f2f9ae54ee9769434428aec5808626c4bcc08a55137c339c9310df30fe5973
4
+ data.tar.gz: c8e029017e1b6739c2b3f2740a016bdf42ff02e87d5935330601ea5f6bd2fb0e
5
5
  SHA512:
6
- metadata.gz: 5389780ce9d8ad500df799b93bc5790cbca71651f2d320249be1d77cccb85124a484fc519c889e3fd2d8a8d1ec4458d9b65ba0925e706af2835261468e65bbdf
7
- data.tar.gz: 9ccbdda3525cc1bd2268214dd684643d5c200da356495cdeeb8f99fa364bee4615910ad20334ee943dd95b75502bc20afb8a5888ab95ed7f45cb0baa0b92804e
6
+ metadata.gz: 751e5771036b40187003bbbdeaa0fc9ed27142b9d3e542a1e712d74b9f02ac174e82ae8f9ebb1a32b29b42fe3083c2990c746a92aac04fb50a31914a638bb66d
7
+ data.tar.gz: 22e8544a817e4402d071163c5fc809f316d90a13f7239f50d37e6d3756fd182535f869af85f34d594b94a566445ca799092fc2f0e6558b088b7749384a50fcf7
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 }
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 pin_importmap_assets
24
- importmap_file = Rails.root.join("config/importmap.rb").to_s
25
- return unless File.exist?(importmap_file)
26
-
27
- importmap_content = File.read(importmap_file)
28
-
29
- pins = {
30
- 'pin "markdowndocs/controllers/docs_search_controller", to: "markdowndocs/controllers/docs_search_controller.js"' => "docs_search_controller",
31
- 'pin "markdowndocs/controllers/docs_mode_controller", to: "markdowndocs/controllers/docs_mode_controller.js"' => "docs_mode_controller",
32
- 'pin "minisearch", to: "markdowndocs/vendor/minisearch.min.js"' => "minisearch"
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 importmap.", :green
80
- say " If you use a custom Stimulus setup, register these controllers:"
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
 
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Markdowndocs
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: markdowndocs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dave Chmura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2026-02-21 00:00:00.000000000 Z
11
+ date: 2026-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -78,6 +78,7 @@ files:
78
78
  - CHANGELOG.md
79
79
  - README.md
80
80
  - Rakefile
81
+ - app/assets/javascripts/markdowndocs/application.js
81
82
  - app/assets/javascripts/markdowndocs/controllers/docs_mode_controller.js
82
83
  - app/assets/javascripts/markdowndocs/controllers/docs_search_controller.js
83
84
  - app/assets/javascripts/markdowndocs/vendor/minisearch.min.js