rdoc-markdown 0.5.0 → 0.6.0

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: df1f3da8afd7010551e9edbaf2f33de617d63584760e3c59120c6f3b38232f19
4
- data.tar.gz: 82b591023300cf619230ef8786b3ae10ed3cb5d2aadae9afcd43b5da4c0528b7
3
+ metadata.gz: 87cca03aa4d398385640d41bb6373d6607885593855cc7753253ce3453b92cbd
4
+ data.tar.gz: 230d405d4b7feca88a1b5fd3baab2ab707d3cd24628a8a9cd6706cbe8b7b45dd
5
5
  SHA512:
6
- metadata.gz: ac5335f705812d01d5bd24488cda5fb77ce69f8fa6b32677b13f048aab476062c0845681324f3b05de9c0965bbcc2c0f1c64dbb5e4f58dc5ee8a8c4a8906dd33
7
- data.tar.gz: b682c9b99cace11662bff88be24560b370a2b8a084ec9fac47a854e90a0bfdfafd246e4c62d9c84055c426bcaf3572d1f69bb2e0d02aacc838a7be46e6da8b01
6
+ metadata.gz: 3a5829cb97da49560f0aebd62f4e405a59ba7ad9a8ca4a9d1ac43aa4c6cc13189230630828b962d12124bc4a7544cb314f82cf9baeae73f25ba0700639802249
7
+ data.tar.gz: 8a47baf609af1888fd049294cfe4c3f97a0e65f1f80d19f013acf42a482db57c89f5a38b854eb6cf2e4b594fa9c9fc515e7e428144827856b236d9d25699da60
data/Gemfile.lock CHANGED
@@ -1,50 +1,55 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rdoc-markdown (0.5.0)
4
+ rdoc-markdown (0.6.0)
5
5
  csv
6
6
  erb
7
7
  rdoc
8
8
  reverse_markdown
9
- unindent
10
9
 
11
10
  GEM
12
11
  remote: https://rubygems.org/
13
12
  specs:
14
- cgi (0.4.1)
15
- csv (3.3.2)
16
- date (3.4.1)
17
- erb (4.0.4)
18
- cgi (>= 0.3.3)
19
- minitest (5.25.4)
20
- nokogiri (1.18.0-aarch64-linux-gnu)
13
+ commonmarker (2.6.3-aarch64-linux)
14
+ commonmarker (2.6.3-arm-linux)
15
+ commonmarker (2.6.3-arm64-darwin)
16
+ commonmarker (2.6.3-x86_64-darwin)
17
+ commonmarker (2.6.3-x86_64-linux)
18
+ commonmarker (2.6.3-x86_64-linux-musl)
19
+ csv (3.3.5)
20
+ date (3.5.1)
21
+ erb (6.0.1)
22
+ minitest (5.27.0)
23
+ nokogiri (1.19.0-aarch64-linux-gnu)
21
24
  racc (~> 1.4)
22
- nokogiri (1.18.0-aarch64-linux-musl)
25
+ nokogiri (1.19.0-aarch64-linux-musl)
23
26
  racc (~> 1.4)
24
- nokogiri (1.18.0-arm-linux-gnu)
27
+ nokogiri (1.19.0-arm-linux-gnu)
25
28
  racc (~> 1.4)
26
- nokogiri (1.18.0-arm-linux-musl)
29
+ nokogiri (1.19.0-arm-linux-musl)
27
30
  racc (~> 1.4)
28
- nokogiri (1.18.0-arm64-darwin)
31
+ nokogiri (1.19.0-arm64-darwin)
29
32
  racc (~> 1.4)
30
- nokogiri (1.18.0-x86_64-darwin)
33
+ nokogiri (1.19.0-x86_64-darwin)
31
34
  racc (~> 1.4)
32
- nokogiri (1.18.0-x86_64-linux-gnu)
35
+ nokogiri (1.19.0-x86_64-linux-gnu)
33
36
  racc (~> 1.4)
34
- nokogiri (1.18.0-x86_64-linux-musl)
37
+ nokogiri (1.19.0-x86_64-linux-musl)
35
38
  racc (~> 1.4)
36
- psych (5.2.2)
39
+ psych (5.3.1)
37
40
  date
38
41
  stringio
39
42
  racc (1.8.1)
40
- rake (13.2.1)
43
+ rake (13.3.1)
41
44
  rdiscount (2.2.7.3)
42
- rdoc (6.10.0)
45
+ rdoc (7.2.0)
46
+ erb
43
47
  psych (>= 4.0.0)
44
- reverse_markdown (3.0.0)
48
+ tsort
49
+ reverse_markdown (3.0.2)
45
50
  nokogiri
