sdoc_live 0.1.6 → 0.1.8

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: 0d49bec64da362efab6cc71f5ab722679479610f07830183eaea7d5155ffa76e
4
- data.tar.gz: 1ce67dcb81729bc112d383bfa48df0160300ab9ffc02e702486df9b0fa26a667
3
+ metadata.gz: 2c58eaf82f18b4feb7c431156e8ba8be018e22eb57b8b62d69e0e0c503e2085c
4
+ data.tar.gz: 372965feda50bdc4bc08b196d3acbbc43af6fe2b7fb4461b622bbb4f80c0befa
5
5
  SHA512:
6
- metadata.gz: 6cb026920418d5effac5b16378160f5bc4e6c5a101083c6f920a8d3eff6d2f89214d396cde03309001137609cd97e9b47b930c7c4157bac94dc01f3dd4e5c301
7
- data.tar.gz: aa5556dced2d25c494c12373817d4ecc498ca751647215ffc0bf5894f1170d39a25edb82b175bb43fc933c71846919cdd99bd313dd70fad8fe0bad51d9ef1b59
6
+ metadata.gz: 224cc2e187603628bb1e76664ef87ff8f6c33640d34512d38e7f262b1e96490a3e05dc07ed2cc08f78e372adf8a016bae6c55199f2a9de3c57ebbcc1ea2e5bfb
7
+ data.tar.gz: dc1222d122c5992e1e9505e752305a28b164b0d55dff3bbdc3f3b19aae4d630c76d6940be15fd45201426e1c548172bea7722b61cf6f3f95eb4ffec2ef02c2f2
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # SDoc Live
2
2
 
3
- Live SDoc generation for Rails — watches your source files and auto-regenerates API documentation on changes. Serves docs from `public/doc/` so they're available at `/doc/index.html` in development.
3
+ Live SDoc generation for Rails — watches your source files and auto-regenerates API documentation on changes. Serves docs via a mountable engine at a path you choose (e.g. `/doc`).
4
4
 
5
5
  ## Requirements
6
6
 
@@ -72,8 +72,8 @@ SdocLive.configure do |config|
72
72
  # Regex for file types that trigger regeneration (default: /\.rb$/)
73
73
  # config.watch_file_type_regex = /\.(rb|md)$/
74
74
 
75
- # Override the output directory (default: Rails.root.join("public", "doc"))
76
- # config.output_dir = Rails.root.join("public", "doc")
75
+ # Override the output directory (default: Rails.root.join("tmp", "doc"))
76
+ # config.output_dir = Rails.root.join("tmp", "doc")
77
77
 
78
78
  # Additional RDoc options passed to the SDoc generator
79
79
  # config.rdoc_options = ["--all", "--hyperlink-all"]
@@ -84,8 +84,8 @@ end if defined?(SdocLive)
84
84
 
85
85
  1. **Development**: Puma boots → forks a child process that runs `SdocLive::Generator#build_watch`
86
86
  2. The `listen` gem monitors `app/` and `lib/` for `.rb` file changes
87
- 3. On change, SDoc regenerates documentation into `public/doc/`
88
- 4. Docs are immediately available at `/doc/index.html`
87
+ 3. On change, SDoc regenerates documentation into `tmp/doc/`
88
+ 4. Docs are served by the mounted engine (e.g. at `/doc`)
89
89
  5. Clean subprocess management with bidirectional lifecycle monitoring (Puma ↔ SDoc)
90
90
 
91
91
  ## License
@@ -7,7 +7,7 @@ module SdocLive
7
7
  end
8
8
 
9
9
  initializer "sdoc_live.static" do |app|
10
- doc_root = (SdocLive.configuration.output_dir || app.root.join("public", "doc")).to_s
10
+ doc_root = (SdocLive.configuration.output_dir || app.root.join("tmp", "doc")).to_s
11
11
 
12
12
  SdocLive::Engine.routes.draw do
13
13
  doc_app = ::Rack::Static.new(
@@ -21,6 +21,32 @@ module SdocLive
21
21
  end
22
22
  end
23
23
 
24
+ initializer "sdoc_live.trailing_slash", after: :add_routing_paths do |app|
25
+ mount_path = nil
26
+
27
+ app.routes.routes.each do |route|
28
+ if route.app.respond_to?(:app) && route.app.app == SdocLive::Engine
29
+ mount_path = route.path.spec.to_s.gsub("(.:format)", "").chomp("/")
30
+ break
31
+ end
32
+ end
33
+
34
+ if mount_path && !mount_path.empty?
35
+ app.middleware.use(Class.new do
36
+ define_method(:initialize) { |a| @app = a }
37
+
38
+ define_method(:call) do |env|
39
+ if env["PATH_INFO"] == mount_path && !env["PATH_INFO"].end_with?("/")
40
+ query = env["QUERY_STRING"].to_s.empty? ? "" : "?#{ env['QUERY_STRING'] }"
41
+ [301, { "location" => "#{ mount_path }/#{ query }", "content-type" => "text/html" }, ["Redirecting..."]]
42
+ else
43
+ @app.call(env)
44
+ end
45
+ end
46
+ end)
47
+ end
48
+ end
49
+
24
50
  end
25
51
 
26
52
  end
@@ -10,7 +10,7 @@ module SdocLive
10
10
 
11
11
  config = SdocLive.configuration
12
12
 
13
- @output_dir = config.output_dir || @root.join("public", "doc")
13
+ @output_dir = config.output_dir || @root.join("tmp", "doc")
14
14
  @title = config.title
15
15
  @main_file = config.main_file
16
16
 
@@ -1,5 +1,5 @@
1
1
  module SdocLive
2
2
 
3
- VERSION = "0.1.6"
3
+ VERSION = "0.1.8"
4
4
 
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sdoc_live
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - 16554289+optimuspwnius@users.noreply.github.com