rdoc-markdown 0.14.0 → 0.16.1
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 +11 -0
- data/Gemfile.lock +1 -1
- data/README.md +6 -0
- data/Rakefile +44 -5
- data/lib/rdoc/generator/markdown.rb +12 -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: 2ff64065c50e370a502784e01c59e86d8dd6490a6c28f87cfec28b3a22bcd235
|
|
4
|
+
data.tar.gz: 9c54ac15590b858a761bafb3fd1055925f19c3a6d783beff8c8d77dba984a953
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e754b47dd630557c3765a2407eee71edb7a106151436c9054dc0cab928afc35b68e65bab29ea158f847a92378251f37990487d6bdbfb0339fd824748e32bcb81
|
|
7
|
+
data.tar.gz: f8108d248d231e0d3c8066a687d9513570d38ddcfa47e917b330dc51ee7db8c512a85cad7acf1fced09856383e914e45d3f7c7cb5e38aa129ce5099aaa555e47
|
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,17 @@
|
|
|
3
3
|
|
|
4
4
|
## Unreleased
|
|
5
5
|
|
|
6
|
+
- Fix copying Markdown pages when RDoc receives relative input paths.
|
|
7
|
+
|
|
8
|
+
## 0.16.0
|
|
9
|
+
|
|
10
|
+
- Don't convert markdown files from source folder. Just copy them.
|
|
11
|
+
|
|
12
|
+
## 0.15.0
|
|
13
|
+
|
|
14
|
+
- remove special files types (changelog, readme), just label everything 'File'
|
|
15
|
+
- change "Page" file type to just "File"
|
|
16
|
+
|
|
6
17
|
## 0.14.0
|
|
7
18
|
|
|
8
19
|
- 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.
|
|
@@ -123,9 +98,8 @@ class RDoc::Generator::Markdown
|
|
|
123
98
|
def initialize(store, rdoc_options)
|
|
124
99
|
@store = store
|
|
125
100
|
@options = rdoc_options
|
|
101
|
+
@source_dir = File.expand_path(rdoc_options.root.to_s)
|
|
126
102
|
@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
103
|
end
|
|
130
104
|
|
|
131
105
|
# Writes class files, page files, and the search index.
|
|
@@ -219,7 +193,7 @@ class RDoc::Generator::Markdown
|
|
|
219
193
|
@pages.each do |page|
|
|
220
194
|
csv << [
|
|
221
195
|
page.page_name,
|
|
222
|
-
|
|
196
|
+
"File",
|
|
223
197
|
page_output_path(page)
|
|
224
198
|
]
|
|
225
199
|
end
|
|
@@ -250,6 +224,8 @@ class RDoc::Generator::Markdown
|
|
|
250
224
|
out_file = Pathname.new("#{output_dir}/#{page_output_path(page)}")
|
|
251
225
|
out_file.dirname.mkpath
|
|
252
226
|
|
|
227
|
+
next FileUtils.cp(File.expand_path(page.absolute_name, @source_dir), out_file) if page.relative_name.end_with?(".md", ".markdown")
|
|
228
|
+
|
|
253
229
|
content = markdownify(render_description(page))
|
|
254
230
|
File.write(out_file, finalize_markdown(
|
|
255
231
|
content,
|
|
@@ -274,6 +250,8 @@ class RDoc::Generator::Markdown
|
|
|
274
250
|
# @return [String] Relative Markdown path.
|
|
275
251
|
def page_output_path(page)
|
|
276
252
|
source_path = normalize_input_path_for_output(page.relative_name)
|
|
253
|
+
return source_path if page.relative_name.match?(/\.(?:md|markdown)\z/)
|
|
254
|
+
|
|
277
255
|
dirname = File.dirname(source_path)
|
|
278
256
|
basename = "#{File.basename(source_path).tr(".", "_")}.md"
|
|
279
257
|
|
|
@@ -282,26 +260,6 @@ class RDoc::Generator::Markdown
|
|
|
282
260
|
"#{dirname}/#{basename}"
|
|
283
261
|
end
|
|
284
262
|
|
|
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
263
|
# Returns the normalized display name for a class or module.
|
|
306
264
|
#
|
|
307
265
|
# @param code_object [RDoc::Context] Class or module object.
|
|
@@ -740,6 +698,7 @@ class RDoc::Generator::Markdown
|
|
|
740
698
|
# @return [String, nil] Resolved output path, or nil when unresolved.
|
|
741
699
|
def resolve_output_path(path, current_dir)
|
|
742
700
|
candidates = [path, path.delete_prefix("#{@root_path_segment}/")]
|
|
701
|
+
candidates += candidates.map { |candidate| candidate.sub(/_(md|markdown)\.md\z/, '.\1') }
|
|
743
702
|
|
|
744
703
|
candidates.each do |candidate|
|
|
745
704
|
return candidate if @known_output_paths.include?(candidate)
|
|
@@ -761,7 +720,7 @@ class RDoc::Generator::Markdown
|
|
|
761
720
|
def normalize_input_path_for_output(path)
|
|
762
721
|
normalized = path.tr("\\", "/").sub(%r{\A\./}, "")
|
|
763
722
|
|
|
764
|
-
root = @
|
|
723
|
+
root = @source_dir
|
|
765
724
|
normalized = normalized.sub(%r{\A#{Regexp.escape(root)}/}, "")
|
|
766
725
|
normalized = normalized.sub(%r{\A/}, "")
|
|
767
726
|
|