rdoc-markdown 0.19.1 → 0.20.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d9e8dcc9378d9424beb37d2e482b881ca5b536af4150a6caed14e872a9b4a5d
4
- data.tar.gz: 378ce21e41ab926bdf056d67445aa49ad412873c37ac89a4840907acac097522
3
+ metadata.gz: 5ae68a40db5d99f60034820bab835a6a6d17c9db00dd3d38d3d47bd7da73743b
4
+ data.tar.gz: 65a59f988b16411b5914dc5d7de8496efac2a12a67b835ac50b9fa478c1492fd
5
5
  SHA512:
6
- metadata.gz: 23d9c7b35a7bbf4366c49f192adb0061ca190331d024bc37d9ed24554cce44a2892bc7b21b86fd0c7678597c9fa1105d2ba2705e63e811bd0cf75286cd839537
7
- data.tar.gz: b484ca5aeda4fcc59f6d029190bc15c1915fbf71e91c9a4c1db5fe80467661ffe428291c6068788d3bfec6fe69800a89f6124886e49a910fdc44f97b4914e106
6
+ metadata.gz: c8c080f1704dff5d1a4ca256676fbf5f1a69d51a9ec0223e952cceb37837f840274a2bb39e44c70801379ef72d7a70d3811e96810de1d5a568341f6ec2a74875
7
+ data.tar.gz: 10a07e634578b0ac0290d91e4b1f52f6af36e0cb30349fa8d519970020b55246e719dec427f64c8ad59f6505def782e8709e98b6ff4be01f5494637af5cb265c
data/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.20.1
6
+
7
+ - Don't offset headings for commets
8
+
9
+ ## 0.20.0
10
+
11
+ - Restore legacy anchors in a single Markdown substitution pass.
12
+ - Reduce internal-link candidate construction and deduplication work.
13
+
5
14
  ## 0.19.1
6
15
 
7
16
  - Store fullpath for files, instead of just file names.
@@ -14,7 +14,7 @@ class RDoc::Generator::Markdown::Conversion
14
14
  document = fragment.document
15
15
  fragment.css("a").each { |link| normalize_link(link, document) }
16
16
  markdown = ReverseMarkdown.convert(fragment, github_flavored: true).dup
17
- anchor_aliases.each { |token, id| markdown.gsub!(token, %(<a id="#{id}"></a>)) }
17
+ markdown.gsub!(Regexp.union(anchor_aliases.keys), anchor_aliases)
18
18
  normalize_definition_list_code_blocks(markdown).rstrip.gsub(/^(#+)(\s)/) do
19
19
  "#{"#" * [Regexp.last_match(1).length + heading_level_offset, 6].min}#{Regexp.last_match(2)}"
20
20
  end
@@ -101,13 +101,13 @@ class RDoc::Generator::Markdown::Conversion
101
101
  #
102
102
  # @param anchors [Nokogiri::XML::NodeSet] Legacy anchor spans.
103
103
  #
104
- # @return [Array<Array<String>>] Token and anchor ID pairs.
104
+ # @return [Hash{String => String}] Token-to-anchor HTML lookup.
105
105
  def tokenize_legacy_anchors(anchors)
106
- anchors.map.with_index do |span, index|
106
+ anchors.each.with_index.to_h do |span, index|
107
107
  token = "RDocMarkdownAnchor#{index}End"
108
- id = span["id"]
108
+ anchor = %(<a id="#{span["id"]}"></a>)
109
109
  span.replace(token)
110
- [token, id]
110
+ [token, anchor]
111
111
  end
112
112
  end
113
113
 
@@ -96,6 +96,8 @@ module RDoc::Generator::Markdown::Descriptions
96
96
  description = render_description(code_object)
97
97
  return fallback.to_s if description.empty?
98
98
 
99
+ comment = code_object.comment
100
+ heading_level_offset = 0 if RDoc::Comment === comment && comment.format == "markdown"
99
101
  RDoc::Generator::Markdown::Conversion.markdownify(description, heading_level_offset: heading_level_offset)
100
102
  end
101
103
 
@@ -83,11 +83,16 @@ module RDoc::Generator::Markdown::Paths
83
83
  #
84
84
  # @return [String, nil] Resolved output path, or nil when unresolved.
85
85
  def self.resolve_output_path_from(path, current_dir, state)
86
+ return if path.empty? || path.match?(%r{\A(?:[a-z][a-z0-9+.-]*:|//)}i)
87
+
86
88
  candidates = [path, path.delete_prefix("#{state.root_path_segment}/")]
87
89
  candidates += candidates.map { |candidate| candidate.sub(/_(md|markdown)\.md\z/i, '.\1') }
88
- expanded_candidates = candidates.map { |candidate| current_dir.join(candidate).cleanpath.to_s }
90
+ candidates.uniq!
89
91
 
90
- (candidates + expanded_candidates).find { |candidate| state.known_output_paths.include?(candidate) }
92
+ candidates.find { |candidate| state.known_output_paths.include?(candidate) } ||
93
+ candidates.lazy
94
+ .map { |candidate| current_dir.join(candidate).cleanpath.to_s }
95
+ .find { |candidate| state.known_output_paths.include?(candidate) }
91
96
  end
92
97
 
93
98
  # Normalizes an input filename into an output-relative source path.
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "erb"
4
+ # standard:disable Lint/RedundantRequireStatement
5
+ require "set"
6
+ # standard:enable Lint/RedundantRequireStatement
4
7
  require "reverse_markdown"
5
8
  require "csv"
6
9
  require "fileutils"
@@ -173,8 +176,8 @@ class RDoc::Generator::Markdown
173
176
  classes: classes,
174
177
  pages: pages,
175
178
  class_output_paths: class_output_paths,
176
- markdown_output_object_ids: (classes + pages).map(&:object_id),
177
- known_output_paths: class_output_paths.values + pages.map { |page| page_output_path(page) },
179
+ markdown_output_object_ids: (classes + pages).to_set(&:object_id),
180
+ known_output_paths: class_output_paths.values.to_set.merge(pages.map { |page| page_output_path(page) }),
178
181
  root_path_segment: Pathname.new(options.root || ".").basename
179
182
  )
180
183
  end
@@ -5,6 +5,6 @@ module Rdoc
5
5
  # @private
6
6
  module Markdown
7
7
  # @private
8
- VERSION = "0.19.1"
8
+ VERSION = "0.20.1"
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdoc-markdown
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.1
4
+ version: 0.20.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stanislav (Stas) Katkov