rdoc-markdown 0.14.0 → 0.16.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 +4 -4
- data/AGENTS.md +1 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/README.md +6 -0
- data/Rakefile +44 -5
- data/lib/rdoc/generator/markdown.rb +11 -53
- data/lib/rdoc/markdown/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: d3d1c4068ecf819554e104801cbf461b722e150e0472bb4215ef96a887750e58
|
|
4
|
+
data.tar.gz: 5de0a95f8b8265b6877a43f85f14ef55f3a4ce7c5bc4bc972b22be104c91d959
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7a7863e3dbcf54782565a065f2997e90e3d5f4a5985e174f855dbd060c0afe6af9dd29239a08e2a6466690126370ae44d366bce012eb8b4612e3740a78704992
|
|
7
|
+
data.tar.gz: 71251348e64ae468b1b739925635aae9f79e003d5be8fef71b769fd757d72e532d8489375a2887adf606b433142b23b50ca93756f38eb88e6aaa57b22e344258
|
data/AGENTS.md
CHANGED
|
@@ -43,6 +43,7 @@ You are done when all of these are green and not reporting any issues:
|
|
|
43
43
|
bundle exec rake test
|
|
44
44
|
# don't run again if fail-fast has already passed
|
|
45
45
|
bundle exec mutant run --fail-fast --since origin/main
|
|
46
|
+
bundle exec standardrb --fix
|
|
46
47
|
bundle exec rake markdown:validate
|
|
47
48
|
bundle exec yard-lint
|
|
48
49
|
bundle exec rake erb:lint
|
data/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
|
|
4
4
|
## Unreleased
|
|
5
5
|
|
|
6
|
+
## 0.16.0
|
|
7
|
+
|
|
8
|
+
- Don't convert markdown files from source folder. Just copy them.
|
|
9
|
+
|
|
10
|
+
## 0.15.0
|
|
11
|
+
|
|
12
|
+
- remove special files types (changelog, readme), just label everything 'File'
|
|
13
|
+
- change "Page" file type to just "File"
|
|
14
|
+
|
|
6
15
|
## 0.14.0
|
|
7
16
|
|
|
8
17
|
- BREAKING: Removing RDoc 7 compatibility code. Support RDoc 8 only.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
|
@@ -35,6 +35,8 @@ Run following command in directory with ruby source code:
|
|
|
35
35
|
|
|
36
36
|
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.
|
|
37
37
|
|
|
38
|
+
Input `.md` and `.markdown` pages are copied unchanged to the same relative path. RDoc pages and Ruby documentation are converted to Markdown.
|
|
39
|
+
|
|
38
40
|
### Unknown HTML tags
|
|
39
41
|
rdoc-markdown uses `reverse_markdown` to convert RDoc's HTML fragments to Markdown. You can configure how unknown HTML tags are handled with:
|
|
40
42
|
|
|
@@ -130,15 +132,19 @@ Use rake tasks to generate markdown output for vendored projects:
|
|
|
130
132
|
rake vendor:setup
|
|
131
133
|
rake vendor:docs:jekyll_seo_tag
|
|
132
134
|
rake vendor:docs:minitest
|
|
135
|
+
rake vendor:docs:reverse_markdown
|
|
133
136
|
rake vendor:docs:rails
|
|
134
137
|
# or generate all
|
|
135
138
|
rake vendor:docs
|
|
136
139
|
```
|
|
137
140
|
|
|
141
|
+
`rake vendor:setup` also checks out the dependency-aligned `reverse_markdown` source in `vendor/reverse_markdown`.
|
|
142
|
+
|
|
138
143
|
Output is written to:
|
|
139
144
|
|
|
140
145
|
- `vendor/docs/minitest`
|
|
141
146
|
- `vendor/docs/jekyll-seo-tag`
|
|
147
|
+
- `vendor/docs/reverse_markdown`
|
|
142
148
|
- `vendor/docs/rails`
|
|
143
149
|
|
|
144
150
|
## Release
|
data/Rakefile
CHANGED
|
@@ -59,6 +59,18 @@ namespace :markdown do
|
|
|
59
59
|
minitest_count = MarkdownValidator.new(minitest_output).validate!
|
|
60
60
|
puts "Validated #{minitest_count} markdown files in #{minitest_output}"
|
|
61
61
|
|
|
62
|
+
Rake::Task["vendor:setup:reverse_markdown"].invoke
|
|
63
|
+
reverse_markdown_root = File.expand_path("vendor/reverse_markdown", __dir__)
|
|
64
|
+
reverse_markdown_output = File.join(validation_root, "reverse_markdown")
|
|
65
|
+
generate_markdown_docs(
|
|
66
|
+
title: "reverse_markdown",
|
|
67
|
+
root: reverse_markdown_root,
|
|
68
|
+
output: reverse_markdown_output,
|
|
69
|
+
files: reverse_markdown_docs_files(reverse_markdown_root)
|
|
70
|
+
)
|
|
71
|
+
reverse_markdown_count = MarkdownValidator.new(reverse_markdown_output).validate!
|
|
72
|
+
puts "Validated #{reverse_markdown_count} markdown files in #{reverse_markdown_output}"
|
|
73
|
+
|
|
62
74
|
Rake::Task["vendor:setup:jekyll_seo_tag"].invoke
|
|
63
75
|
jekyll_seo_tag_output = File.join(validation_root, JEKYLL_SEO_TAG_NAME)
|
|
64
76
|
generate_jekyll_seo_tag_docs(output: jekyll_seo_tag_output)
|
|
@@ -168,6 +180,10 @@ def minitest_docs_files(root)
|
|
|
168
180
|
files.uniq
|
|
169
181
|
end
|
|
170
182
|
|
|
183
|
+
def reverse_markdown_docs_files(root)
|
|
184
|
+
Dir[File.join(root, "lib/**/*.rb")] + Dir[File.join(root, "*.md")]
|
|
185
|
+
end
|
|
186
|
+
|
|
171
187
|
def rails_validation_files(root)
|
|
172
188
|
files = Dir[File.join(root, "activesupport/lib/**/*.rb")]
|
|
173
189
|
files.concat(Dir[File.join(root, "activerecord/lib/**/*.rb")])
|
|
@@ -176,9 +192,6 @@ def rails_validation_files(root)
|
|
|
176
192
|
|
|
177
193
|
files.concat(Dir[File.join(root, "{active*,action*,railties}/README.{rdoc,md,markdown}")])
|
|
178
194
|
|
|
179
|
-
main_page = File.join(root, "railties/RDOC_MAIN.md")
|
|
180
|
-
files << main_page if File.file?(main_page)
|
|
181
|
-
|
|
182
195
|
files.uniq
|
|
183
196
|
end
|
|
184
197
|
|
|
@@ -186,6 +199,7 @@ namespace :vendor do
|
|
|
186
199
|
namespace :setup do
|
|
187
200
|
minitest_ref = "v6.0.1"
|
|
188
201
|
rails_ref = ENV.fetch("RAILS_REF", "main")
|
|
202
|
+
reverse_markdown_ref = "v3.0.2"
|
|
189
203
|
|
|
190
204
|
desc "Clone/update vendor/jekyll-seo-tag and checkout docs-aligned tag"
|
|
191
205
|
task :jekyll_seo_tag do
|
|
@@ -210,10 +224,20 @@ namespace :vendor do
|
|
|
210
224
|
task :rails do
|
|
211
225
|
ensure_git_checkout(path: "vendor/rails", url: "https://github.com/rails/rails.git", ref: rails_ref)
|
|
212
226
|
end
|
|
227
|
+
|
|
228
|
+
desc "Clone/update vendor/reverse_markdown and checkout dependency-aligned tag"
|
|
229
|
+
task :reverse_markdown do
|
|
230
|
+
ensure_git_checkout(
|
|
231
|
+
path: "vendor/reverse_markdown",
|
|
232
|
+
url: "https://github.com/xijo/reverse_markdown.git",
|
|
233
|
+
ref: reverse_markdown_ref
|
|
234
|
+
)
|
|
235
|
+
Dir.chdir("vendor/reverse_markdown") { sh "git checkout #{reverse_markdown_ref}" }
|
|
236
|
+
end
|
|
213
237
|
end
|
|
214
238
|
|
|
215
239
|
desc "Prepare all vendored repositories"
|
|
216
|
-
task setup: ["vendor:setup:jekyll_seo_tag", "vendor:setup:minitest", "vendor:setup:rails"]
|
|
240
|
+
task setup: ["vendor:setup:jekyll_seo_tag", "vendor:setup:minitest", "vendor:setup:rails", "vendor:setup:reverse_markdown"]
|
|
217
241
|
|
|
218
242
|
namespace :docs do
|
|
219
243
|
desc "Generate markdown docs for vendored jekyll-seo-tag"
|
|
@@ -233,6 +257,21 @@ namespace :vendor do
|
|
|
233
257
|
puts "Generated minitest markdown docs in #{output}"
|
|
234
258
|
end
|
|
235
259
|
|
|
260
|
+
desc "Generate markdown docs for vendored reverse_markdown"
|
|
261
|
+
task :reverse_markdown do
|
|
262
|
+
root = File.expand_path("vendor/reverse_markdown", __dir__)
|
|
263
|
+
raise "Missing vendor/reverse_markdown. Run `rake vendor:setup:reverse_markdown` first." unless Dir.exist?(root)
|
|
264
|
+
|
|
265
|
+
output = File.expand_path("vendor/docs/reverse_markdown", __dir__)
|
|
266
|
+
generate_markdown_docs(
|
|
267
|
+
title: "reverse_markdown",
|
|
268
|
+
root: root,
|
|
269
|
+
output: output,
|
|
270
|
+
files: reverse_markdown_docs_files(root)
|
|
271
|
+
)
|
|
272
|
+
puts "Generated reverse_markdown markdown docs in #{output}"
|
|
273
|
+
end
|
|
274
|
+
|
|
236
275
|
desc "Generate markdown docs for vendored rails"
|
|
237
276
|
task :rails do
|
|
238
277
|
root = File.expand_path("vendor/rails", __dir__)
|
|
@@ -249,7 +288,7 @@ namespace :vendor do
|
|
|
249
288
|
end
|
|
250
289
|
|
|
251
290
|
desc "Generate markdown docs for all vendored repositories"
|
|
252
|
-
task all: [:jekyll_seo_tag, :minitest, :rails]
|
|
291
|
+
task all: [:jekyll_seo_tag, :minitest, :reverse_markdown, :rails]
|
|
253
292
|
end
|
|
254
293
|
|
|
255
294
|
desc "Generate markdown docs for all vendored repositories"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
# shareable_constant_value: literal
|
|
3
2
|
|
|
4
3
|
require "erb"
|
|
5
4
|
require "reverse_markdown"
|
|
6
5
|
require "csv"
|
|
6
|
+
require "fileutils"
|
|
7
7
|
require "optparse"
|
|
8
8
|
|
|
9
9
|
# Generates Markdown output and a CSV search index from an RDoc store.
|
|
@@ -12,37 +12,12 @@ class RDoc::Generator::Markdown
|
|
|
12
12
|
|
|
13
13
|
require_relative "markdown/crossref"
|
|
14
14
|
|
|
15
|
-
# Supported reverse_markdown unknown-tag modes.
|
|
16
|
-
MARKDOWN_UNKNOWN_TAGS = %i[pass_through drop bypass raise]
|
|
17
|
-
|
|
18
|
-
# Root source page basenames and their search-index types.
|
|
19
|
-
ROOT_PAGES = {
|
|
20
|
-
"readme" => "Readme",
|
|
21
|
-
"guide" => "Readme",
|
|
22
|
-
"changelog" => "Changelog",
|
|
23
|
-
"history" => "Changelog"
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
# Source page extensions eligible for root page classification.
|
|
27
|
-
ROOT_PAGE_EXTENSIONS = %w[.rdoc .md .markdown]
|
|
28
|
-
|
|
29
|
-
# Returns the configured search-index type for an eligible root text page path.
|
|
30
|
-
#
|
|
31
|
-
# @param source_path [String] Normalized source path relative to the root.
|
|
32
|
-
#
|
|
33
|
-
# @return [String, nil]
|
|
34
|
-
def self.root_page_type_for(source_path)
|
|
35
|
-
return unless File.dirname(source_path) == "."
|
|
36
|
-
return unless ROOT_PAGE_EXTENSIONS.include?(File.extname(source_path))
|
|
37
|
-
|
|
38
|
-
ROOT_PAGES[File.basename(source_path, ".*").downcase]
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
# shareable_constant_value: none
|
|
42
|
-
|
|
43
15
|
# Directory containing ERB templates.
|
|
44
16
|
TEMPLATE_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "templates"))
|
|
45
17
|
|
|
18
|
+
# Supported reverse_markdown unknown-tag modes.
|
|
19
|
+
MARKDOWN_UNKNOWN_TAGS = %i[pass_through drop bypass raise].freeze
|
|
20
|
+
|
|
46
21
|
# Adds rdoc-markdown generator configuration to RDoc's option object.
|
|
47
22
|
module OptionsExtension
|
|
48
23
|
# Initializes markdown generator options alongside RDoc's built-in options.
|
|
@@ -124,8 +99,6 @@ class RDoc::Generator::Markdown
|
|
|
124
99
|
@store = store
|
|
125
100
|
@options = rdoc_options
|
|
126
101
|
@markdown_unknown_tags = self.class.validate_markdown_unknown_tags(rdoc_options.markdown_unknown_tags)
|
|
127
|
-
|
|
128
|
-
@expanded_root = Pathname(@options.root.to_s).expand_path
|
|
129
102
|
end
|
|
130
103
|
|
|
131
104
|
# Writes class files, page files, and the search index.
|
|
@@ -219,7 +192,7 @@ class RDoc::Generator::Markdown
|
|
|
219
192
|
@pages.each do |page|
|
|
220
193
|
csv << [
|
|
221
194
|
page.page_name,
|
|
222
|
-
|
|
195
|
+
"File",
|
|
223
196
|
page_output_path(page)
|
|
224
197
|
]
|
|
225
198
|
end
|
|
@@ -250,6 +223,8 @@ class RDoc::Generator::Markdown
|
|
|
250
223
|
out_file = Pathname.new("#{output_dir}/#{page_output_path(page)}")
|
|
251
224
|
out_file.dirname.mkpath
|
|
252
225
|
|
|
226
|
+
next FileUtils.cp(page.absolute_name, out_file) if page.relative_name.end_with?(".md", ".markdown")
|
|
227
|
+
|
|
253
228
|
content = markdownify(render_description(page))
|
|
254
229
|
File.write(out_file, finalize_markdown(
|
|
255
230
|
content,
|
|
@@ -274,6 +249,8 @@ class RDoc::Generator::Markdown
|
|
|
274
249
|
# @return [String] Relative Markdown path.
|
|
275
250
|
def page_output_path(page)
|
|
276
251
|
source_path = normalize_input_path_for_output(page.relative_name)
|
|
252
|
+
return source_path if page.relative_name.match?(/\.(?:md|markdown)\z/)
|
|
253
|
+
|
|
277
254
|
dirname = File.dirname(source_path)
|
|
278
255
|
basename = "#{File.basename(source_path).tr(".", "_")}.md"
|
|
279
256
|
|
|
@@ -282,26 +259,6 @@ class RDoc::Generator::Markdown
|
|
|
282
259
|
"#{dirname}/#{basename}"
|
|
283
260
|
end
|
|
284
261
|
|
|
285
|
-
# Checks whether a text page is the configured main page.
|
|
286
|
-
#
|
|
287
|
-
# @param page [RDoc::TopLevel] Page object to index.
|
|
288
|
-
#
|
|
289
|
-
# @return [Boolean]
|
|
290
|
-
def main_page?(page)
|
|
291
|
-
normalize_input_path_for_output(page.full_name) == normalize_input_path_for_output(@options.main_page.to_s)
|
|
292
|
-
end
|
|
293
|
-
|
|
294
|
-
# Returns the search-index type for a text page.
|
|
295
|
-
#
|
|
296
|
-
# @param page [RDoc::TopLevel] Page object to index.
|
|
297
|
-
#
|
|
298
|
-
# @return [String]
|
|
299
|
-
def page_type(page)
|
|
300
|
-
return "Readme" if main_page?(page)
|
|
301
|
-
|
|
302
|
-
self.class.root_page_type_for(normalize_input_path_for_output(page.relative_name)) || "Page"
|
|
303
|
-
end
|
|
304
|
-
|
|
305
262
|
# Returns the normalized display name for a class or module.
|
|
306
263
|
#
|
|
307
264
|
# @param code_object [RDoc::Context] Class or module object.
|
|
@@ -740,6 +697,7 @@ class RDoc::Generator::Markdown
|
|
|
740
697
|
# @return [String, nil] Resolved output path, or nil when unresolved.
|
|
741
698
|
def resolve_output_path(path, current_dir)
|
|
742
699
|
candidates = [path, path.delete_prefix("#{@root_path_segment}/")]
|
|
700
|
+
candidates += candidates.map { |candidate| candidate.sub(/_(md|markdown)\.md\z/, '.\1') }
|
|
743
701
|
|
|
744
702
|
candidates.each do |candidate|
|
|
745
703
|
return candidate if @known_output_paths.include?(candidate)
|
|
@@ -761,7 +719,7 @@ class RDoc::Generator::Markdown
|
|
|
761
719
|
def normalize_input_path_for_output(path)
|
|
762
720
|
normalized = path.tr("\\", "/").sub(%r{\A\./}, "")
|
|
763
721
|
|
|
764
|
-
root = @
|
|
722
|
+
root = File.expand_path(@options.root.to_s)
|
|
765
723
|
normalized = normalized.sub(%r{\A#{Regexp.escape(root)}/}, "")
|
|
766
724
|
normalized = normalized.sub(%r{\A/}, "")
|
|
767
725
|
|