46
- stringio (3.1.2)
47
- unindent (1.0)
51
+ stringio (3.2.0)
52
+ tsort (0.2.0)
48
53
 
49
54
  PLATFORMS
50
55
  aarch64-linux-gnu
@@ -58,6 +63,7 @@ PLATFORMS
58
63
 
59
64
  DEPENDENCIES
60
65
  bundler (~> 2.0)
66
+ commonmarker
61
67
  minitest (~> 5.0)
62
68
  rake (~> 13.0)
63
69
  rdiscount (~> 2.0)
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # RDoc-Markdown
2
- RDoc plugin to generate markdown documentation and search index backed by sqlite database.
2
+ RDoc plugin to generate markdown documentation and search index file (CSV).
3
+
4
+ ## Motivation
5
+ Markdown has become the de-facto documentation standard. I heavily rely on Obsidian to render my storage of markdown notes. But markdown is used not just for scribbles, supported is far and wide. We can render markdown file on any device, probably even on thermometer with a screen. But also everyone knows enough markdown to be dangerous (or productive).
6
+
7
+ It's a pitty that rdoc and yard can't output a proper markdown file. I would like to change that.
3
8
 
4
9
  ## Installation
5
10
 
@@ -23,6 +28,13 @@ Run following command in directory with ruby source code:
23
28
 
24
29
  This will produce a tree of markdown documents and search index in `/doc` folder. Every class in library will have it's own markdown file.
25
30
 
31
+ ## Note on index.csv file
32
+ This gem emits index of all markdown files in a index.csv file.
33
+
34
+ There are decent tools that offer search through structured plain-text files. But my expectation is that nobody will use CSV as an actual search index, but rather import it into something that performs this function better.
35
+
36
+ In my personal use-case, I use SQLite. All other databases seem to have a good support for CSV imports.
37
+
26
38
  ## Development
27
39
  Biggest issue is testing this locally, but that's not as hard to do these days.
28
40
 
@@ -46,6 +58,65 @@ Following command should run entire testsuit:
46
58
  rake test
47
59
  ```
48
60
  Testing is not excessive, just verifies that basic functionality is operational.
61
+
62
+ To validate generated markdown against GitHub Flavored Markdown and check local links/anchors:
63
+
64
+ ```
65
+ rake markdown:validate
66
+ ```
67
+
68
+ This task validates:
69
+
70
+ - generated sample docs,
71
+ - checked-in `example/` docs,
72
+ - vendored minitest docs,
73
+ - vendored rails docs (Active Support, Active Record, Action Pack, Railties slices).
74
+
75
+ Validation artifacts are written to `tmp/markdown-validate/` inside this repository.
76
+ To fail on every unresolved vendor local link/anchor, run with:
77
+
78
+ ```
79
+ MARKDOWN_VALIDATE_STRICT_VENDOR=1 rake markdown:validate
80
+ ```
81
+
82
+ This task is also executed in CI.
83
+
84
+ ### Integration harness: minitest
85
+ To run the integration harness against minitest (aligned with docs.seattlerb.org/minitest):
86
+
87
+ ```
88
+ rake vendor:setup:minitest
89
+ bundle exec rake test
90
+ ```
91
+
92
+ The harness validates markdown formatting quality, generated page files, class/module paths, and search index output.
93
+
94
+ ### Integration harness: rails
95
+ To run the rails harness (focused on Active Support + Active Record API docs with sdoc-like structure):
96
+
97
+ ```
98
+ rake vendor:setup:rails
99
+ bundle exec rake test
100
+ ```
101
+
102
+ The rails harness validates alias rendering, preserved code blocks, file/page links rewritten to markdown, and index stability (no synthetic nested class names).
103
+
104
+ ### Generate vendored docs
105
+ Use rake tasks to generate markdown output for vendored projects:
106
+
107
+ ```
108
+ rake vendor:setup
109
+ rake vendor:docs:minitest
110
+ rake vendor:docs:rails
111
+ # or generate both
112
+ rake vendor:docs
113
+ ```
114
+
115
+ Output is written to:
116
+
117
+ - `vendor/docs/minitest`
118
+ - `vendor/docs/rails`
119
+
49
120
  ## Release
50
121
  ```
51
122
  gem build rdoc-markdown.gemspec
data/Rakefile CHANGED
@@ -1,5 +1,9 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rake/testtask"
3
+ require "fileutils"
4
+ require "rdoc/rdoc"
5
+ require "rdoc/markdown"
6
+ require_relative "test/support/markdown_validator"
3
7
 
4
8
  Rake::TestTask.new do |t|
5
9
  t.verbose = true
