sdoc_live 0.1.5 → 0.1.7
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 +15 -9
- data/lib/sdoc_live/engine.rb +31 -0
- data/lib/sdoc_live/generator.rb +1 -1
- data/lib/sdoc_live/version.rb +1 -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: 1653429aed4ce0456d7df0c26da4d8ccdde41967cfd91ab2824c24c5da7dc975
|
|
4
|
+
data.tar.gz: a22e7b188e50c419cf7160dbc2c2b32160320ca46015306cf19e08efde37dc11
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4c592cd42c497602bbb49b90e9f1603c407139e8c00e0f093f26bfc412a5c160b1de729ce70c4db14a5efbe89967e51eceda9bca695273f7e252c83e6dfd639a
|
|
7
|
+
data.tar.gz: 87c2c8adc1768ed43cba4aad88b425a16279920893ab5e326c63555e5653c1bce416980d868eb1e17d52162277ce80bc009466df465e38743ba266f8c081df79
|
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
|
|
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
|
|
|
@@ -26,7 +26,15 @@ Then run `bundle install`.
|
|
|
26
26
|
|
|
27
27
|
## Usage
|
|
28
28
|
|
|
29
|
-
### 1.
|
|
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)
|
|
30
38
|
|
|
31
39
|
Add to your `config/puma.rb`:
|
|
32
40
|
|
|
@@ -38,9 +46,7 @@ end
|
|
|
38
46
|
|
|
39
47
|
This watches `app/` and `lib/` for `.rb` file changes and automatically regenerates SDoc documentation.
|
|
40
48
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
### 2. Rake Task (Manual / Deploy)
|
|
49
|
+
### 3. Rake Task (Manual / Deploy)
|
|
44
50
|
|
|
45
51
|
```bash
|
|
46
52
|
rake sdoc:build
|
|
@@ -66,8 +72,8 @@ SdocLive.configure do |config|
|
|
|
66
72
|
# Regex for file types that trigger regeneration (default: /\.rb$/)
|
|
67
73
|
# config.watch_file_type_regex = /\.(rb|md)$/
|
|
68
74
|
|
|
69
|
-
# Override the output directory (default: Rails.root.join("
|
|
70
|
-
# config.output_dir = Rails.root.join("
|
|
75
|
+
# Override the output directory (default: Rails.root.join("tmp", "doc"))
|
|
76
|
+
# config.output_dir = Rails.root.join("tmp", "doc")
|
|
71
77
|
|
|
72
78
|
# Additional RDoc options passed to the SDoc generator
|
|
73
79
|
# config.rdoc_options = ["--all", "--hyperlink-all"]
|
|
@@ -78,8 +84,8 @@ end if defined?(SdocLive)
|
|
|
78
84
|
|
|
79
85
|
1. **Development**: Puma boots → forks a child process that runs `SdocLive::Generator#build_watch`
|
|
80
86
|
2. The `listen` gem monitors `app/` and `lib/` for `.rb` file changes
|
|
81
|
-
3. On change, SDoc regenerates documentation into `
|
|
82
|
-
4. Docs are
|
|
87
|
+
3. On change, SDoc regenerates documentation into `tmp/doc/`
|
|
88
|
+
4. Docs are served by the mounted engine (e.g. at `/doc`)
|
|
83
89
|
5. Clean subprocess management with bidirectional lifecycle monitoring (Puma ↔ SDoc)
|
|
84
90
|
|
|
85
91
|
## License
|
data/lib/sdoc_live/engine.rb
CHANGED
|
@@ -6,6 +6,37 @@ module SdocLive
|
|
|
6
6
|
load File.expand_path("../tasks/sdoc_live.rake", __dir__)
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
+
initializer "sdoc_live.static" do |app|
|
|
10
|
+
doc_root = (SdocLive.configuration.output_dir || app.root.join("tmp", "doc")).to_s
|
|
11
|
+
|
|
12
|
+
SdocLive::Engine.routes.draw do
|
|
13
|
+
doc_app = ::Rack::Static.new(
|
|
14
|
+
->(_) { [404, { "content-type" => "text/plain" }, ["Not Found"]] },
|
|
15
|
+
urls: ["/"],
|
|
16
|
+
root: doc_root,
|
|
17
|
+
index: "index.html"
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
mount doc_app, at: "/"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
initializer "sdoc_live.trailing_slash" do
|
|
25
|
+
SdocLive::Engine.middleware.use(Class.new do
|
|
26
|
+
def initialize(app)
|
|
27
|
+
@app = app
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def call(env)
|
|
31
|
+
if env["PATH_INFO"] == ""
|
|
32
|
+
[301, { "location" => "#{ env['SCRIPT_NAME'] }/", "content-type" => "text/html" }, ["Redirecting..."]]
|
|
33
|
+
else
|
|
34
|
+
@app.call(env)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end)
|
|
38
|
+
end
|
|
39
|
+
|
|
9
40
|
end
|
|
10
41
|
|
|
11
42
|
end
|
data/lib/sdoc_live/generator.rb
CHANGED
data/lib/sdoc_live/version.rb
CHANGED