rdoc 6.3.4.1 → 8.0.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/CONTRIBUTING.md +195 -0
- data/History.rdoc +65 -63
- data/LEGAL.rdoc +7 -1
- data/LICENSE.rdoc +6 -0
- data/README.md +236 -0
- data/RI.md +842 -0
- data/TODO.rdoc +8 -7
- data/doc/markup_reference/markdown.md +659 -0
- data/doc/markup_reference/rdoc.rdoc +1169 -0
- data/exe/rdoc +0 -1
- data/lib/rdoc/{alias.rb → code_object/alias.rb} +4 -18
- data/lib/rdoc/{any_method.rb → code_object/any_method.rb} +50 -24
- data/lib/rdoc/{attr.rb → code_object/attr.rb} +16 -14
- data/lib/rdoc/{class_module.rb → code_object/class_module.rb} +225 -58
- data/lib/rdoc/{constant.rb → code_object/constant.rb} +44 -10
- data/lib/rdoc/code_object/context/section.rb +182 -0
- data/lib/rdoc/{context.rb → code_object/context.rb} +78 -106
- data/lib/rdoc/{extend.rb → code_object/extend.rb} +0 -1
- data/lib/rdoc/{include.rb → code_object/include.rb} +0 -1
- data/lib/rdoc/{method_attr.rb → code_object/method_attr.rb} +46 -48
- data/lib/rdoc/{mixin.rb → code_object/mixin.rb} +6 -4
- data/lib/rdoc/{normal_class.rb → code_object/normal_class.rb} +2 -3
- data/lib/rdoc/{normal_module.rb → code_object/normal_module.rb} +2 -3
- data/lib/rdoc/{require.rb → code_object/require.rb} +1 -2
- data/lib/rdoc/{single_class.rb → code_object/single_class.rb} +5 -1
- data/lib/rdoc/{top_level.rb → code_object/top_level.rb} +60 -63
- data/lib/rdoc/code_object.rb +11 -39
- data/lib/rdoc/code_objects.rb +1 -2
- data/lib/rdoc/comment.rb +202 -99
- data/lib/rdoc/cross_reference.rb +75 -62
- data/lib/rdoc/encoding.rb +8 -24
- data/lib/rdoc/erb_partial.rb +1 -2
- data/lib/rdoc/erbio.rb +3 -8
- data/lib/rdoc/generator/aliki.rb +200 -0
- data/lib/rdoc/generator/darkfish.rb +156 -122
- data/lib/rdoc/generator/json_index.rb +8 -24
- data/lib/rdoc/generator/markup.rb +70 -34
- data/lib/rdoc/generator/pot/message_extractor.rb +7 -7
- data/lib/rdoc/generator/pot/po.rb +1 -1
- data/lib/rdoc/generator/pot/po_entry.rb +8 -8
- data/lib/rdoc/generator/pot.rb +1 -5
- data/lib/rdoc/generator/ri.rb +1 -2
- data/lib/rdoc/generator/template/aliki/DESIGN.md +536 -0
- data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +8 -0
- data/lib/rdoc/generator/template/aliki/_footer.rhtml +23 -0
- data/lib/rdoc/generator/template/aliki/_head.rhtml +163 -0
- data/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
- data/lib/rdoc/generator/template/aliki/_icons.rhtml +208 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +16 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +15 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +27 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +27 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +41 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +67 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +21 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
- data/lib/rdoc/generator/template/aliki/class.rhtml +230 -0
- data/lib/rdoc/generator/template/aliki/css/rdoc.css +2181 -0
- data/lib/rdoc/generator/template/aliki/index.rhtml +22 -0
- data/lib/rdoc/generator/template/aliki/js/aliki.js +513 -0
- data/lib/rdoc/generator/template/aliki/js/bash_highlighter.js +167 -0
- data/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
- data/lib/rdoc/generator/template/aliki/js/search_controller.js +129 -0
- data/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
- data/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
- data/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
- data/lib/rdoc/generator/template/aliki/page.rhtml +18 -0
- data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +14 -0
- data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +65 -0
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +3 -3
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +35 -14
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +1 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +11 -9
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +11 -9
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +7 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +20 -11
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +25 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +4 -9
- data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +2 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +28 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +138 -90
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +420 -358
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +14 -12
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +59 -3
- data/lib/rdoc/generator/template/darkfish/js/search.js +15 -5
- data/lib/rdoc/generator/template/darkfish/page.rhtml +7 -6
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +12 -9
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +24 -21
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +35 -21
- data/lib/rdoc/generator/template/json_index/js/navigation.js +8 -8
- data/lib/rdoc/generator/template/json_index/js/searcher.js +48 -6
- data/lib/rdoc/generator.rb +6 -5
- data/lib/rdoc/i18n/text.rb +3 -3
- data/lib/rdoc/i18n.rb +1 -1
- data/lib/rdoc/known_classes.rb +5 -4
- data/lib/rdoc/markdown/entities.rb +0 -1
- data/lib/rdoc/markdown/literals.kpeg +0 -2
- data/lib/rdoc/markdown/literals.rb +0 -1
- data/lib/rdoc/markdown.kpeg +140 -62
- data/lib/rdoc/markdown.rb +1015 -873
- data/lib/rdoc/markup/blank_line.rb +25 -24
- data/lib/rdoc/markup/block_quote.rb +1 -2
- data/lib/rdoc/markup/document.rb +10 -11
- data/lib/rdoc/markup/element.rb +21 -0
- data/lib/rdoc/markup/formatter.rb +134 -115
- data/lib/rdoc/markup/hard_break.rb +30 -28
- data/lib/rdoc/markup/heading.rb +163 -72
- data/lib/rdoc/markup/include.rb +3 -4
- data/lib/rdoc/markup/indented_paragraph.rb +4 -5
- data/lib/rdoc/markup/inline_parser.rb +312 -0
- data/lib/rdoc/markup/list.rb +6 -7
- data/lib/rdoc/markup/list_item.rb +6 -7
- data/lib/rdoc/markup/paragraph.rb +2 -3
- data/lib/rdoc/markup/parser.rb +29 -19
- data/lib/rdoc/markup/pre_process.rb +39 -18
- data/lib/rdoc/markup/raw.rb +52 -56
- data/lib/rdoc/markup/rule.rb +2 -3
- data/lib/rdoc/markup/table.rb +49 -32
- data/lib/rdoc/markup/to_ansi.rb +58 -8
- data/lib/rdoc/markup/to_bs.rb +47 -38
- data/lib/rdoc/markup/to_html.rb +343 -105
- data/lib/rdoc/markup/to_html_crossref.rb +143 -58
- data/lib/rdoc/markup/to_html_snippet.rb +78 -76
- data/lib/rdoc/markup/to_joined_paragraph.rb +3 -9
- data/lib/rdoc/markup/to_label.rb +34 -25
- data/lib/rdoc/markup/to_markdown.rb +74 -51
- data/lib/rdoc/markup/to_rdoc.rb +141 -82
- data/lib/rdoc/markup/to_table_of_contents.rb +4 -5
- data/lib/rdoc/markup/to_test.rb +10 -3
- data/lib/rdoc/markup/to_tt_only.rb +17 -31
- data/lib/rdoc/markup/verbatim.rb +5 -6
- data/lib/rdoc/markup.rb +59 -707
- data/lib/rdoc/options.rb +228 -101
- data/lib/rdoc/parser/c.rb +186 -184
- data/lib/rdoc/parser/changelog.rb +57 -13
- data/lib/rdoc/parser/markdown.rb +0 -2
- data/lib/rdoc/parser/rbs.rb +275 -0
- data/lib/rdoc/parser/rd.rb +0 -1
- data/lib/rdoc/parser/ruby.rb +963 -2024
- data/lib/rdoc/parser/ruby_colorizer.rb +253 -0
- data/lib/rdoc/parser/simple.rb +6 -23
- data/lib/rdoc/parser/text.rb +0 -1
- data/lib/rdoc/parser.rb +35 -14
- data/lib/rdoc/rbs_helper.rb +186 -0
- data/lib/rdoc/rd/block_parser.rb +659 -11
- data/lib/rdoc/rd/block_parser.ry +13 -9
- data/lib/rdoc/rd/inline.rb +4 -5
- data/lib/rdoc/rd/inline_parser.rb +646 -2
- data/lib/rdoc/rd.rb +4 -5
- data/lib/rdoc/rdoc.rb +234 -90
- data/lib/rdoc/ri/driver.rb +172 -172
- data/lib/rdoc/ri/paths.rb +3 -3
- data/lib/rdoc/{servlet.rb → ri/servlet.rb} +28 -27
- data/lib/rdoc/ri/store.rb +0 -1
- data/lib/rdoc/ri/task.rb +3 -3
- data/lib/rdoc/ri.rb +5 -5
- data/lib/rdoc/rubygems_hook.rb +106 -25
- data/lib/rdoc/server.rb +460 -0
- data/lib/rdoc/stats/normal.rb +1 -1
- data/lib/rdoc/stats/quiet.rb +1 -2
- data/lib/rdoc/stats/verbose.rb +3 -5
- data/lib/rdoc/stats.rb +158 -136
- data/lib/rdoc/store.rb +267 -48
- data/lib/rdoc/task.rb +54 -28
- data/lib/rdoc/text.rb +60 -120
- data/lib/rdoc/token_stream.rb +30 -45
- data/lib/rdoc/tom_doc.rb +9 -15
- data/lib/rdoc/version.rb +3 -1
- data/lib/rdoc.rb +90 -52
- data/lib/rubygems_plugin.rb +14 -0
- data/man/ri.1 +2 -0
- data/rdoc-logo.svg +43 -0
- data/rdoc.gemspec +25 -200
- metadata +120 -53
- data/CONTRIBUTING.rdoc +0 -220
- data/ExampleMarkdown.md +0 -37
- data/ExampleRDoc.rdoc +0 -208
- data/Gemfile +0 -12
- data/README.rdoc +0 -129
- data/RI.rdoc +0 -57
- data/Rakefile +0 -101
- data/bin/console +0 -7
- data/bin/setup +0 -6
- data/lib/rdoc/anon_class.rb +0 -11
- data/lib/rdoc/context/section.rb +0 -232
- data/lib/rdoc/generator/template/darkfish/.document +0 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +0 -19
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +0 -9
- data/lib/rdoc/generator/template/json_index/.document +0 -1
- data/lib/rdoc/ghost_method.rb +0 -7
- data/lib/rdoc/markup/attr_changer.rb +0 -23
- data/lib/rdoc/markup/attr_span.rb +0 -36
- data/lib/rdoc/markup/attribute_manager.rb +0 -409
- data/lib/rdoc/markup/attributes.rb +0 -71
- data/lib/rdoc/markup/regexp_handling.rb +0 -41
- data/lib/rdoc/meta_method.rb +0 -7
- data/lib/rdoc/parser/ripper_state_lex.rb +0 -590
- data/lib/rdoc/parser/ruby_tools.rb +0 -167
data/lib/rdoc/rdoc.rb
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
2
|
+
require_relative '../rdoc'
|
|
3
3
|
|
|
4
4
|
require 'find'
|
|
5
5
|
require 'fileutils'
|
|
6
6
|
require 'pathname'
|
|
7
7
|
require 'time'
|
|
8
|
+
require_relative 'rbs_helper'
|
|
8
9
|
|
|
9
10
|
##
|
|
10
11
|
# This is the driver for generating RDoc output. It handles file parsing and
|
|
@@ -14,7 +15,7 @@ require 'time'
|
|
|
14
15
|
# is:
|
|
15
16
|
#
|
|
16
17
|
# rdoc = RDoc::RDoc.new
|
|
17
|
-
# options =
|
|
18
|
+
# options = RDoc::Options.load_options # returns an RDoc::Options instance
|
|
18
19
|
# # set extra options
|
|
19
20
|
# rdoc.document options
|
|
20
21
|
#
|
|
@@ -35,6 +36,17 @@ class RDoc::RDoc
|
|
|
35
36
|
|
|
36
37
|
GENERATORS = {}
|
|
37
38
|
|
|
39
|
+
##
|
|
40
|
+
# List of directory names always skipped
|
|
41
|
+
|
|
42
|
+
UNCONDITIONALLY_SKIPPED_DIRECTORIES = %w[CVS .svn .git].freeze
|
|
43
|
+
|
|
44
|
+
##
|
|
45
|
+
# List of directory names skipped if test suites should be skipped
|
|
46
|
+
|
|
47
|
+
TEST_SUITE_DIRECTORY_NAMES = %w[spec test].freeze
|
|
48
|
+
|
|
49
|
+
|
|
38
50
|
##
|
|
39
51
|
# Generator instance used for creating output
|
|
40
52
|
|
|
@@ -58,7 +70,7 @@ class RDoc::RDoc
|
|
|
58
70
|
##
|
|
59
71
|
# The current documentation store
|
|
60
72
|
|
|
61
|
-
|
|
73
|
+
attr_accessor :store
|
|
62
74
|
|
|
63
75
|
##
|
|
64
76
|
# Add +klass+ that can generate output after parsing
|
|
@@ -78,7 +90,7 @@ class RDoc::RDoc
|
|
|
78
90
|
##
|
|
79
91
|
# Sets the active RDoc::RDoc instance
|
|
80
92
|
|
|
81
|
-
def self.current=
|
|
93
|
+
def self.current=(rdoc)
|
|
82
94
|
@current = rdoc
|
|
83
95
|
end
|
|
84
96
|
|
|
@@ -107,8 +119,8 @@ class RDoc::RDoc
|
|
|
107
119
|
# Gathers a set of parseable files from the files and directories listed in
|
|
108
120
|
# +files+.
|
|
109
121
|
|
|
110
|
-
def gather_files
|
|
111
|
-
files = [
|
|
122
|
+
def gather_files(files)
|
|
123
|
+
files = [@options.root.to_s] if files.empty?
|
|
112
124
|
|
|
113
125
|
file_list = normalized_file_list files, true, @options.exclude
|
|
114
126
|
|
|
@@ -129,7 +141,7 @@ class RDoc::RDoc
|
|
|
129
141
|
# Turns RDoc from stdin into HTML
|
|
130
142
|
|
|
131
143
|
def handle_pipe
|
|
132
|
-
@html = RDoc::Markup::ToHtml.new @options
|
|
144
|
+
@html = RDoc::Markup::ToHtml.new(pipe: @options.pipe, output_decoration: @options.output_decoration)
|
|
133
145
|
|
|
134
146
|
parser = RDoc::Text::MARKUP_FORMAT[@options.markup]
|
|
135
147
|
|
|
@@ -151,35 +163,6 @@ class RDoc::RDoc
|
|
|
151
163
|
end
|
|
152
164
|
end
|
|
153
165
|
|
|
154
|
-
##
|
|
155
|
-
# Loads options from .rdoc_options if the file exists, otherwise creates a
|
|
156
|
-
# new RDoc::Options instance.
|
|
157
|
-
|
|
158
|
-
def load_options
|
|
159
|
-
options_file = File.expand_path '.rdoc_options'
|
|
160
|
-
return RDoc::Options.new unless File.exist? options_file
|
|
161
|
-
|
|
162
|
-
RDoc.load_yaml
|
|
163
|
-
|
|
164
|
-
begin
|
|
165
|
-
options = YAML.safe_load_file '.rdoc_options', permitted_classes: [RDoc::Options, Symbol]
|
|
166
|
-
rescue Psych::SyntaxError
|
|
167
|
-
raise RDoc::Error, "#{options_file} is not a valid rdoc options file"
|
|
168
|
-
end
|
|
169
|
-
|
|
170
|
-
return RDoc::Options.new unless options # Allow empty file.
|
|
171
|
-
|
|
172
|
-
raise RDoc::Error, "#{options_file} is not a valid rdoc options file" unless
|
|
173
|
-
RDoc::Options === options or Hash === options
|
|
174
|
-
|
|
175
|
-
if Hash === options
|
|
176
|
-
# Override the default values with the contents of YAML file.
|
|
177
|
-
options = RDoc::Options.new options
|
|
178
|
-
end
|
|
179
|
-
|
|
180
|
-
options
|
|
181
|
-
end
|
|
182
|
-
|
|
183
166
|
##
|
|
184
167
|
# Create an output dir if it doesn't exist. If it does exist, but doesn't
|
|
185
168
|
# contain the flag file <tt>created.rid</tt> then we refuse to use it, as
|
|
@@ -226,15 +209,6 @@ option)
|
|
|
226
209
|
last
|
|
227
210
|
end
|
|
228
211
|
|
|
229
|
-
##
|
|
230
|
-
# Sets the current documentation tree to +store+ and sets the store's rdoc
|
|
231
|
-
# driver to this instance.
|
|
232
|
-
|
|
233
|
-
def store= store
|
|
234
|
-
@store = store
|
|
235
|
-
@store.rdoc = self
|
|
236
|
-
end
|
|
237
|
-
|
|
238
212
|
##
|
|
239
213
|
# Update the flag file in an output directory.
|
|
240
214
|
|
|
@@ -264,7 +238,7 @@ option)
|
|
|
264
238
|
# representing candidates for documentation. It may also contain comments
|
|
265
239
|
# (starting with '#')
|
|
266
240
|
|
|
267
|
-
def parse_dot_doc_file
|
|
241
|
+
def parse_dot_doc_file(in_dir, filename)
|
|
268
242
|
# read and strip comments
|
|
269
243
|
patterns = File.read(filename).gsub(/#.*/, '')
|
|
270
244
|
|
|
@@ -309,7 +283,10 @@ option)
|
|
|
309
283
|
file_list[rel_file_name] = mtime
|
|
310
284
|
end
|
|
311
285
|
when "directory" then
|
|
312
|
-
next if rel_file_name
|
|
286
|
+
next if UNCONDITIONALLY_SKIPPED_DIRECTORIES.include?(rel_file_name)
|
|
287
|
+
|
|
288
|
+
basename = File.basename(rel_file_name)
|
|
289
|
+
next if options.skip_tests && TEST_SUITE_DIRECTORY_NAMES.include?(basename)
|
|
313
290
|
|
|
314
291
|
created_rid = File.join rel_file_name, "created.rid"
|
|
315
292
|
next if File.file? created_rid
|
|
@@ -335,7 +312,7 @@ option)
|
|
|
335
312
|
# files. However we may well contain subdirectories which must be tested
|
|
336
313
|
# for .document files.
|
|
337
314
|
|
|
338
|
-
def list_files_in_directory
|
|
315
|
+
def list_files_in_directory(dir)
|
|
339
316
|
files = Dir.glob File.join(dir, "*")
|
|
340
317
|
|
|
341
318
|
normalized_file_list files, false, @options.exclude
|
|
@@ -344,7 +321,7 @@ option)
|
|
|
344
321
|
##
|
|
345
322
|
# Parses +filename+ and returns an RDoc::TopLevel
|
|
346
323
|
|
|
347
|
-
def parse_file
|
|
324
|
+
def parse_file(filename)
|
|
348
325
|
encoding = @options.encoding
|
|
349
326
|
filename = filename.encode encoding
|
|
350
327
|
|
|
@@ -356,22 +333,9 @@ option)
|
|
|
356
333
|
|
|
357
334
|
return unless content
|
|
358
335
|
|
|
359
|
-
|
|
360
|
-
begin
|
|
361
|
-
relative_path = filename_path.relative_path_from @options.root
|
|
362
|
-
rescue ArgumentError
|
|
363
|
-
relative_path = filename_path
|
|
364
|
-
end
|
|
365
|
-
|
|
366
|
-
if @options.page_dir and
|
|
367
|
-
relative_path.to_s.start_with? @options.page_dir.to_s then
|
|
368
|
-
relative_path =
|
|
369
|
-
relative_path.relative_path_from @options.page_dir
|
|
370
|
-
end
|
|
371
|
-
|
|
372
|
-
top_level = @store.add_file filename, relative_name: relative_path.to_s
|
|
336
|
+
top_level = @store.add_file filename, relative_name: relative_path_for(filename)
|
|
373
337
|
|
|
374
|
-
parser = RDoc::Parser.for top_level,
|
|
338
|
+
parser = RDoc::Parser.for top_level, content, @options, @stats
|
|
375
339
|
|
|
376
340
|
return unless parser
|
|
377
341
|
|
|
@@ -393,13 +357,25 @@ it or perhaps the original author's permissions are to restrictive. If the
|
|
|
393
357
|
this is not your library please report a bug to the author.
|
|
394
358
|
EOF
|
|
395
359
|
rescue => e
|
|
396
|
-
|
|
360
|
+
syntax_check_command = syntax_check_command_for filename, parser&.class
|
|
361
|
+
syntax_check_message = if syntax_check_command
|
|
362
|
+
<<~MESSAGE
|
|
397
363
|
Before reporting this, could you check that the file you're documenting
|
|
398
364
|
has proper syntax:
|
|
399
365
|
|
|
400
|
-
#{
|
|
366
|
+
#{syntax_check_command}
|
|
367
|
+
MESSAGE
|
|
368
|
+
else
|
|
369
|
+
<<~MESSAGE
|
|
370
|
+
Before reporting this, could you check that the file you're documenting
|
|
371
|
+
has proper syntax for its language?
|
|
372
|
+
MESSAGE
|
|
373
|
+
end
|
|
401
374
|
|
|
402
|
-
|
|
375
|
+
$stderr.puts <<-EOF
|
|
376
|
+
#{syntax_check_message}
|
|
377
|
+
RDoc's parsers are not full language parsers and may fail when fed invalid
|
|
378
|
+
source files.
|
|
403
379
|
|
|
404
380
|
The internal error was:
|
|
405
381
|
|
|
@@ -410,18 +386,50 @@ The internal error was:
|
|
|
410
386
|
$stderr.puts e.backtrace.join("\n\t") if $DEBUG_RDOC
|
|
411
387
|
|
|
412
388
|
raise e
|
|
413
|
-
|
|
389
|
+
end
|
|
390
|
+
|
|
391
|
+
def syntax_check_command_for(filename, parser_class = RDoc::Parser.can_parse_by_name(filename))
|
|
392
|
+
if parser_class == RDoc::Parser::Ruby
|
|
393
|
+
"#{Gem.ruby} -c #{filename}"
|
|
394
|
+
elsif parser_class == RDoc::Parser::C
|
|
395
|
+
cc = ENV['CC']
|
|
396
|
+
cc = 'cc' if cc.nil? || cc.empty?
|
|
397
|
+
"#{cc} -fsyntax-only #{filename}"
|
|
398
|
+
end
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
##
|
|
402
|
+
# Returns the relative path for +filename+ against +options.root+ (and
|
|
403
|
+
# +options.page_dir+ when set). This is the key used by RDoc::Store to
|
|
404
|
+
# identify files.
|
|
405
|
+
|
|
406
|
+
def relative_path_for(filename)
|
|
407
|
+
filename_path = Pathname(filename).expand_path
|
|
408
|
+
begin
|
|
409
|
+
relative_path = filename_path.relative_path_from @options.root
|
|
410
|
+
rescue ArgumentError
|
|
411
|
+
relative_path = filename_path
|
|
412
|
+
end
|
|
413
|
+
|
|
414
|
+
if @options.page_dir &&
|
|
415
|
+
relative_path.to_s.start_with?(@options.page_dir.to_s)
|
|
416
|
+
relative_path =
|
|
417
|
+
relative_path.relative_path_from @options.page_dir
|
|
418
|
+
end
|
|
419
|
+
|
|
420
|
+
relative_path.to_s
|
|
414
421
|
end
|
|
415
422
|
|
|
416
423
|
##
|
|
417
424
|
# Parse each file on the command line, recursively entering directories.
|
|
418
425
|
|
|
419
|
-
def parse_files
|
|
426
|
+
def parse_files(files)
|
|
420
427
|
file_list = gather_files files
|
|
421
428
|
@stats = RDoc::Stats.new @store, file_list.length, @options.verbosity
|
|
422
429
|
|
|
423
430
|
return [] if file_list.empty?
|
|
424
431
|
|
|
432
|
+
# This workaround can be removed after the :main: directive is removed
|
|
425
433
|
original_options = @options.dup
|
|
426
434
|
@stats.begin_adding
|
|
427
435
|
|
|
@@ -430,6 +438,8 @@ The internal error was:
|
|
|
430
438
|
parse_file filename
|
|
431
439
|
end.compact
|
|
432
440
|
|
|
441
|
+
@store.resolve_c_superclasses
|
|
442
|
+
|
|
433
443
|
@stats.done_adding
|
|
434
444
|
@options = original_options
|
|
435
445
|
|
|
@@ -440,13 +450,11 @@ The internal error was:
|
|
|
440
450
|
# Removes file extensions known to be unparseable from +files+ and TAGS
|
|
441
451
|
# files for emacs and vim.
|
|
442
452
|
|
|
443
|
-
def remove_unparseable
|
|
453
|
+
def remove_unparseable(files)
|
|
444
454
|
files.reject do |file, *|
|
|
445
|
-
file =~ /\.(?:class|eps|erb|scpt\.txt|svg|ttf|yml)
|
|
446
|
-
(file =~ /tags
|
|
447
|
-
File.
|
|
448
|
-
io.read(100) =~ /\A(\f\n[^,]+,\d+$|!_TAG_)/
|
|
449
|
-
})
|
|
455
|
+
file =~ /\.(?:class|eps|erb|scpt\.txt|svg|ttf|yml)\z/i or
|
|
456
|
+
(file =~ /tags\z/i and
|
|
457
|
+
/\A(\f\n[^,]+,\d+$|!_TAG_)/.match?(File.binread(file, 100)))
|
|
450
458
|
end
|
|
451
459
|
end
|
|
452
460
|
|
|
@@ -464,40 +472,60 @@ The internal error was:
|
|
|
464
472
|
# By default, output will be stored in a directory called "doc" below the
|
|
465
473
|
# current directory, so make sure you're somewhere writable before invoking.
|
|
466
474
|
|
|
467
|
-
def document
|
|
468
|
-
self.store = RDoc::Store.new
|
|
469
|
-
|
|
475
|
+
def document(options)
|
|
470
476
|
if RDoc::Options === options then
|
|
471
477
|
@options = options
|
|
472
|
-
@options.finish
|
|
473
478
|
else
|
|
474
|
-
@options = load_options
|
|
479
|
+
@options = RDoc::Options.load_options
|
|
475
480
|
@options.parse options
|
|
476
481
|
end
|
|
482
|
+
@options.finish
|
|
483
|
+
|
|
484
|
+
@store = RDoc::Store.new(@options)
|
|
477
485
|
|
|
478
486
|
if @options.pipe then
|
|
479
487
|
handle_pipe
|
|
480
488
|
exit
|
|
481
489
|
end
|
|
482
490
|
|
|
491
|
+
if @options.server_port
|
|
492
|
+
@store.load_cache
|
|
493
|
+
|
|
494
|
+
parse_files @options.files
|
|
495
|
+
record_auto_discovered_rbs_signature_mtimes
|
|
496
|
+
|
|
497
|
+
@options.default_title = "RDoc Documentation"
|
|
498
|
+
|
|
499
|
+
load_auto_discovered_rbs_signatures
|
|
500
|
+
@store.complete @options.visibility
|
|
501
|
+
|
|
502
|
+
start_server
|
|
503
|
+
exit
|
|
504
|
+
end
|
|
505
|
+
|
|
483
506
|
unless @options.coverage_report then
|
|
484
507
|
@last_modified = setup_output_dir @options.op_dir, @options.force_update
|
|
485
508
|
end
|
|
486
509
|
|
|
487
|
-
@store.encoding = @options.encoding
|
|
488
|
-
@store.dry_run = @options.dry_run
|
|
489
|
-
@store.main = @options.main_page
|
|
490
|
-
@store.title = @options.title
|
|
491
|
-
@store.path = @options.op_dir
|
|
492
|
-
|
|
493
510
|
@start_time = Time.now
|
|
494
511
|
|
|
495
512
|
@store.load_cache
|
|
496
513
|
|
|
514
|
+
auto_discovered_rbs_signatures_changed = auto_discovered_rbs_signatures_changed?
|
|
515
|
+
# When only auto-discovered RBS signatures changed, no Ruby file would be
|
|
516
|
+
# reparsed under normal mtime checks. The store cache holds class metadata
|
|
517
|
+
# but not live RDoc::Context objects, so the generator would have nothing
|
|
518
|
+
# to iterate. Force a full reparse so updated signatures show up in the
|
|
519
|
+
# rendered output.
|
|
520
|
+
@last_modified.clear if auto_discovered_rbs_signatures_changed
|
|
521
|
+
|
|
497
522
|
file_info = parse_files @options.files
|
|
523
|
+
record_auto_discovered_rbs_signature_mtimes
|
|
498
524
|
|
|
499
525
|
@options.default_title = "RDoc Documentation"
|
|
500
526
|
|
|
527
|
+
load_auto_discovered_rbs_signatures
|
|
528
|
+
|
|
501
529
|
@store.complete @options.visibility
|
|
502
530
|
|
|
503
531
|
@stats.coverage_level = @options.coverage_report
|
|
@@ -505,8 +533,8 @@ The internal error was:
|
|
|
505
533
|
if @options.coverage_report then
|
|
506
534
|
puts
|
|
507
535
|
|
|
508
|
-
puts @stats.report
|
|
509
|
-
elsif file_info.empty? then
|
|
536
|
+
puts @stats.report
|
|
537
|
+
elsif file_info.empty? && !auto_discovered_rbs_signatures_changed then
|
|
510
538
|
$stderr.puts "\nNo newer files." unless @options.quiet
|
|
511
539
|
else
|
|
512
540
|
gen_klass = @options.generator
|
|
@@ -518,7 +546,7 @@ The internal error was:
|
|
|
518
546
|
|
|
519
547
|
if @stats and (@options.coverage_report or not @options.quiet) then
|
|
520
548
|
puts
|
|
521
|
-
puts @stats.summary
|
|
549
|
+
puts @stats.summary
|
|
522
550
|
end
|
|
523
551
|
|
|
524
552
|
exit @stats.fully_documented? if @options.coverage_report
|
|
@@ -537,6 +565,9 @@ The internal error was:
|
|
|
537
565
|
Dir.chdir @options.op_dir do
|
|
538
566
|
unless @options.quiet then
|
|
539
567
|
$stderr.puts "\nGenerating #{@generator.class.name.sub(/^.*::/, '')} format into #{Dir.pwd}..."
|
|
568
|
+
uri = "file://#{Dir.pwd}/index.html"
|
|
569
|
+
ref = $stderr.tty? ? "\e]8;;#{uri}\e\\#{uri}\e]8;;\e\\" : uri
|
|
570
|
+
$stderr.puts "\nYou can visit the home page at: #{ref}"
|
|
540
571
|
end
|
|
541
572
|
|
|
542
573
|
@generator.generate
|
|
@@ -545,6 +576,99 @@ The internal error was:
|
|
|
545
576
|
end
|
|
546
577
|
end
|
|
547
578
|
|
|
579
|
+
##
|
|
580
|
+
# Loads RBS type signatures from the project's +sig+ directory and RBS
|
|
581
|
+
# stdlib, then merges them into the store's code objects.
|
|
582
|
+
|
|
583
|
+
def load_auto_discovered_rbs_signatures
|
|
584
|
+
sig_dirs = []
|
|
585
|
+
sig_dir = File.join(@options.root.to_s, 'sig')
|
|
586
|
+
sig_dirs << sig_dir if File.directory?(sig_dir)
|
|
587
|
+
signatures = RDoc::RbsHelper.load_signatures(*sig_dirs)
|
|
588
|
+
@store.merge_rbs_signatures(signatures)
|
|
589
|
+
rescue RBS::BaseError, Errno::ENOENT, LoadError => e
|
|
590
|
+
# In server mode, a previous successful load may have populated the store;
|
|
591
|
+
# drop those signatures so a now-broken sig file doesn't keep showing
|
|
592
|
+
# stale types alongside the warning.
|
|
593
|
+
@store.clear_rbs_signatures
|
|
594
|
+
@options.warn "Failed to load RBS type signatures: #{e.message}"
|
|
595
|
+
end
|
|
596
|
+
|
|
597
|
+
##
|
|
598
|
+
# Returns RBS files that RDoc auto-discovers for signature loading.
|
|
599
|
+
|
|
600
|
+
def auto_discovered_rbs_signature_files
|
|
601
|
+
Dir[File.join(@options.root.to_s, 'sig', '**', '*.rbs')].sort
|
|
602
|
+
end
|
|
603
|
+
|
|
604
|
+
##
|
|
605
|
+
# Returns true if any auto-discovered RBS signature file has changed since
|
|
606
|
+
# the last run.
|
|
607
|
+
|
|
608
|
+
def auto_discovered_rbs_signatures_changed?
|
|
609
|
+
current = auto_discovered_rbs_signature_mtimes
|
|
610
|
+
previous = @last_modified.select { |file, _| auto_discovered_rbs_signature_file?(file) }
|
|
611
|
+
|
|
612
|
+
return true unless (previous.keys - current.keys).empty?
|
|
613
|
+
|
|
614
|
+
current.any? do |file, mtime|
|
|
615
|
+
last_modified = @last_modified[file]
|
|
616
|
+
last_modified.nil? || mtime.to_i > last_modified.to_i
|
|
617
|
+
end
|
|
618
|
+
end
|
|
619
|
+
|
|
620
|
+
##
|
|
621
|
+
# Records auto-discovered RBS signature file mtimes so normal generation
|
|
622
|
+
# freshness checks and the live server watcher can see signature-only edits.
|
|
623
|
+
|
|
624
|
+
def record_auto_discovered_rbs_signature_mtimes
|
|
625
|
+
@last_modified.reject! { |file, _| auto_discovered_rbs_signature_file?(file) }
|
|
626
|
+
@last_modified.merge! auto_discovered_rbs_signature_mtimes
|
|
627
|
+
end
|
|
628
|
+
|
|
629
|
+
##
|
|
630
|
+
# Files watched by the live preview server.
|
|
631
|
+
|
|
632
|
+
def watch_files
|
|
633
|
+
(@last_modified.keys + auto_discovered_rbs_signature_files).uniq
|
|
634
|
+
end
|
|
635
|
+
|
|
636
|
+
##
|
|
637
|
+
# Returns true for project RBS files that are auto-discovered for signature
|
|
638
|
+
# loading. RDoc parses any selected .rbs file as documentation input, but
|
|
639
|
+
# only +sig/**/*.rbs+ files are loaded through RBS::EnvironmentLoader for
|
|
640
|
+
# type signature merging and live-reload bookkeeping.
|
|
641
|
+
|
|
642
|
+
def auto_discovered_rbs_signature_file?(file) # :nodoc:
|
|
643
|
+
return false unless File.extname(file) == '.rbs'
|
|
644
|
+
|
|
645
|
+
root = Pathname(@options.root.to_s).expand_path
|
|
646
|
+
relative_path = Pathname(file).expand_path.relative_path_from root
|
|
647
|
+
relative_path.each_filename.first == 'sig'
|
|
648
|
+
rescue ArgumentError
|
|
649
|
+
# file and root may be on different drives on Windows
|
|
650
|
+
false
|
|
651
|
+
end
|
|
652
|
+
|
|
653
|
+
##
|
|
654
|
+
# Returns mtimes for auto-discovered RBS signature files.
|
|
655
|
+
|
|
656
|
+
def auto_discovered_rbs_signature_mtimes # :nodoc:
|
|
657
|
+
auto_discovered_rbs_signature_files.each_with_object({}) do |file, mtimes|
|
|
658
|
+
mtime = RDoc.safe_mtime(file)
|
|
659
|
+
mtimes[file] = mtime if mtime
|
|
660
|
+
end
|
|
661
|
+
end
|
|
662
|
+
|
|
663
|
+
##
|
|
664
|
+
# Starts a live-reloading HTTP server for previewing documentation.
|
|
665
|
+
# Called from #document when <tt>--server</tt> is given.
|
|
666
|
+
|
|
667
|
+
def start_server
|
|
668
|
+
server = RDoc::Server.new(self, @options.server_port)
|
|
669
|
+
server.start
|
|
670
|
+
end
|
|
671
|
+
|
|
548
672
|
##
|
|
549
673
|
# Removes a siginfo handler and replaces the previous
|
|
550
674
|
|
|
@@ -556,14 +680,33 @@ The internal error was:
|
|
|
556
680
|
trap 'INFO', handler
|
|
557
681
|
end
|
|
558
682
|
|
|
683
|
+
##
|
|
684
|
+
# Returns true when +extension+ is the RBS gem's RDoc discovery hook.
|
|
685
|
+
# Released RBS gems install their plugin through this hook, so skip it to
|
|
686
|
+
# avoid replacing the built-in parser during discovery.
|
|
687
|
+
|
|
688
|
+
def self.rbs_discovery_extension?(extension) # :nodoc:
|
|
689
|
+
extension = File.expand_path(extension)
|
|
690
|
+
|
|
691
|
+
Gem::Specification.find_all_by_name('rbs').any? do |spec|
|
|
692
|
+
File.expand_path('lib/rdoc/discover.rb', spec.full_gem_path) == extension
|
|
693
|
+
end
|
|
694
|
+
end
|
|
695
|
+
|
|
559
696
|
end
|
|
560
697
|
|
|
698
|
+
# Load built-in parser registrations before RubyGems discovery, then skip the
|
|
699
|
+
# RBS gem's plugin hook so it cannot replace RDoc::Parser::RBS.
|
|
700
|
+
require_relative 'parser'
|
|
701
|
+
|
|
561
702
|
begin
|
|
562
703
|
require 'rubygems'
|
|
563
704
|
|
|
564
|
-
rdoc_extensions = Gem.
|
|
705
|
+
rdoc_extensions = Gem.find_latest_files 'rdoc/discover'
|
|
565
706
|
|
|
566
707
|
rdoc_extensions.each do |extension|
|
|
708
|
+
next if RDoc::RDoc.rbs_discovery_extension?(extension)
|
|
709
|
+
|
|
567
710
|
begin
|
|
568
711
|
load extension
|
|
569
712
|
rescue => e
|
|
@@ -576,5 +719,6 @@ end
|
|
|
576
719
|
|
|
577
720
|
# require built-in generators after discovery in case they've been replaced
|
|
578
721
|
require_relative 'generator/darkfish'
|
|
722
|
+
require_relative 'generator/aliki'
|
|
579
723
|
require_relative 'generator/ri'
|
|
580
724
|
require_relative 'generator/pot'
|