rdoc-markdown 0.12.1 → 0.13.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/CHANGELOG.md +20 -0
- data/Gemfile.lock +1 -1
- data/lib/rdoc/generator/markdown.rb +52 -16
- data/lib/rdoc/markdown/version.rb +1 -1
- data/lib/templates/classfile.md.erb +18 -0
- 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: f6f72f8c6fb2ba87242d9cfbcba6c38ae5587ce16b2769c71be2777ad0bdf5db
|
|
4
|
+
data.tar.gz: cb6f5ec0b90f430abbc90ab2cd379907fd044f64be52fc0243987e7287b05858
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3c18290f2f21c4a5bab355288688e7893c7f7922e944cc3ffbddfa71e063e76d5bbb8f0a05cb66052359e921eb0b81ac6aae89b21f47715e453f48f1bc05e84f
|
|
7
|
+
data.tar.gz: 57849ac7cfa778224373c3444f38e2d0f205f9442726636218a6894f7da51e842b056105e9c90dfdd3c7715ec0990029138a699d8d4b5fc62972a32ec18479ca
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.13.1
|
|
6
|
+
|
|
7
|
+
- reduce metadata escape characters only to absolutely necessary (|, \)
|
|
8
|
+
|
|
9
|
+
## 0.13.0
|
|
10
|
+
|
|
11
|
+
- Adding metadata to classes/modules
|
|
12
|
+
- Fixed: cross-linking between markdown files
|
|
13
|
+
|
|
14
|
+
## 0.12.1
|
|
15
|
+
|
|
16
|
+
- simplification: automatic root-page inclusion hook.
|
|
17
|
+
- Explicit RDoc file lists are authoritative again; unlisted README, CHANGELOG, and similar files are not silently added.
|
|
18
|
+
|
|
19
|
+
## 0.12.0
|
|
20
|
+
|
|
21
|
+
- Indexing: Classifies root-level README and GUIDE pages as Readme.
|
|
22
|
+
- Indexing: Classifies root-level CHANGELOG and HISTORY pages as Changelog.
|
|
23
|
+
- Recognizes .rdoc, .md, and .markdown, case-insensitively by basename.
|
|
24
|
+
|
|
5
25
|
## 0.11.1
|
|
6
26
|
|
|
7
27
|
- Changed headings from standalone anchors to adjacent inline anchors:
|
data/Gemfile.lock
CHANGED
|
@@ -75,7 +75,6 @@ class RDoc::Generator::Markdown
|
|
|
75
75
|
super
|
|
76
76
|
@markdown_unknown_tags = map.fetch("markdown_unknown_tags") if map.key?("markdown_unknown_tags")
|
|
77
77
|
end
|
|
78
|
-
|
|
79
78
|
end
|
|
80
79
|
|
|
81
80
|
# Registers markdown generator-specific RDoc options.
|
|
@@ -253,16 +252,17 @@ class RDoc::Generator::Markdown
|
|
|
253
252
|
template = ERB.new(template_content, trim_mode: "-")
|
|
254
253
|
|
|
255
254
|
@classes.each do |klass|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
255
|
+
content = template.result(binding)
|
|
256
|
+
output_path = output_path_for(klass)
|
|
257
|
+
|
|
258
|
+
([output_path] | legacy_paths_for(klass)).each do |destination_path|
|
|
259
|
+
out_file = Pathname.new("#{output_dir}/#{destination_path}")
|
|
260
|
+
out_file.dirname.mkpath
|
|
261
|
+
File.write(out_file, finalize_markdown(
|
|
262
|
+
content,
|
|
263
|
+
canonical_output_path: output_path,
|
|
264
|
+
current_output_path: destination_path
|
|
265
|
+
))
|
|
266
266
|
end
|
|
267
267
|
end
|
|
268
268
|
end
|
|
@@ -276,7 +276,11 @@ class RDoc::Generator::Markdown
|
|
|
276
276
|
out_file.dirname.mkpath
|
|
277
277
|
|
|
278
278
|
content = markdownify(page.description)
|
|
279
|
-
File.write(out_file, finalize_markdown(
|
|
279
|
+
File.write(out_file, finalize_markdown(
|
|
280
|
+
content,
|
|
281
|
+
canonical_output_path: page_output_path(page),
|
|
282
|
+
current_output_path: page_output_path(page)
|
|
283
|
+
))
|
|
280
284
|
end
|
|
281
285
|
end
|
|
282
286
|
|
|
@@ -351,6 +355,30 @@ class RDoc::Generator::Markdown
|
|
|
351
355
|
class_doc_for(code_object).fetch(:legacy_paths)
|
|
352
356
|
end
|
|
353
357
|
|
|
358
|
+
# Renders a class or module reference, linking it when its documentation is emitted.
|
|
359
|
+
#
|
|
360
|
+
# @param target [RDoc::ClassModule, String] Resolved RDoc object or unresolved name.
|
|
361
|
+
# @param label [String] Visible reference text.
|
|
362
|
+
#
|
|
363
|
+
# @return [String] Markdown text or link.
|
|
364
|
+
def metadata_reference(target, label)
|
|
365
|
+
class_doc = @class_docs_by_name[normalized_full_name(target.full_name)] if target.respond_to?(:full_name)
|
|
366
|
+
cell = metadata_table_cell(label)
|
|
367
|
+
return cell unless class_doc
|
|
368
|
+
|
|
369
|
+
"[#{cell}](#{class_doc.fetch(:output_path)})"
|
|
370
|
+
end
|
|
371
|
+
|
|
372
|
+
# Escapes text for a Markdown table cell.
|
|
373
|
+
#
|
|
374
|
+
# @param value [String] Metadata text.
|
|
375
|
+
#
|
|
376
|
+
# @return [String] GFM table-safe Markdown text.
|
|
377
|
+
def metadata_table_cell(value)
|
|
378
|
+
value.gsub(/[[:blank:]]*\R[[:blank:]]*/, " ")
|
|
379
|
+
.gsub(/[\\|]/) { |character| "\\#{character}" }
|
|
380
|
+
end
|
|
381
|
+
|
|
354
382
|
# Converts RDoc HTML into GitHub-flavored Markdown.
|
|
355
383
|
#
|
|
356
384
|
# @param input [String] RDoc HTML fragment.
|
|
@@ -589,12 +617,17 @@ class RDoc::Generator::Markdown
|
|
|
589
617
|
# Applies final whitespace and link normalization before writing Markdown.
|
|
590
618
|
#
|
|
591
619
|
# @param content [String] Markdown content.
|
|
620
|
+
# @param canonical_output_path [String] Canonical output path used to resolve links.
|
|
592
621
|
# @param current_output_path [String] Output path for the file being written.
|
|
593
622
|
#
|
|
594
623
|
# @return [String] Final Markdown ending with one newline.
|
|
595
|
-
def finalize_markdown(content, current_output_path:)
|
|
624
|
+
def finalize_markdown(content, canonical_output_path:, current_output_path:)
|
|
596
625
|
output = content.lines.map(&:rstrip).join("\n")
|
|
597
|
-
output = normalize_internal_links(
|
|
626
|
+
output = normalize_internal_links(
|
|
627
|
+
output,
|
|
628
|
+
canonical_output_path: canonical_output_path,
|
|
629
|
+
current_output_path: current_output_path
|
|
630
|
+
)
|
|
598
631
|
output = output.sub(/\n{3,}/, "\n\n")
|
|
599
632
|
"#{output}\n"
|
|
600
633
|
end
|
|
@@ -671,10 +704,12 @@ class RDoc::Generator::Markdown
|
|
|
671
704
|
# Rewrites local Markdown links relative to the current output file.
|
|
672
705
|
#
|
|
673
706
|
# @param markdown [String] Markdown content.
|
|
707
|
+
# @param canonical_output_path [String] Canonical output path used to resolve links.
|
|
674
708
|
# @param current_output_path [String] Output path for the file being written.
|
|
675
709
|
#
|
|
676
710
|
# @return [String] Markdown with normalized internal links.
|
|
677
|
-
def normalize_internal_links(markdown, current_output_path:)
|
|
711
|
+
def normalize_internal_links(markdown, canonical_output_path:, current_output_path:)
|
|
712
|
+
canonical_dir = Pathname.new(canonical_output_path).dirname
|
|
678
713
|
current_dir = Pathname.new(current_output_path).dirname
|
|
679
714
|
|
|
680
715
|
markdown.gsub(%r{\]\(([^)]+)\)}) do
|
|
@@ -682,7 +717,7 @@ class RDoc::Generator::Markdown
|
|
|
682
717
|
path = target.sub(/[?#].*\z/, "")
|
|
683
718
|
suffix = target[path.length..]
|
|
684
719
|
|
|
685
|
-
resolved = resolve_output_path(path,
|
|
720
|
+
resolved = resolve_output_path(path, canonical_dir)
|
|
686
721
|
rewritten = resolved ? Pathname.new(resolved).relative_path_from(current_dir) : path
|
|
687
722
|
"](#{rewritten}#{suffix})"
|
|
688
723
|
end
|
|
@@ -854,6 +889,7 @@ class RDoc::Generator::Markdown
|
|
|
854
889
|
|
|
855
890
|
@class_docs = build_class_docs(@store.all_classes_and_modules.sort)
|
|
856
891
|
@class_docs_by_object_id = @class_docs.to_h { |doc| [doc.fetch(:klass).object_id, doc] }
|
|
892
|
+
@class_docs_by_name = @class_docs.to_h { |doc| [doc.fetch(:display_name), doc] }
|
|
857
893
|
@classes = @class_docs.map { |doc| doc.fetch(:klass) }
|
|
858
894
|
@pages = @store.all_files.select(&:text?).select(&:display?).sort_by(&:base_name)
|
|
859
895
|
@rbs_method_signatures = RbsSignatureIndex.build(Array(@options.files), @base_dir, @store)
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
# <%= klass.type.capitalize %> <%= display_name(klass) %><%= anchor(klass.aref.strip) %>
|
|
2
|
+
<%- superclass = klass.superclass if klass.type == "class" -%>
|
|
3
|
+
<%- includes = klass.includes -%>
|
|
4
|
+
<%- source_files = klass.in_files -%>
|
|
5
|
+
<%- if superclass || !includes.empty? || !source_files.empty? -%>
|
|
6
|
+
|
|
7
|
+
| | |
|
|
8
|
+
| --- | --- |
|
|
9
|
+
<%- if superclass -%>
|
|
10
|
+
| **Inherits** | <%= metadata_reference(superclass, superclass.respond_to?(:full_name) ? superclass.full_name : superclass) %> |
|
|
11
|
+
<%- end -%>
|
|
12
|
+
<%- unless includes.empty? -%>
|
|
13
|
+
| **Includes** | <%= includes.map { |mixin| metadata_reference(mixin.module, mixin.name) }.join(", ") %> |
|
|
14
|
+
<%- end -%>
|
|
15
|
+
<%- unless source_files.empty? -%>
|
|
16
|
+
| **Defined in** | <%= source_files.map { |file| metadata_table_cell(file.relative_name) }.join(", ") %> |
|
|
17
|
+
<%- end -%>
|
|
18
|
+
<%- end -%>
|
|
19
|
+
|
|
2
20
|
<%- class_description = describe(klass) -%>
|
|
3
21
|
<%- unless class_description.empty? -%>
|
|
4
22
|
<%= class_description %>
|