rdoc_link_checker 0.7.0 → 0.8.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: eb872be04882f5f7d1766531b096683198244ac46f1997e896e65e7f79cb3f47
4
- data.tar.gz: 47768288623da2a9bf3610c4404ef5bdf704098a6572daeecae5400ab7e81987
3
+ metadata.gz: e341b7558f0ff7fdd60949c48e74b40b3510203760c66959f35f3950170b84ca
4
+ data.tar.gz: 07aeb18242f468ba7279cbd889a691de5fb350ff7846e052a0f69758a0354dc9
5
5
  SHA512:
6
- metadata.gz: 743c976e0ad98d6f624d3d7856504944ce82c0455a94fe693bf4b508eb9dada4b1c3f8d1d19211a8d9dbff96c6ff25e708ed1193afd8bc0cf036ca3eff614cc4
7
- data.tar.gz: 7f670d5f69e16259d1f6eeb555f38a2631eb6e8b53be91ab5a5d7a78f33e5fff40533c4438fe6024c465ddd894f876759097a099020c5860cd9843285bfdf0a2
6
+ metadata.gz: 26e31a6ceaab63b7d0e4ca4aaf4cb22c30a358ceec0b8f7be7a588fac2ecf63d894c2c52ca91777692c96a66a28b54e0d1b8a1fa811c6122327caca59868f254
7
+ data.tar.gz: 8aa4c40edd1cf78162c90ac3e184a5845157a21781a7a8988bce335e08ebe2f3db3c2fd6394d48d066d36ae44c0803109107bf8158420c98f18d56b4d5d5d800
data/README.md CHANGED
@@ -1,28 +1,19 @@
1
- # RDocLinkChecker
2
-
3
- A gem to find broken links in HTML files generated by Ruby RDoc.
4
-
5
- Reports a link as broken if:
6
-
7
- - The target page given by +href+ is not found.
8
- - The target page is found, but the fragment given by +href+
9
- is not a link target (element with attribute <tt>id</tt>) on that page;
10
- this usually causes a browser to open at the top of the page
11
- instead of at the given fragment.
12
-
13
- Some browsers are forgiving, and will open the target
14
- page at a link target similar to the given fragment;
15
- for example, fragment ```#bar``` may be opened at an element
16
- with id ```foobar```.
17
-
18
- See the [help text](doc/help.txt).
19
-
20
- <b>Note</b>: An RDoc bug that was fixed recently
21
- (PR https://github.com/ruby/rdoc/pull/1002)
22
- caused many (make that many, many) broken links TOC section
23
- https://docs.ruby-lang.org/en/master/table_of_contents.html#classes.
24
- Unless you have a recent Ruby version installed (one that has the bug fix),
25
- the RDocLinkChecker will find and report all those broken links.
26
-
27
- <b>Workaround</b>: Use option <tt>--no_toc</tt>, which suppresses checking
28
- for those links.
1
+ # RDocLinkChecker
2
+
3
+ A gem to find broken links in HTML files generated by Ruby RDoc.
4
+
5
+ Reports a link as broken if:
6
+
7
+ - The target page given by +href+ is not found.
8
+ - The target page is found, but the fragment given by +href+
9
+ is not a link target (element with attribute <tt>id</tt>) on that page;
10
+ this usually causes a browser to open at the top of the page
11
+ instead of at the given fragment.
12
+
13
+ Some browsers are forgiving, and will open the target
14
+ page at a link target similar to the given fragment;
15
+ for example, fragment ```#bar``` may be opened at an element
16
+ with id ```foobar```.
17
+
18
+ See the [help text](doc/help.txt).
19
+
@@ -4,9 +4,10 @@ require 'getoptlong'
4
4
  require_relative '../lib/rdoc_link_checker'
5
5
 
6
6
  options = GetoptLong.new(
7
- ['--config', GetoptLong::REQUIRED_ARGUMENT],
8
- ['--onsite_only', GetoptLong::NO_ARGUMENT],
9
- ['--no_toc', GetoptLong::NO_ARGUMENT],
7
+ ['--ruby_core', GetoptLong::REQUIRED_ARGUMENT],
8
+ ['--config', GetoptLong::REQUIRED_ARGUMENT],
9
+ ['--onsite_only', GetoptLong::REQUIRED_ARGUMENT],
10
+ ['--no_toc', GetoptLong::REQUIRED_ARGUMENT],
10
11
  ['--version', GetoptLong::NO_ARGUMENT],
11
12
  ['--help', GetoptLong::NO_ARGUMENT]
12
13
  )
@@ -30,18 +31,22 @@ end
30
31
 
31
32
  config_filepath = nil
32
33
  onsite_only = false
33
- no_toc = false
34
+ no_toc = true
35
+ ruby_core = true
34
36
  options.each do |option, argument|
35
37
  case option
38
+ when '--ruby_core'
39
+ ruby_core = argument == 'false' ? false : true
40
+ break
36
41
  when '--config'
37
42
  config_filepath = argument
38
43
  onsite_only = false
39
- no_toc = false
44
+ no_toc = true
40
45
  break
41
46
  when '--onsite_only'
42
- onsite_only = true
47
+ onsite_only = argument == 'false' ? false : true
43
48
  when '--no_toc'
44
- no_toc = true
49
+ no_toc = argument == 'false' ? false : true
45
50
  when '--help'
46
51
  help
47
52
  when '--version'
@@ -63,6 +68,7 @@ raise ArgumentError.new(message) if message
63
68
  html_dirpath = ARGV[0]
64
69
  RDocLinkChecker.new(
65
70
  html_dirpath,
71
+ ruby_core: ruby_core,
66
72
  config_filepath: config_filepath,
67
73
  onsite_only: onsite_only,
68
74
  no_toc: no_toc
data/doc/help.txt CHANGED
@@ -7,10 +7,14 @@ of RDoc-generated HTML files, such as those generated by command
7
7
  rdoc --visibility=private --op html . # Note the trailing dot.
8
8
 
9
9
  Options:
10
+ --ruby_core Set all options for reading Ruby core docs;
11
+ default is true (its primary use).
10
12
  --config filepath Read configuration from file. See below.
11
13
  --onsite_only Check link targets only on pages in the file tree at <html_dirpath>,
12
- and not those on other local pages or those on the web.
13
- --no_toc Do not check links on the TOC page (table_of_contents.html).
14
+ and not those on other local pages or those on the web;
15
+ default is false.
16
+ --no_toc Do not check links on the TOC page (table_of_contents.html);
17
+ default is true.
14
18
  --version Print the version and exit.
15
19
  --help Print this help and exit.
16
20
 
@@ -34,7 +38,5 @@ the names may include:
34
38
  a source filepath that matches any of those regexps will not be checked
35
39
  for bad links.
36
40
 
37
- Example:
38
-
39
41
 
40
42
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class RDocLinkChecker
4
- VERSION = "0.7.0"
4
+ VERSION = "0.8.0"
5
5
  end
@@ -13,13 +13,19 @@ class RDocLinkChecker
13
13
 
14
14
  include REXML
15
15
 
16
- attr_accessor :html_dirpath, :config_filepath, :onsite_only, :no_toc,
16
+ attr_accessor :html_dirpath, :ruby_core, :config_filepath, :onsite_only, :no_toc,
17
17
  :source_file_omits
18
18
 
19
19
  attr_accessor :source_paths, :pages
20
20
 
21
+ RUBY_CORE_OMITS = [
22
+ "^LEGAL",
23
+ "^NEWS"
24
+ ]
25
+
21
26
  def initialize(
22
27
  html_dirpath,
28
+ ruby_core: true,
23
29
  config_filepath: nil,
24
30
  onsite_only: false,
25
31
  no_toc: false
@@ -28,7 +34,7 @@ class RDocLinkChecker
28
34
  self.config_filepath = config_filepath
29
35
  self.onsite_only = onsite_only
30
36
  self.no_toc = no_toc
31
- self.source_file_omits = []
37
+ self.source_file_omits = ruby_core ? RUBY_CORE_OMITS : []
32
38
  if config_filepath
33
39
  config = JSON.parse(File.read(config_filepath))
34
40
  options = config['options']
@@ -572,7 +578,7 @@ EOT
572
578
 
573
579
  # For off-site, gather all ids, regardless of element.
574
580
  if RDocLinkChecker.offsite?(path)
575
- ok = path.match('homepages')
581
+ path.match('homepages')
576
582
  doc.xpath("//*[@id]").each do |element|
577
583
  id = element.attr('id')
578
584
  ids.push(id)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdoc_link_checker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Burdette Lamar
@@ -90,7 +90,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  - !ruby/object:Gem::Version
91
91
  version: '0'
92
92
  requirements: []
93
- rubygems_version: 3.6.9
93
+ rubygems_version: 4.0.3
94
94
  specification_version: 4
95
95
  summary: Tool to check links in RDoc-generated HTML files.
96
96
  test_files: []