@@ -8,3 +12,173 @@ Rake::TestTask.new do |t|
8
12
  end
9
13
 
10
14
  task default: [:test]
15
+
16
+ namespace :markdown do
17
+ desc "Validate generated markdown as GitHub Flavored Markdown"
18
+ task :validate do
19
+ strict_vendor_links = ENV["MARKDOWN_VALIDATE_STRICT_VENDOR"] == "1"
20
+ validation_root = File.expand_path("tmp/markdown-validate", __dir__)
21
+ FileUtils.rm_rf(validation_root)
22
+ FileUtils.mkdir_p(validation_root)
23
+
24
+ sample_output = File.join(validation_root, "sample")
25
+ generate_markdown_docs(
26
+ title: "sample",
27
+ root: File.expand_path("test/data", __dir__),
28
+ output: sample_output,
29
+ files: [File.expand_path("test/data/example.rb", __dir__)]
30
+ )
31
+
32
+ sample_count = MarkdownValidator.new(sample_output).validate!
33
+ puts "Validated #{sample_count} markdown files in #{sample_output}"
34
+
35
+ example_dir = File.expand_path("example", __dir__)
36
+ if Dir.exist?(example_dir)
37
+ example_count = MarkdownValidator.new(example_dir).validate!
38
+ puts "Validated #{example_count} markdown files in #{example_dir}"
39
+ end
40
+
41
+ Rake::Task["vendor:setup:minitest"].invoke
42
+ minitest_root = File.expand_path("vendor/minitest", __dir__)
43
+ minitest_output = File.join(validation_root, "minitest")
44
+ generate_markdown_docs(
45
+ title: "minitest",
46
+ root: minitest_root,
47
+ output: minitest_output,
48
+ files: minitest_docs_files(minitest_root)
49
+ )
50
+ minitest_validator = MarkdownValidator.new(minitest_output, strict_links: strict_vendor_links)
51
+ minitest_count = minitest_validator.validate!
52
+ puts "Validated #{minitest_count} markdown files in #{minitest_output}"
53
+ puts "Skipped #{minitest_validator.unresolved_links} unresolved local links in vendored minitest docs"
54
+
55
+ Rake::Task["vendor:setup:rails"].invoke
56
+ rails_root = File.expand_path("vendor/rails", __dir__)
57
+ rails_output = File.join(validation_root, "rails")
58
+ generate_markdown_docs(
59
+ title: "rails validation",
60
+ root: rails_root,
61
+ output: rails_output,
62
+ files: rails_validation_files(rails_root)
63
+ )
64
+ rails_validator = MarkdownValidator.new(rails_output, strict_links: strict_vendor_links)
65
+ rails_count = rails_validator.validate!
66
+ puts "Validated #{rails_count} markdown files in #{rails_output}"
67
+ puts "Skipped #{rails_validator.unresolved_links} unresolved local links in vendored rails docs"
68
+
69
+ puts "Markdown validation artifacts written to #{validation_root}"
70
+ end
71
+ end
72
+
73
+ def ensure_git_checkout(path:, url:, ref: nil)
74
+ return if Dir.exist?(path)
75
+
76
+ FileUtils.mkdir_p(File.dirname(path))
77
+
78
+ clone_command = ["git", "clone", "--depth", "1"]
79
+ clone_command += ["--branch", ref] if ref
80
+ clone_command += [url, path]
81
+
82
+ sh clone_command.join(" ")
83
+ end
84
+
85
+ def generate_markdown_docs(title:, root:, output:, files:)
86
+ raise "No input files for #{title}" if files.empty?
87
+
88
+ FileUtils.rm_rf(output)
89
+ FileUtils.mkdir_p(output)
90
+
91
+ options = RDoc::Options.new
92
+ options.setup_generator("markdown")
93
+ options.verbosity = 0
94
+ options.files = files
95
+ options.op_dir = output
96
+ options.root = root
97
+ options.title = title
98
+ options.force_output = true
99
+
100
+ RDoc::RDoc.new.document(options)
101
+ end
102
+
103
+ def minitest_docs_files(root)
104
+ files = Dir[File.join(root, "lib/**/*.rb")]
105
+ files.concat(Dir[File.join(root, "*.rdoc")])
106
+
107
+ manifest = File.join(root, "Manifest.txt")
108
+ files << manifest if File.file?(manifest)
109
+
110
+ files.uniq
111
+ end
112
+
113
+ def rails_validation_files(root)
114
+ files = Dir[File.join(root, "activesupport/lib/**/*.rb")]
115
+ files.concat(Dir[File.join(root, "activerecord/lib/**/*.rb")])
116
+ files.concat(Dir[File.join(root, "actionpack/lib/**/*.rb")])
117
+ files.concat(Dir[File.join(root, "railties/lib/**/*.rb")])
118
+
119
+ [
120
+ "activerecord/README.rdoc",
121
+ "actionpack/README.rdoc",
122
+ "railties/README.rdoc",
123
+ "railties/RDOC_MAIN.md"
124
+ ].each do |relative_path|
125
+ file = File.join(root, relative_path)
126
+ files << file if File.file?(file)
127
+ end
128
+
129
+ files.uniq
130
+ end
131
+
132
+ namespace :vendor do
133
+ namespace :setup do
134
+ MINITEST_REF = "v6.0.1"
135
+ RAILS_REF = ENV.fetch("RAILS_REF", "main")
136
+
137
+ desc "Clone/update vendor/minitest and checkout docs-aligned tag"
138
+ task :minitest do
139
+ ensure_git_checkout(path: "vendor/minitest", url: "https://github.com/minitest/minitest.git", ref: MINITEST_REF)
140
+ Dir.chdir("vendor/minitest") { sh "git checkout #{MINITEST_REF}" }
141
+ end
142
+
143
+ desc "Clone/update vendor/rails"
144
+ task :rails do
145
+ ensure_git_checkout(path: "vendor/rails", url: "https://github.com/rails/rails.git", ref: RAILS_REF)
146
+ end
147
+ end
148
+
149
+ desc "Prepare all vendored repositories"
150
+ task setup: ["vendor:setup:minitest", "vendor:setup:rails"]
151
+
152
+ namespace :docs do
153
+ desc "Generate markdown docs for vendored minitest"
154
+ task :minitest do
155
+ root = File.expand_path("vendor/minitest", __dir__)
156
+ raise "Missing vendor/minitest. Run `rake vendor:setup:minitest` first." unless Dir.exist?(root)
157
+
158
+ output = File.expand_path("vendor/docs/minitest", __dir__)
159
+ generate_markdown_docs(title: "minitest", root: root, output: output, files: minitest_docs_files(root))
160
+ puts "Generated minitest markdown docs in #{output}"
161
+ end
162
+
163
+ desc "Generate markdown docs for vendored rails"
164
+ task :rails do
165
+ root = File.expand_path("vendor/rails", __dir__)
166
+ raise "Missing vendor/rails. Run `rake vendor:setup:rails` first." unless Dir.exist?(root)
167
+
168
+ files = Dir[File.join(root, "*/lib/**/*.rb")]
169
+
170
+ active_record_readme = File.join(root, "activerecord/README.rdoc")
171
+ files << active_record_readme if File.file?(active_record_readme)
172
+
173
+ output = File.expand_path("vendor/docs/rails", __dir__)
174
+ generate_markdown_docs(title: "rails", root: root, output: output, files: files)
175
+ puts "Generated rails markdown docs in #{output}"
176
+ end
177
+
178
+ desc "Generate markdown docs for all vendored repositories"
179
+ task all: [:minitest, :rails]
180
+ end
181
+
182
+ desc "Generate markdown docs for all vendored repositories"
183
+ task docs: ["vendor:docs:all"]
184
+ end
data/example/Bird.md CHANGED
@@ -1,18 +1,24 @@
1
- # class Bird [](#class-Bird) [](#top)
1
+ # Class Bird
2
+ <a id="class-Bird"></a>
3
+
2
4
  The base class for all birds.
