yard-relative_markdown_links 0.4.1 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 80b7c7cab3b827823c2078b115951199a31f73e9950d5a59c8ef3934e722a369
4
- data.tar.gz: 34a0cacb3db651d342c1dca6df506bf71db93b63debc9a8bbae247743dd2d5d2
3
+ metadata.gz: 7929abc6b2c9d7a6b62040d0adc96142a310aa1bdb624b5de4d30955797f40ef
4
+ data.tar.gz: 9cddf2bc9e6d62b6021f5b8cc18bf4c9f77066078eab9ea21c14392e1fbc86c7
5
5
  SHA512:
6
- metadata.gz: 7b011be39b3c63128218ea975e62dd4ee94c126582f99a2291dfe6674c0b80f807844d1b47f40844862aa17b81ddbd4333019cba2b6490d580075fad0a5d0ef8
7
- data.tar.gz: c53087dbd10685c87f2ed4c1770942f2679fe444eb218dff93e9c46218c076861160d6b063cbe6d9ef7f9bd1599117508112aee22d30e2b6dc4bf77b6596ebaa
6
+ metadata.gz: 060eaddb81656064827475056a067a65fc967bcdb3063808df2566a7caea23ae6492c02411db5c059ac4c3843316bc7974642d0df86524721a9c115cba0c3023
7
+ data.tar.gz: 0b933386677e1875c365714e7056e2f4b82fbde7f8f0fb36caa28bb28b3ba7fb14c69d6d361b41207f543311597b3dccec0b1d0813ee0e456444b8b22b6f6f18
data/CHANGELOG.md CHANGED
@@ -8,6 +8,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
8
8
  ## [Unreleased]
9
9
  No notable changes.
10
10
 
