rdoc_link_checker 0.6.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 +4 -4
- data/README.md +19 -28
- data/bin/rdoc_link_checker +25 -8
- data/config/ruby.json +10 -0
- data/doc/help.txt +31 -5
- data/lib/rdoc_link_checker/version.rb +5 -5
- data/lib/rdoc_link_checker.rb +722 -674
- metadata +4 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e341b7558f0ff7fdd60949c48e74b40b3510203760c66959f35f3950170b84ca
|
|
4
|
+
data.tar.gz: 07aeb18242f468ba7279cbd889a691de5fb350ff7846e052a0f69758a0354dc9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
+
|
data/bin/rdoc_link_checker
CHANGED
|
@@ -4,11 +4,12 @@ require 'getoptlong'
|
|
|
4
4
|
require_relative '../lib/rdoc_link_checker'
|
|
5
5
|
|
|
6
6
|
options = GetoptLong.new(
|
|
7
|
-
['--
|
|
8
|
-
['--
|
|
9
|
-
['--
|
|
10
|
-
['--
|
|
11
|
-
['--
|
|
7
|
+
['--ruby_core', GetoptLong::REQUIRED_ARGUMENT],
|
|
8
|
+
['--config', GetoptLong::REQUIRED_ARGUMENT],
|
|
9
|
+
['--onsite_only', GetoptLong::REQUIRED_ARGUMENT],
|
|
10
|
+
['--no_toc', GetoptLong::REQUIRED_ARGUMENT],
|
|
11
|
+
['--version', GetoptLong::NO_ARGUMENT],
|
|
12
|
+
['--help', GetoptLong::NO_ARGUMENT]
|
|
12
13
|
)
|
|
13
14
|
|
|
14
15
|
def help
|
|
@@ -16,6 +17,10 @@ def help
|
|
|
16
17
|
dirname = File.dirname(File.dirname(path))
|
|
17
18
|
filepath = File.join(dirname, 'doc', 'help.txt')
|
|
18
19
|
puts File.read(filepath)
|
|
20
|
+
filepath = File.join(dirname, 'config', 'ruby.json')
|
|
21
|
+
File.readlines(filepath).each do |line|
|
|
22
|
+
puts " #{line}"
|
|
23
|
+
end
|
|
19
24
|
exit
|
|
20
25
|
end
|
|
21
26
|
|
|
@@ -24,14 +29,24 @@ def version
|
|
|
24
29
|
exit
|
|
25
30
|
end
|
|
26
31
|
|
|
32
|
+
config_filepath = nil
|
|
27
33
|
onsite_only = false
|
|
28
|
-
no_toc =
|
|
34
|
+
no_toc = true
|
|
35
|
+
ruby_core = true
|
|
29
36
|
options.each do |option, argument|
|
|
30
37
|
case option
|
|
38
|
+
when '--ruby_core'
|
|
39
|
+
ruby_core = argument == 'false' ? false : true
|
|
40
|
+
break
|
|
41
|
+
when '--config'
|
|
42
|
+
config_filepath = argument
|
|
43
|
+
onsite_only = false
|
|
44
|
+
no_toc = true
|
|
45
|
+
break
|
|
31
46
|
when '--onsite_only'
|
|
32
|
-
onsite_only = true
|
|
47
|
+
onsite_only = argument == 'false' ? false : true
|
|
33
48
|
when '--no_toc'
|
|
34
|
-
no_toc = true
|
|
49
|
+
no_toc = argument == 'false' ? false : true
|
|
35
50
|
when '--help'
|
|
36
51
|
help
|
|
37
52
|
when '--version'
|
|
@@ -53,6 +68,8 @@ raise ArgumentError.new(message) if message
|
|
|
53
68
|
html_dirpath = ARGV[0]
|
|
54
69
|
RDocLinkChecker.new(
|
|
55
70
|
html_dirpath,
|
|
71
|
+
ruby_core: ruby_core,
|
|
72
|
+
config_filepath: config_filepath,
|
|
56
73
|
onsite_only: onsite_only,
|
|
57
74
|
no_toc: no_toc
|
|
58
75
|
).check
|
data/config/ruby.json
ADDED
data/doc/help.txt
CHANGED
|
@@ -7,10 +7,36 @@ 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
|
-
--
|
|
11
|
-
|
|
12
|
-
--
|
|
13
|
-
--
|
|
14
|
-
|
|
10
|
+
--ruby_core Set all options for reading Ruby core docs;
|
|
11
|
+
default is true (its primary use).
|
|
12
|
+
--config filepath Read configuration from file. See below.
|
|
13
|
+
--onsite_only Check link targets only on pages in the file tree at <html_dirpath>,
|
|
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.
|
|
18
|
+
--version Print the version and exit.
|
|
19
|
+
--help Print this help and exit.
|
|
15
20
|
|
|
16
21
|
The output is file <html_dirpath>/Report.htm, which reports broken links.
|
|
22
|
+
|
|
23
|
+
The configuration file must be a JSON object
|
|
24
|
+
(see https://docs.ruby-lang.org/en/master/JSON.html)
|
|
25
|
+
consisting of name/value pairs;
|
|
26
|
+
the names may include:
|
|
27
|
+
|
|
28
|
+
- "options": a JSON object consisting of option-name/value pairs;
|
|
29
|
+
the option-names may include:
|
|
30
|
+
|
|
31
|
+
- "onsite_only": the value must be true or false (not quoted),
|
|
32
|
+
which sets the onsite_only value.
|
|
33
|
+
- "no_toc": the value must be true or false (not quoted),
|
|
34
|
+
which sets the no_toc value.
|
|
35
|
+
|
|
36
|
+
- "source_file_omits": a JSON array consisting of double-quoted strings,
|
|
37
|
+
each of which will be used to create a Regexp object;
|
|
38
|
+
a source filepath that matches any of those regexps will not be checked
|
|
39
|
+
for bad links.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
class RDocLinkChecker
|
|
4
|
-
VERSION = "0.
|
|
5
|
-
end
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class RDocLinkChecker
|
|
4
|
+
VERSION = "0.8.0"
|
|
5
|
+
end
|