3
5
 
4
- ## Public Instance Methods
5
- ### fly(string, number) -> bool [](#method-i-fly)
6
- Fly somewhere.
6
+ ### Public Instance Methods
7
+
8
+ #### `fly(string, number) -> bool`
9
+ <a id="method-i-fly"></a>
10
+
11
+ Fly somewhere.
7
12
 
8
13
  Flying is the most critical feature of birds.
9
14
 
10
- # Example[¶](#method-i-fly-label-Example) [↑](#top)
15
+ ##### Example
11
16
 
12
17
  ```
13
- fly(:south,70)
18
+ fly(:south, 70)
14
19
  ```
15
- ### speak() { |text| ... } [](#method-i-speak)
16
- Produce some noise.
17
20
 
18
-
21
+ #### `speak() { |text| ... }`
22
+ <a id="method-i-speak"></a>
23
+
24
+ Produce some noise.
data/example/Duck.md CHANGED
@@ -1,52 +1,64 @@
1
- # class Duck [](#class-Duck) [](#top)
2
- A duck is a [`Waterfowl`](Waterfowl.html) [`Bird`](Bird.html).
1
+ # Class Duck
2
+ <a id="class-Duck"></a>
3
+
4
+ A duck is a [`Waterfowl`](Waterfowl.md) [`Bird`](Bird.md).
3
5
 
