rdoc-markdown 0.11.1 → 0.12.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/Gemfile.lock +1 -1
- data/lib/rdoc/generator/markdown.rb +53 -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: c69484c517e3582906e6847cbb162a7847ad29446856197a5f65972071c21d24
|
|
4
|
+
data.tar.gz: f646046107985a70925df0794921c5451c514be069827762a296b9763a27bd81
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 79dce45ea46f3c5baa04488ea729e280196cb1b73cf48d1857c8227d67cf9d8ec2eb2d5d3dd69ced241d06c0b91ba91d817fcf4cbd0d7d6de22f05e709f3e0a0
|
|
7
|
+
data.tar.gz: 44cd9cf4996a79fee5c56b19fa3779aed7e19a165a0576f350399560259b89f82e615c0911f7a1ce00087b860f1494499c7c00230dc486da11724502bc9a58fb
|
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 eligible for root page classification.
|
|
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,7 @@ 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
|
+
|
|
52
79
|
end
|
|
53
80
|
|
|
54
81
|
# Registers markdown generator-specific RDoc options.
|
|
@@ -117,6 +144,7 @@ class RDoc::Generator::Markdown
|
|
|
117
144
|
@markdown_unknown_tags = self.class.validate_markdown_unknown_tags(rdoc_options.markdown_unknown_tags)
|
|
118
145
|
|
|
119
146
|
@base_dir = Pathname.pwd
|
|
147
|
+
@expanded_root = Pathname(@options.root.to_s).expand_path
|
|
120
148
|
end
|
|
121
149
|
|
|
122
150
|
# Writes class files, page files, and the search index.
|
|
@@ -210,7 +238,7 @@ class RDoc::Generator::Markdown
|
|
|
210
238
|
@pages.each do |page|
|
|
211
239
|
csv << [
|
|
212
240
|
page.page_name,
|
|
213
|
-
|
|
241
|
+
page_type(page),
|
|
214
242
|
page_output_path(page)
|
|
215
243
|
]
|
|
216
244
|
end
|
|
@@ -276,6 +304,26 @@ class RDoc::Generator::Markdown
|
|
|
276
304
|
"#{dirname}/#{basename}"
|
|
277
305
|
end
|
|
278
306
|
|
|
307
|
+
# Checks whether a text page is the configured main page.
|
|
308
|
+
#
|
|
309
|
+
# @param page [RDoc::TopLevel] Page object to index.
|
|
310
|
+
#
|
|
311
|
+
# @return [Boolean]
|
|
312
|
+
def main_page?(page)
|
|
313
|
+
normalize_input_path_for_output(page.full_name) == normalize_input_path_for_output(@options.main_page.to_s)
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
# Returns the search-index type for a text page.
|
|
317
|
+
#
|
|
318
|
+
# @param page [RDoc::TopLevel] Page object to index.
|
|
319
|
+
#
|
|
320
|
+
# @return [String]
|
|
321
|
+
def page_type(page)
|
|
322
|
+
return "Readme" if main_page?(page)
|
|
323
|
+
|
|
324
|
+
self.class.root_page_type_for(normalize_input_path_for_output(page.relative_name)) || "Page"
|
|
325
|
+
end
|
|
326
|
+
|
|
279
327
|
# Returns the normalized display name for a class or module.
|
|
280
328
|
#
|
|
281
329
|
# @param code_object [RDoc::Context] Class or module object.
|
|
@@ -669,7 +717,7 @@ class RDoc::Generator::Markdown
|
|
|
669
717
|
def normalize_input_path_for_output(path)
|
|
670
718
|
normalized = path.tr("\\", "/").sub(%r{\A\./}, "")
|
|
671
719
|
|
|
672
|
-
root =
|
|
720
|
+
root = @expanded_root.to_s
|
|
673
721
|
normalized = normalized.sub(%r{\A#{Regexp.escape(root)}/}, "")
|
|
674
722
|
normalized = normalized.sub(%r{\A/}, "")
|
|
675
723
|
|