rdoc-markdown 0.11.1 → 0.12.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/Gemfile.lock +1 -1
- data/lib/rdoc/generator/markdown.rb +76 -5
- 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: 575534e13c6e1b37284625867c6d57661f8af184308ce3a926b482025d964248
|
|
4
|
+
data.tar.gz: 68165f940dd78b6da93cea34cf0ed52b85c25d9616226326959e1dd66dcbbe8e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1e9cd00c3f59f79153e01fb666801615d9a30c486c3c3bdf10c0e73e7118b2badda559e661f2f73cb9741fc6b2e6a8d44946a4ff3210f4ee1e74acf44a82c5b6
|
|
7
|
+
data.tar.gz: faef36b7139ea5ffd5f2b959aaf522e47cc254f54bf3a1622ccb56c64936bb4e22b5c17cb8f2d323ad6b5691b32c63d8586cf71c756cabb4136568d5a78663b2
|
data/Gemfile.lock
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
+
# shareable_constant_value: literal
|
|
2
3
|
|
|
3
4
|
gem "rdoc"
|
|
4
5
|
|
|
@@ -14,12 +15,37 @@ class RDoc::Generator::Markdown
|
|
|
14
15
|
|
|
15
16
|
require_relative "markdown/rbs_signature_index"
|
|
16
17
|
|
|
18
|
+
# Supported reverse_markdown unknown-tag modes.
|
|
19
|
+
MARKDOWN_UNKNOWN_TAGS = %i[pass_through drop bypass raise]
|
|
20
|
+
|
|
21
|
+
# Root source page basenames and their search-index types.
|
|
22
|
+
ROOT_PAGES = {
|
|
23
|
+
"readme" => "Readme",
|
|
24
|
+
"guide" => "Readme",
|
|
25
|
+
"changelog" => "Changelog",
|
|
26
|
+
"history" => "Changelog"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
# Source page extensions RDoc should auto-include from the root directory.
|
|
30
|
+
ROOT_PAGE_EXTENSIONS = %w[.rdoc .md .markdown]
|
|
31
|
+
|
|
32
|
+
# Returns the configured search-index type for an eligible root text page path.
|
|
33
|
+
#
|
|
34
|
+
# @param source_path [String] Normalized source path relative to the root.
|
|
35
|
+
#
|
|
36
|
+
# @return [String, nil]
|
|
37
|
+
def self.root_page_type_for(source_path)
|
|
38
|
+
return unless File.dirname(source_path) == "."
|
|
39
|
+
return unless ROOT_PAGE_EXTENSIONS.include?(File.extname(source_path))
|
|
40
|
+
|
|
41
|
+
ROOT_PAGES[File.basename(source_path, ".*").downcase]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# shareable_constant_value: none
|
|
45
|
+
|
|
17
46
|
# Directory containing ERB templates.
|
|
18
47
|
TEMPLATE_DIR = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "templates"))
|
|
19
48
|
|
|
20
|
-
# Supported reverse_markdown unknown-tag modes.
|
|
21
|
-
MARKDOWN_UNKNOWN_TAGS = %i[pass_through drop bypass raise].freeze
|
|
22
|
-
|
|
23
49
|
# Adds rdoc-markdown generator configuration to RDoc's option object.
|
|
24
50
|
module OptionsExtension
|
|
25
51
|
# Initializes markdown generator options alongside RDoc's built-in options.
|
|
@@ -49,6 +75,30 @@ class RDoc::Generator::Markdown
|
|
|
49
75
|
super
|
|
50
76
|
@markdown_unknown_tags = map.fetch("markdown_unknown_tags") if map.key?("markdown_unknown_tags")
|
|
51
77
|
end
|
|
78
|
+
|
|
79
|
+
# Adds markdown root entry pages to explicit source files.
|
|
80
|
+
#
|
|
81
|
+
# @return [void]
|
|
82
|
+
def check_files
|
|
83
|
+
return super unless @generator == RDoc::Generator::Markdown
|
|
84
|
+
super
|
|
85
|
+
return if @files.empty?
|
|
86
|
+
|
|
87
|
+
root = Pathname(@root)
|
|
88
|
+
expanded_root = root.expand_path
|
|
89
|
+
expanded_files = @files.map { |file| Pathname(file).expand_path.to_s }
|
|
90
|
+
@files.concat(
|
|
91
|
+
Dir.children(expanded_root).filter_map do |name|
|
|
92
|
+
path = expanded_root.join(name)
|
|
93
|
+
next unless path.file?
|
|
94
|
+
next unless File.readable?(path)
|
|
95
|
+
next unless RDoc::Generator::Markdown.root_page_type_for(name)
|
|
96
|
+
next if expanded_files.include?(path.to_s)
|
|
97
|
+
|
|
98
|
+
root.join(name).to_s
|
|
99
|
+
end
|
|
100
|
+
)
|
|
101
|
+
end
|
|
52
102
|
end
|
|
53
103
|
|
|
54
104
|
# Registers markdown generator-specific RDoc options.
|
|
@@ -117,6 +167,7 @@ class RDoc::Generator::Markdown
|
|
|
117
167
|
@markdown_unknown_tags = self.class.validate_markdown_unknown_tags(rdoc_options.markdown_unknown_tags)
|
|
118
168
|
|
|
119
169
|
@base_dir = Pathname.pwd
|
|
170
|
+
@expanded_root = Pathname(@options.root.to_s).expand_path
|
|
120
171
|
end
|
|
121
172
|
|
|
122
173
|
# Writes class files, page files, and the search index.
|
|
@@ -210,7 +261,7 @@ class RDoc::Generator::Markdown
|
|
|
210
261
|
@pages.each do |page|
|
|
211
262
|
csv << [
|
|
212
263
|
page.page_name,
|
|
213
|
-
|
|
264
|
+
page_type(page),
|
|
214
265
|
page_output_path(page)
|
|
215
266
|
]
|
|
216
267
|
end
|
|
@@ -276,6 +327,26 @@ class RDoc::Generator::Markdown
|
|
|
276
327
|
"#{dirname}/#{basename}"
|
|
277
328
|
end
|
|
278
329
|
|
|
330
|
+
# Checks whether a text page is the configured main page.
|
|
331
|
+
#
|
|
332
|
+
# @param page [RDoc::TopLevel] Page object to index.
|
|
333
|
+
#
|
|
334
|
+
# @return [Boolean]
|
|
335
|
+
def main_page?(page)
|
|
336
|
+
normalize_input_path_for_output(page.full_name) == normalize_input_path_for_output(@options.main_page.to_s)
|
|
337
|
+
end
|
|
338
|
+
|
|
339
|
+
# Returns the search-index type for a text page.
|
|
340
|
+
#
|
|
341
|
+
# @param page [RDoc::TopLevel] Page object to index.
|
|
342
|
+
#
|
|
343
|
+
# @return [String]
|
|
344
|
+
def page_type(page)
|
|
345
|
+
return "Readme" if main_page?(page)
|
|
346
|
+
|
|
347
|
+
self.class.root_page_type_for(normalize_input_path_for_output(page.relative_name)) || "Page"
|
|
348
|
+
end
|
|
349
|
+
|
|
279
350
|
# Returns the normalized display name for a class or module.
|
|
280
351
|
#
|
|
281
352
|
# @param code_object [RDoc::Context] Class or module object.
|
|
@@ -669,7 +740,7 @@ class RDoc::Generator::Markdown
|
|
|
669
740
|
def normalize_input_path_for_output(path)
|
|
670
741
|
normalized = path.tr("\\", "/").sub(%r{\A\./}, "")
|
|
671
742
|
|
|
672
|
-
root =
|
|
743
|
+
root = @expanded_root.to_s
|
|
673
744
|
normalized = normalized.sub(%r{\A#{Regexp.escape(root)}/}, "")
|
|
674
745
|
normalized = normalized.sub(%r{\A/}, "")
|
|
675
746
|
|