4
6
  Features:
5
7
 
6
- ```
7
- bird::
8
-
9
- * speak
10
- * fly
11
-
12
- waterfowl::
13
-
14
- * swim
15
- ```
16
- ## Constants
17
- | Name | Description |
18
- | ---- | ----------- |
19
- | **MAX_VELOCITY[](#MAX_VELOCITY)** | Not documented |
20
- # Bird overrides
21
- ## Constants
22
- | Name | Description |
23
- | ---- | ----------- |
24
- | **MAX_VELOCITY[](#MAX_VELOCITY)** | Not documented |
25
- ## Public Instance Methods
26
- ### speak() { |speech| ... } [](#method-i-speak)
27
- [`Duck`](Duck.html) overrides generic implementation.
28
-
29
- # Duck extensions
30
- ## Constants
31
- | Name | Description |
32
- | ---- | ----------- |
33
- | **MAX_VELOCITY[](#MAX_VELOCITY)** | Not documented |
34
- ## Attributes
35
- ### domestic[RW] [](#attribute-i-domestic)
36
- True for domestic ducks.
37
-
38
- ### rubber[R] [](#attribute-i-rubber)
39
- True for rubber ducks.
40
-
41
- ## Public Class Methods
42
- ### new(domestic, rubber) [](#method-c-new)
43
- Creates a new duck.
44
-
45
- ### rubber_ducks() [](#method-c-rubber_ducks)
46
- Returns list of all rubber ducks.
47
-
48
- ## Public Instance Methods
49
- ### useful? -> bool [](#method-i-useful-3F)
50
- Checks if this duck is a useful one.
51
-
52
-
8
+ bird:
9
+
10
+ - speak
11
+ - fly
12
+
13
+ waterfowl:
14
+
15
+ - swim
16
+
17
+ ## Bird overrides
18
+
19
+ ### Public Instance Methods
20
+
21
+ #### `speak() { |speech| ... }`
22
+ <a id="method-i-speak"></a>
23
+
24
+ [`Duck`](Duck.md) overrides generic implementation.
25
+
26
+ ## Duck extensions
27
+
28
+ ### Constants
29
+
30
+ #### `MAX_VELOCITY`
31
+ <a id="MAX_VELOCITY"></a>
32
+
33
+ Not documented.
34
+
35
+ ### Attributes
36
+
37
+ #### `domestic` [RW]
38
+ <a id="attribute-i-domestic"></a>
39
+
40
+ True for domestic ducks.
41
+
42
+ #### `rubber` [R]
43
+ <a id="attribute-i-rubber"></a>
44
+
45
+ True for rubber ducks.
46
+
47
+ ### Public Class Methods
48
+
49
+ #### `new(domestic, rubber)`
50
+ <a id="method-c-new"></a>
51
+
52
+ Creates a new duck.
53
+
54
+ #### `rubber_ducks()`
55
+ <a id="method-c-rubber_ducks"></a>
56
+
57
+ Returns list of all rubber ducks.
58
+
59
+ ### Public Instance Methods
60
+
61
+ #### `useful? -> bool`
62
+ <a id="method-i-useful-3F"></a>
63
+
64
+ Checks if this duck is a useful one.
data/example/Object.md CHANGED
@@ -1,6 +1,9 @@
1
- # class Object [](#class-Object) [](#top)
2
- ## Constants
3
- | Name | Description |
4
- | ---- | ----------- |
5
- | **DEFAULT_DUCK_VELOCITY[](#DEFAULT_DUCK_VELOCITY)** | Default velocity for a flying duck. |
6
-
1
+ # Class Object
2
+ <a id="class-Object"></a>
3
+
4
+ ### Constants
5
+
6
+ #### `DEFAULT_DUCK_VELOCITY`
7
+ <a id="DEFAULT_DUCK_VELOCITY"></a>
8
+
9
+ Default velocity for a flying duck.
data/example/Waterfowl.md CHANGED
@@ -1,8 +1,11 @@
1
- # module Waterfowl [](#module-Waterfowl) [](#top)
1
+ # Module Waterfowl
2
+ <a id="module-Waterfowl"></a>
3
+
2
4
  A mixin for waterfowl creatures.
3
5
 
4
- ## Public Instance Methods
5
- ### swim() [](#method-i-swim)
6
- Swimming helper.
6
+ ### Public Instance Methods
7
+
8
+ #### `swim()`
9
+ <a id="method-i-swim"></a>
7
10
 
8
-
11
+ Swimming helper.