sdoc_live 0.1.9 → 0.1.11
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/README.md +6 -11
- data/lib/sdoc_live/engine.rb +10 -18
- data/lib/sdoc_live/version.rb +1 -1
- data/lib/sdoc_live.rb +2 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2632d4b9ea967fd91af45d93010c1f507813c88ed9665a1592ff9667fd65d300
|
|
4
|
+
data.tar.gz: 5160265deb94355bf35d442f192cc2917f4900e887e69911039755af4135508a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ab62868d6ea0993036eb970cee004df241813b6b7183784893a329774238496045e9f5af87fe747015bb302d733e0c6b638a105c8d0e32562934037a914f4a95
|
|
7
|
+
data.tar.gz: 3c864f88b8eebe761424c695ee85ba0bad5659e51ee3e5bc38d5fdbaa16a929f085cb2c5a7df572d161ba64ce71a635d1a186c732ddfc045183b369c5604fc83
|
data/README.md
CHANGED
|
@@ -26,15 +26,7 @@ Then run `bundle install`.
|
|
|
26
26
|
|
|
27
27
|
## Usage
|
|
28
28
|
|
|
29
|
-
### 1.
|
|
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
|
-
###
|
|
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
|
|
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
|
data/lib/sdoc_live/engine.rb
CHANGED
|
@@ -7,34 +7,34 @@ module SdocLive
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
initializer "sdoc_live.static" do
|
|
10
|
-
|
|
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
|
-
|
|
14
|
+
Rails.application.middleware.insert_before(Rails::Rack::Logger, 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")
|
data/lib/sdoc_live/version.rb
CHANGED
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
|