11
+ ## [0.5.0] - 2023-06-12
12
+ ### Changed
13
+ * Require Ruby ≥ 3.0 ([#175](https://github.com/haines/yard-relative_markdown_links/pull/175))
14
+ * Test against Ruby 3.1 ([#107](https://github.com/haines/yard-relative_markdown_links/pull/107))
15
+ * Test against Ruby 3.2 ([#175](https://github.com/haines/yard-relative_markdown_links/pull/175))
16
+ * Require Nokogiri ≥ 1.14.3 ([#175](https://github.com/haines/yard-relative_markdown_links/pull/175))
17
+
18
+ ### Fixed
19
+ * Handle links generated by recent versions of RDoc ([#175](https://github.com/haines/yard-relative_markdown_links/pull/175))
20
+
11
21
  ## [0.4.1] - 2021-11-15
12
22
  ### Changed
13
23
  * Require MFA to publish gem ([#92](https://github.com/haines/yard-relative_markdown_links/pull/92))
@@ -37,7 +47,8 @@ No notable changes.
37
47
  ### Added
38
48
  - A YARD plugin to allow relative links between Markdown files ([#1](https://github.com/haines/yard-relative_markdown_links/pull/1))
39
49
 
40
- [Unreleased]: https://github.com/haines/yard-relative_markdown_links/compare/v0.4.1...HEAD
50
+ [Unreleased]: https://github.com/haines/yard-relative_markdown_links/compare/v0.5.0...HEAD
51
+ [0.5.0]: https://github.com/haines/yard-relative_markdown_links/compare/v0.4.1...v0.5.0
41
52
  [0.4.1]: https://github.com/haines/yard-relative_markdown_links/compare/v0.4.0...v0.4.1
42
53
  [0.4.0]: https://github.com/haines/yard-relative_markdown_links/compare/v0.3.0...v0.4.0
43
54
  [0.3.0]: https://github.com/haines/yard-relative_markdown_links/compare/v0.2.0...v0.3.0
@@ -3,6 +3,6 @@
3
3
  module YARD
4
4
  module RelativeMarkdownLinks
5
5
  # Current version of the yard-relative_markdown_links gem.
6
- VERSION = "0.4.1"
6
+ VERSION = "0.5.0"
7
7
  end
8
8
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "nokogiri"
4
+ require "set"
4
5
  require "uri"
5
6
  require "yard"
6
7
  require "yard/relative_markdown_links/version"
@@ -18,14 +19,35 @@ module YARD # rubocop:disable Style/Documentation
18
19
  # @param [String] text the HTML fragment in which to resolve links.
19
20
  # @return [String] HTML with relative links to extra files converted to `{file:}` links.
20
21
  def resolve_links(text)
22
+ return super unless options.files
23
+
24
+ filenames = options.files.to_set(&:filename)
25
+
26
+ rdoc_filenames = filenames.filter_map { |filename|
27
+ # https://github.com/ruby/rdoc/blob/0e060c69f51ec4a877e5cde69b31d47eaeb2a2b9/lib/rdoc/markup/to_html.rb#L364-L366
28
+ match = %r{\A(?<dirname>(?:[^/#]*/)*+)(?<basename>[^/#]+)\.(?<ext>rb|rdoc|md)\z}i.match(filename)
29
+ next unless match
30
+
31
+ ["#{match[:dirname]}#{match[:basename].tr('.', '_')}_#{match[:ext]}.html", filename]
32
+ }.to_h
33
+
21
34
  html = Nokogiri::HTML.fragment(text)
35
+
22
36
  html.css("a[href]").each do |link|
23
37
  href = URI(link["href"])
38
+ next unless href.relative?
39
+
40
+ if filenames.include?(href.path)
41
+ link.replace "{file:#{href} #{link.inner_html}}"
42
+ next
43
+ end
24
44
 
25
- next unless href.relative? && options.files.map(&:filename).include?(href.path)
45
+ href.path = rdoc_filenames[href.path]
46
+ next unless href.path && filenames.include?(href.path)
26
47
 
27
48
  link.replace "{file:#{href} #{link.inner_html}}"
28
49
  end
50
+
29
51
  super(html.to_s)
30
52
  end
31
53
  end
@@ -16,7 +16,16 @@ Gem::Specification.new do |spec|
16
16
  spec.homepage = "https://github.com/haines/yard-relative_markdown_links"
17
17
  spec.license = "MIT"
18
18
 
19
- spec.files = Dir.chdir(__dir__) { `git ls-files -z`.split("\x0").reject { |path| path.match(%r{^test/}) } }
19
+ spec.files = Dir[
20
+ "lib/**/*.rb",
21
+ ".yardopts",
22
+ "CHANGELOG.md",
23
+ "CODE_OF_CONDUCT.md",
24
+ "LICENSE.md",
25
+ "README.md",
26
+ "yard-relative_markdown_links.gemspec"
27
+ ]
28
+
20
29
  spec.require_paths = ["lib"]
21
30
 
22
31
  spec.metadata["bug_tracker_uri"] = "#{spec.homepage}/issues"
@@ -27,7 +36,7 @@ Gem::Specification.new do |spec|
27
36
  spec.metadata["source_code_uri"] = spec.homepage
28
37
  spec.metadata["yard.run"] = "yri"
29
38
 
30
- spec.required_ruby_version = ">= 2.5"
39
+ spec.required_ruby_version = ">= 3.0"
31
40
 
32
- spec.add_dependency "nokogiri", "~> 1.8"
41
+ spec.add_dependency "nokogiri", ">= 1.14.3", "< 2"
33
42
  end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard-relative_markdown_links
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Haines
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-15 00:00:00.000000000 Z
11
+ date: 2023-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.8'
19
+ version: 1.14.3
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
- - - "~>"
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 1.14.3
30
+ - - "<"
25
31
  - !ruby/object:Gem::Version
26
- version: '1.8'
32
+ version: '2'
27
33
  description:
28
34
  email:
29
35
  - andrew@haines.org.nz
@@ -31,24 +37,11 @@ executables: []
31
37
  extensions: []
32
38
  extra_rdoc_files: []
33
39
  files:
34
- - ".github/dependabot.yml"
35
- - ".github/workflows/pull-request.yml"
36
- - ".gitignore"
37
- - ".rubocop.yml"
38
- - ".ruby-version"
39
40
  - ".yardopts"
40
41
  - CHANGELOG.md
41
42
  - CODE_OF_CONDUCT.md
42
- - Gemfile
43
- - Gemfile.lock
44
43
  - LICENSE.md
45
44
  - README.md
46
- - Rakefile
47
- - bin/bundle
48
- - bin/console
49
- - bin/install-bundler
50
- - bin/rake
51
- - bin/setup
52
45
  - lib/yard-relative_markdown_links.rb
53
46
  - lib/yard/relative_markdown_links.rb
54
47
  - lib/yard/relative_markdown_links/version.rb
@@ -72,14 +65,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
72
65
  requirements:
73
66
  - - ">="
74
67
  - !ruby/object:Gem::Version
75
- version: '2.5'
68
+ version: '3.0'
76
69
  required_rubygems_version: !ruby/object:Gem::Requirement
77
70
  requirements:
78
71
  - - ">="
79
72
  - !ruby/object:Gem::Version
80
73
  version: '0'
81
74
  requirements: []
82
- rubygems_version: 3.2.31
75
+ rubygems_version: 3.4.13
83
76
  signing_key:
84
77
  specification_version: 4
85
78
  summary: A YARD plugin to allow relative links between Markdown files
@@ -1,16 +0,0 @@
1
- version: 2
2
-
3
- updates:
4
- - package-ecosystem: bundler
5
- directory: /
6
- schedule:
7
- interval: weekly
8
- reviewers:
9
- - haines
10
-
11
- - package-ecosystem: github-actions
12
- directory: /
13
- schedule:
14
- interval: weekly
15
- reviewers:
16
- - haines
@@ -1,62 +0,0 @@
1
- name: pull-request
2
-
3
- on:
4
- - pull_request
5
-
6
- jobs:
7
- test:
8
- strategy:
9
- matrix:
10
- ruby:
11
- - "2.5"
12
- - "2.6"
13
- - "2.7"
14
- - "3.0"
15
-
16
- name: Ruby ${{ matrix.ruby }}
17
-
18
- runs-on: ubuntu-latest
19
-
20
- container:
21
- image: ruby:${{ matrix.ruby }}-alpine
22
-
23
- env:
24
- BUNDLE_PATH: ${{ github.workspace }}/vendor/bundle
25
-
26
- steps:
27
- - name: Install dependencies
28
- run: apk add build-base git tar
29
-
30
- - name: Check out source code
31
- uses: actions/checkout@v2
32
-
33
- - name: Install Bundler
34
- run: bin/install-bundler
35
-
36
- - name: Compute cache key
37
- id: cache-key
38
- run: |
39
- source /etc/os-release
40
- printf \
41
- "::set-output name=cache-key::alpine-%s-ruby-%s\n" \
42
- "${VERSION_ID}" \
43
- "${RUBY_VERSION}"
44
-
45
- - name: Cache gems
46
- uses: actions/cache@v2
47
- with:
48
- key: ${{ steps.cache-key.outputs.cache-key }}-gems-${{ hashFiles('Gemfile.lock') }}
49
- path: vendor/bundle
50
-
51
- - name: Install gems
52
- run: bin/bundle install
53
- env:
54
- BUNDLE_FROZEN: true
55
- BUNDLE_JOBS: 4
56
- BUNDLE_RETRY: 3
57
-
58
- - name: Run RuboCop
59
- run: bin/rake rubocop
60
-
61
- - name: Run tests
62
- run: bin/rake test
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- /.bundle/
2
- /.yardoc/
3
- /doc/
4
- /pkg/
data/.rubocop.yml DELETED
@@ -1,53 +0,0 @@
1
- require:
2
- - rubocop-minitest
3
- - rubocop-rake
4
-
5
- AllCops:
6
- NewCops: enable
7
- TargetRubyVersion: 2.5
8
- Exclude:
9
- - bin/bundle
10
- - bin/rake
11
- - vendor/bundle/**/*
12
-
13
- Layout/LineLength:
14
- Enabled: false
15
-
16
- Metrics/MethodLength:
17
- Enabled: false
18
-
19
- Naming/FileName:
20
- Exclude:
21
- - lib/yard-relative_markdown_links.rb
22
-
23
- Style/BlockDelimiters:
24
- EnforcedStyle: semantic
25
-
26
- Style/Documentation:
27
- Exclude:
28
- - test/**/*
29
-
30
- Style/HashEachMethods:
31
- Enabled: true
32
-
33
- Style/HashSyntax:
34
- Exclude:
35
- - Rakefile
36
-
37
- Style/HashTransformKeys:
38
- Enabled: true
39
-
40
- Style/HashTransformValues:
41
- Enabled: true
42
-
43
- Style/Lambda:
44
- EnforcedStyle: literal
45
-
46
- Style/StringLiterals:
47
- EnforcedStyle: double_quotes
48
-
49
- Style/SymbolArray:
50
- EnforcedStyle: brackets
51
-
52
- Style/WordArray:
53
- EnforcedStyle: brackets
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 3.0.2
data/Gemfile DELETED
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- gemspec
6
-
7
- gem "bundler"
8
- gem "minitest"
9
- gem "pry"
10
- gem "rake"
11
- gem "rubocop"
12
- gem "rubocop-minitest"
13
- gem "rubocop-rake"
14
- gem "yard"
data/Gemfile.lock DELETED
@@ -1,69 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- yard-relative_markdown_links (0.4.1)
5
- nokogiri (~> 1.8)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- ast (2.4.2)
11
- coderay (1.1.3)
12
- method_source (1.0.0)
13
- mini_portile2 (2.6.1)
14
- minitest (5.14.4)
15
- nokogiri (1.12.5)
16
- mini_portile2 (~> 2.6.1)
17
- racc (~> 1.4)
18
- nokogiri (1.12.5-x86_64-darwin)
19
- racc (~> 1.4)
20
- nokogiri (1.12.5-x86_64-linux)
21
- racc (~> 1.4)
22
- parallel (1.21.0)
23
- parser (3.0.2.0)
24
- ast (~> 2.4.1)
25
- pry (0.14.1)
26
- coderay (~> 1.1)
27
- method_source (~> 1.0)
28
- racc (1.5.2)
29
- rainbow (3.0.0)
30
- rake (13.0.6)
31
- regexp_parser (2.1.1)
32
- rexml (3.2.5)
33
- rubocop (1.23.0)
34
- parallel (~> 1.10)
35
- parser (>= 3.0.0.0)
36
- rainbow (>= 2.2.2, < 4.0)
37
- regexp_parser (>= 1.8, < 3.0)
38
- rexml
39
- rubocop-ast (>= 1.12.0, < 2.0)
40
- ruby-progressbar (~> 1.7)
41
- unicode-display_width (>= 1.4.0, < 3.0)
42
- rubocop-ast (1.13.0)
43
- parser (>= 3.0.1.1)
44
- rubocop-minitest (0.16.0)
45
- rubocop (>= 0.90, < 2.0)
46
- rubocop-rake (0.6.0)
47
- rubocop (~> 1.0)
48
- ruby-progressbar (1.11.0)
49
- unicode-display_width (2.1.0)
50
- yard (0.9.26)
51
-
52
- PLATFORMS
53
- ruby
54
- x86_64-darwin-20
55
- x86_64-linux
56
-
57
- DEPENDENCIES
58
- bundler
59
- minitest
60
- pry
61
- rake
62
- rubocop
63
- rubocop-minitest
64
- rubocop-rake
65
- yard
66
- yard-relative_markdown_links!
67
-
68
- BUNDLED WITH
69
- 2.2.31
data/Rakefile DELETED
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rake/testtask"
5
- require "rubocop/rake_task"
6
- require "yard"
7
-
8
- Rake::TestTask.new do |task|
9
- task.test_files = FileList["test/**/*_test.rb"]
10
- end
11
-
12
- RuboCop::RakeTask.new
13
-
14
- desc "Generate documentation"
15
- YARD::Rake::YardocTask.new :doc
16
- CLOBBER << "doc/"
17
-
18
- task :default => [:doc, :rubocop, :test]
data/bin/bundle DELETED
@@ -1,105 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- #
5
- # This file was generated by Bundler.
6
- #
7
- # The application 'bundle' is installed as part of a gem, and
8
- # this file is here to facilitate running it.
9
- #
10
-
11
- require "rubygems"
12
-
13
- m = Module.new do
14
- module_function
15
-
16
- def invoked_as_script?
17
- File.expand_path($0) == File.expand_path(__FILE__)
18
- end
19
-
20
- def env_var_version
21
- ENV["BUNDLER_VERSION"]
22
- end
23
-
24
- def cli_arg_version
25
- return unless invoked_as_script? # don't want to hijack other binstubs
26
- return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27
- bundler_version = nil
28
- update_index = nil
29
- ARGV.each_with_index do |a, i|
30
- if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31
- bundler_version = a
32
- end
33
- next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
- bundler_version = $1 || ">= 0.a"
35
- update_index = i
36
- end
37
- bundler_version
38
- end
39
-
40
- def gemfile
41
- gemfile = ENV["BUNDLE_GEMFILE"]
42
- return gemfile if gemfile && !gemfile.empty?
43
-
44
- File.expand_path("../../Gemfile", __FILE__)
45
- end
46
-
47
- def lockfile
48
- lockfile =
49
- case File.basename(gemfile)
50
- when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51
- else "#{gemfile}.lock"
52
- end
53
- File.expand_path(lockfile)
54
- end
55
-
56
- def lockfile_version
57
- return unless File.file?(lockfile)
58
- lockfile_contents = File.read(lockfile)
59
- return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60
- Regexp.last_match(1)
61
- end
62
-
63
- def bundler_version
64
- @bundler_version ||= begin
65
- env_var_version || cli_arg_version ||
66
- lockfile_version || "#{Gem::Requirement.default}.a"
67
- end
68
- end
69
-
70
- def load_bundler!
71
- ENV["BUNDLE_GEMFILE"] ||= gemfile
72
-
73
- # must dup string for RG < 1.8 compatibility
74
- activate_bundler(bundler_version.dup)
75
- end
76
-
77
- def activate_bundler(bundler_version)
78
- if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
79
- bundler_version = "< 2"
80
- end
81
- gem_error = activation_error_handling do
82
- gem "bundler", bundler_version
83
- end
84
- return if gem_error.nil?
85
- require_error = activation_error_handling do
86
- require "bundler/version"
87
- end
88
- return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
89
- warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
90
- exit 42
91
- end
92
-
93
- def activation_error_handling
94
- yield
95
- nil
96
- rescue StandardError, LoadError => e
97
- e
98
- end
99
- end
100
-
101
- m.load_bundler!
102
-
103
- if m.invoked_as_script?
104
- load Gem.bin_path("bundler", "bundle")
105
- end
data/bin/console DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
- require "yard/relative_markdown_links"
6
-
7
- require "pry"
8
- Pry.start
data/bin/install-bundler DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- Gem.install "bundler", Gem::BundlerVersionFinder.bundler_version
data/bin/rake DELETED
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- #
5
- # This file was generated by Bundler.
6
- #
7
- # The application 'rake' is installed as part of a gem, and
8
- # this file is here to facilitate running it.
9
- #
10
-
11
- require "pathname"
12
- ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
- Pathname.new(__FILE__).realpath)
14
-
15
- bundle_binstub = File.expand_path("../bundle", __FILE__)
16
-
17
- if File.file?(bundle_binstub)
18
- if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
- load(bundle_binstub)
20
- else
21
- abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
- Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
- end
24
- end
25
-
26
- require "rubygems"
27
- require "bundler/setup"
28
-
29
- load Gem.bin_path("rake", "rake")
data/bin/setup DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
-
4
- bundle install