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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7490903924197e3ee4eff1894ade54c6c7c21537816a4b634302900736dfe6c8
4
- data.tar.gz: 46e30d39c620d14dbc2a420654d026e7fa0a290ede2eb36e2540c33ac8117178
3
+ metadata.gz: 1653429aed4ce0456d7df0c26da4d8ccdde41967cfd91ab2824c24c5da7dc975
4
+ data.tar.gz: a22e7b188e50c419cf7160dbc2c2b32160320ca46015306cf19e08efde37dc11
5
5
  SHA512:
6
- metadata.gz: 00ccad038240b21408c3adf4360db50e8edcb90554573f5305837cb139c621d272c842622b925c03f689eaabaff30b661548c67cddece8cc9c2609dd96bbe7e0
7
- data.tar.gz: bc2eccd08b28280f4ee6ff178b5f9dde689c64cddab2df9a4954702f3dbebf5e3e8f35044b7960f1f958919207f10ab9c683081fab8edfab714b51ad94627176
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 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
 
@@ -26,7 +26,15 @@ Then run `bundle install`.
26
26
 
27
27
  ## Usage
28
28
 
29
- ### 1. Puma Plugin (Development Watch Mode)
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
- Docs are served at `/doc/index.html` via Rails' `public/` directory.
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("public", "doc"))
70
- # 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")
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 `public/doc/`
82
- 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`)
83
89
  5. Clean subprocess management with bidirectional lifecycle monitoring (Puma ↔ SDoc)
84
90
 
85
91
  ## License
@@ -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
@@ -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.5"
3
+ VERSION = "0.1.7"
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.5
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - 16554289+optimuspwnius@users.noreply.github.com