yard-relative_markdown_links 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1204730ec292962c6e56006c41f2523609ca219934064613243e3e5b39100dc2
4
- data.tar.gz: 66e8ad922dccac4cd4cc0760fcc64814c553f93363d2bb3ec25122617366eb77
3
+ metadata.gz: 7929abc6b2c9d7a6b62040d0adc96142a310aa1bdb624b5de4d30955797f40ef
4
+ data.tar.gz: 9cddf2bc9e6d62b6021f5b8cc18bf4c9f77066078eab9ea21c14392e1fbc86c7
5
5
  SHA512:
6
- metadata.gz: 355a58f58e8221968bde3e38c230e47df2d2be06c0131083b3f664c6c3c9c8dd55c44f0bf874efdd387748fcd2e5702c619de6faa2c76d21632e0e6bca93713d
7
- data.tar.gz: 62263d9574edd8118d21c91ed3d21edf28928c59436f6ff5268e549b8834f7d9c73aa721a6618b8ef4114c84e9632ea5fc5a6a9892cdb71966831b53c64d6c0b
6
+ metadata.gz: 060eaddb81656064827475056a067a65fc967bcdb3063808df2566a7caea23ae6492c02411db5c059ac4c3843316bc7974642d0df86524721a9c115cba0c3023
7
+ data.tar.gz: 0b933386677e1875c365714e7056e2f4b82fbde7f8f0fb36caa28bb28b3ba7fb14c69d6d361b41207f543311597b3dccec0b1d0813ee0e456444b8b22b6f6f18
data/CHANGELOG.md CHANGED
@@ -8,6 +8,20 @@ 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
+
21
+ ## [0.4.1] - 2021-11-15
22
+ ### Changed
23
+ * Require MFA to publish gem ([#92](https://github.com/haines/yard-relative_markdown_links/pull/92))
24
+
11
25
  ## [0.4.0] - 2021-01-29
12
26
  ### Changed
13
27
  * Require Ruby ≥ 2.5 ([#40](https://github.com/haines/yard-relative_markdown_links/pull/40))
@@ -33,7 +47,9 @@ No notable changes.
33
47
  ### Added
34
48
  - A YARD plugin to allow relative links between Markdown files ([#1](https://github.com/haines/yard-relative_markdown_links/pull/1))
35
49
 
36
- [Unreleased]: https://github.com/haines/yard-relative_markdown_links/compare/v0.4.0...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
52
+ [0.4.1]: https://github.com/haines/yard-relative_markdown_links/compare/v0.4.0...v0.4.1
37
53
  [0.4.0]: https://github.com/haines/yard-relative_markdown_links/compare/v0.3.0...v0.4.0
38
54
  [0.3.0]: https://github.com/haines/yard-relative_markdown_links/compare/v0.2.0...v0.3.0
39
55
  [0.2.0]: https://github.com/haines/yard-relative_markdown_links/compare/v0.1.2...v0.2.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.0"
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,17 +16,27 @@ 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"
23
32
  spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
24
33
  spec.metadata["documentation_uri"] = "https://haines.github.io/yard-relative_markdown_links/"
25
34
  spec.metadata["homepage_uri"] = spec.homepage
35
+ spec.metadata["rubygems_mfa_required"] = "true"
26
36
  spec.metadata["source_code_uri"] = spec.homepage
27
37
  spec.metadata["yard.run"] = "yri"
28
38
 
29
- spec.required_ruby_version = ">= 2.5"
39
+ spec.required_ruby_version = ">= 3.0"
30
40
 
31
- spec.add_dependency "nokogiri", "~> 1.8"
41
+ spec.add_dependency "nokogiri", ">= 1.14.3", "< 2"
32
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.0
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-01-29 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
@@ -61,6 +54,7 @@ metadata:
61
54
  changelog_uri: https://github.com/haines/yard-relative_markdown_links/blob/main/CHANGELOG.md
62
55
  documentation_uri: https://haines.github.io/yard-relative_markdown_links/
63
56
  homepage_uri: https://github.com/haines/yard-relative_markdown_links
57
+ rubygems_mfa_required: 'true'
64
58
  source_code_uri: https://github.com/haines/yard-relative_markdown_links
65
59
  yard.run: yri
66
60
  post_install_message:
@@ -71,14 +65,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
71
65
  requirements:
72
66
  - - ">="
73
67
  - !ruby/object:Gem::Version
74
- version: '2.5'
68
+ version: '3.0'
75
69
  required_rubygems_version: !ruby/object:Gem::Requirement
76
70
  requirements:
77
71
  - - ">="
78
72
  - !ruby/object:Gem::Version
79
73
  version: '0'
80
74
  requirements: []
81
- rubygems_version: 3.2.7
75
+ rubygems_version: 3.4.13
82
76
  signing_key:
83
77
  specification_version: 4
84
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.0
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,64 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- yard-relative_markdown_links (0.4.0)
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
- minitest (5.14.3)
14
- nokogiri (1.11.1-x86_64-darwin)
15
- racc (~> 1.4)
16
- nokogiri (1.11.1-x86_64-linux)
17
- racc (~> 1.4)
18
- parallel (1.20.1)
19
- parser (3.0.0.0)
20
- ast (~> 2.4.1)
21
- pry (0.13.1)
22
- coderay (~> 1.1)
23
- method_source (~> 1.0)
24
- racc (1.5.2)
25
- rainbow (3.0.0)
26
- rake (13.0.3)
27
- regexp_parser (2.0.3)
28
- rexml (3.2.4)
29
- rubocop (1.9.0)
30
- parallel (~> 1.10)
31
- parser (>= 3.0.0.0)
32
- rainbow (>= 2.2.2, < 4.0)
33
- regexp_parser (>= 1.8, < 3.0)
34
- rexml
35
- rubocop-ast (>= 1.2.0, < 2.0)
36
- ruby-progressbar (~> 1.7)
37
- unicode-display_width (>= 1.4.0, < 3.0)
38
- rubocop-ast (1.4.1)
39
- parser (>= 2.7.1.5)
40
- rubocop-minitest (0.10.3)
41
- rubocop (>= 0.87, < 2.0)
42
- rubocop-rake (0.5.1)
43
- rubocop
44
- ruby-progressbar (1.11.0)
45
- unicode-display_width (2.0.0)
46
- yard (0.9.26)
47
-
48
- PLATFORMS
49
- x86_64-darwin-20
50
- x86_64-linux
51
-
52
- DEPENDENCIES
53
- bundler
54
- minitest
55
- pry
56
- rake
57
- rubocop
58
- rubocop-minitest
59
- rubocop-rake
60
- yard
61
- yard-relative_markdown_links!
62
-
63
- BUNDLED WITH
64
- 2.2.7
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