sdoc_live 0.1.9 → 0.1.10

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: c308a3b0c63dae1cd0325824aecadac55373be489c0371d7a00710129527533e
4
- data.tar.gz: c69d278e885d057d746c433431333a10bd34e9595e9b881a99c8ebe38569914f
3
+ metadata.gz: 01316e7563fe0c297ff8ee3304b86fcab074251063ab2c503369a8288362210c
4
+ data.tar.gz: d4d839d93250944f290f0157282213c8888daf1c4bfbb2872c17b0ff1034b0b7
5
5
  SHA512:
6
- metadata.gz: f82f91308407a7a993f5fd58bfaf26490e02ad7ee91edfa7d5065faea40411638c461011820efa61f1939bf671915f2de5297bf5fdad9868a0e7fa45ad56b0e9
7
- data.tar.gz: 0c0930e0ab7c5196057648904952eadbd8674abd79a2972081b0d0ed698128e01b70c0a4a6ecb4b4490a2061bbdd3d059fe7a458c9c3d49af3cc5e08a5047f82
6
+ metadata.gz: 0fed3626046989a0448f0368d0d3d65d3889e82ec71cb43775969e832824f156dc773f25b2c9a0e7c92c284f6d76227045fc46e8bbd4e6052f397f99c1cbbf15
7
+ data.tar.gz: 7b73e3fe0c6aecc0414120f1af80e4e92ecde9ddc314939ce3165ace61398c31d5a2f85238aec220395b2bd57ed78c4f3e949862eb0d5b85841fd163ead4af75
data/README.md CHANGED
@@ -26,15 +26,7 @@ Then run `bundle install`.
26
26
 
27
27
  ## Usage
28
28
 
29
- ### 1. Mount the Engine
30
-
31
- Add to your `config/routes.rb`:
32
-
33
- ```ruby
34
- mount SdocLive::Engine, at: "/doc"
35
- ```
36
-
37
- ### 2. Puma Plugin (Development Watch Mode)
29
+ ### 1. Puma Plugin (Development Watch Mode)
38
30
 
39
31
  Add to your `config/puma.rb`:
40
32
 
@@ -46,7 +38,7 @@ end
46
38
 
47
39
  This watches `app/` and `lib/` for `.rb` file changes and automatically regenerates SDoc documentation.
48
40
 
49
- ### 3. Rake Task (Manual / Deploy)
41
+ ### 2. Rake Task (Manual / Deploy)
50
42
 
51
43
  ```bash
52
44
  rake sdoc:build
@@ -77,6 +69,9 @@ SdocLive.configure do |config|
77
69
 
78
70
  # Additional RDoc options passed to the SDoc generator
79
71
  # config.rdoc_options = ["--all", "--hyperlink-all"]
72
+
73
+ # URL path where documentation is served (default: "/doc")
74
+ # config.mount_path = "/doc"
80
75
  end if defined?(SdocLive)
81
76
  ```
82
77
 
@@ -85,7 +80,7 @@ end if defined?(SdocLive)
85
80
  1. **Development**: Puma boots → forks a child process that runs `SdocLive::Generator#build_watch`
86
81
  2. The `listen` gem monitors `app/` and `lib/` for `.rb` file changes
87
82
  3. On change, SDoc regenerates documentation into `tmp/doc/`
88
- 4. Docs are served by the mounted engine (e.g. at `/doc`)
83
+ 4. Docs are served via middleware at the configured `mount_path` (default: `/doc`)
89
84
  5. Clean subprocess management with bidirectional lifecycle monitoring (Puma ↔ SDoc)
90
85
 
91
86
  ## License
@@ -7,34 +7,34 @@ module SdocLive
7
7
  end
8
8
 
9
9
  initializer "sdoc_live.static" do
10
- doc_root = (SdocLive.configuration.output_dir || Rails.root.join("tmp", "doc")).to_s
10
+ config = SdocLive.configuration
11
+ doc_root = (config.output_dir || Rails.root.join("tmp", "doc")).to_s
12
+ mount_path = config.mount_path
11
13
 
12
- config.middleware.use(SdocLive::StaticFiles, doc_root)
14
+ app.middleware.use(SdocLive::StaticFiles, doc_root, mount_path)
13
15
  end
14
16
 
15
17
  end
16
18
 
17
19
  class StaticFiles
18
20
 
19
- def initialize(app, doc_root)
21
+ def initialize(app, doc_root, mount_path)
20
22
  @app = app
21
23
  @doc_root = doc_root
24
+ @mount_path = mount_path.chomp("/")
22
25
  end
23
26
 
24
27
  def call(env)
25
- mount_path = find_mount_path(env)
26
- return @app.call(env) unless mount_path
27
-
28
28
  path_info = env["PATH_INFO"]
29
29
 
30
- if path_info == mount_path
30
+ if path_info == @mount_path
31
31
  query = env["QUERY_STRING"].to_s.empty? ? "" : "?#{ env['QUERY_STRING'] }"
32
- return [301, { "location" => "#{ mount_path }/#{ query }" }, []]
32
+ return [301, { "location" => "#{ @mount_path }/#{ query }" }, []]
33
33
  end
34
34
 
35
- return @app.call(env) unless path_info.start_with?("#{ mount_path }/")
35
+ return @app.call(env) unless path_info.start_with?("#{ @mount_path }/")
36
36
 
37
- relative_path = path_info.delete_prefix(mount_path)
37
+ relative_path = path_info.delete_prefix(@mount_path)
38
38
  relative_path = "/index.html" if relative_path == "/"
39
39
 
40
40
  file_path = File.join(@doc_root, relative_path)
@@ -49,14 +49,6 @@ module SdocLive
49
49
 
50
50
  private
51
51
 
52
- def find_mount_path(env)
53
- @mount_path ||= begin
54
- routes = Rails.application.routes.routes
55
- route = routes.detect { |r| r.app.respond_to?(:app) && r.app.app == SdocLive::Engine }
56
- route&.path&.spec&.to_s&.gsub("(.:format)", "")&.chomp("/")
57
- end
58
- end
59
-
60
52
  def serve_file(path)
61
53
  content_type = Rack::Mime.mime_type(File.extname(path), "application/octet-stream")
62
54
  body = File.read(path, mode: "rb")
@@ -1,5 +1,5 @@
1
1
  module SdocLive
2
2
 
3
- VERSION = "0.1.9"
3
+ VERSION = "0.1.10"
4
4
 
5
5
  end
data/lib/sdoc_live.rb CHANGED
@@ -19,13 +19,14 @@ module SdocLive
19
19
  class Configuration
20
20
 
21
21
  attr_accessor :output_dir, :title, :main_file, :source_dirs, :watch_dirs,
22
- :watch_file_type_regex, :rdoc_options
22
+ :watch_file_type_regex, :rdoc_options, :mount_path
23
23
 
24
24
  def initialize
25
25
  @source_dirs = ["app", "lib"]
26
26
  @watch_file_type_regex = /\.rb$/
27
27
  @title = "Documentation"
28
28
  @main_file = "README.md"
29
+ @mount_path = "/doc"
29
30
  end
30
31
 
31
32
  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.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - 16554289+optimuspwnius@users.noreply.github.com