rdoc 6.14.2 → 6.16.1
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/History.rdoc +1 -1
- data/README.md +112 -0
- data/RI.md +1 -1
- data/lib/rdoc/code_object/top_level.rb +18 -25
- data/lib/rdoc/comment.rb +190 -8
- data/lib/rdoc/cross_reference.rb +1 -1
- data/lib/rdoc/generator/aliki.rb +42 -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 +158 -0
- data/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +6 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +5 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +15 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +15 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +21 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +37 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +11 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
- data/lib/rdoc/generator/template/aliki/class.rhtml +219 -0
- data/lib/rdoc/generator/template/aliki/css/rdoc.css +1612 -0
- data/lib/rdoc/generator/template/aliki/index.rhtml +21 -0
- data/lib/rdoc/generator/template/aliki/js/aliki.js +483 -0
- data/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
- data/lib/rdoc/generator/template/aliki/js/search.js +120 -0
- data/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
- data/lib/rdoc/generator/template/aliki/page.rhtml +17 -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 +14 -19
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +8 -8
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +8 -8
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +7 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +6 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +19 -19
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +1 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +3 -3
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +14 -14
- data/lib/rdoc/generator/template/darkfish/class.rhtml +62 -60
- data/lib/rdoc/generator/template/darkfish/index.rhtml +4 -3
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +21 -1
- data/lib/rdoc/generator/template/darkfish/js/search.js +11 -1
- data/lib/rdoc/generator/template/darkfish/page.rhtml +2 -1
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +2 -1
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +19 -19
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +19 -17
- data/lib/rdoc/generator/template/json_index/js/searcher.js +48 -6
- data/lib/rdoc/generator.rb +1 -0
- data/lib/rdoc/markdown.kpeg +28 -17
- data/lib/rdoc/markdown.rb +365 -544
- data/lib/rdoc/markup/pre_process.rb +34 -10
- data/lib/rdoc/markup/to_html.rb +162 -14
- data/lib/rdoc/markup/to_html_crossref.rb +53 -23
- data/lib/rdoc/options.rb +22 -11
- data/lib/rdoc/parser/c.rb +15 -46
- data/lib/rdoc/parser/prism_ruby.rb +121 -113
- data/lib/rdoc/parser/ruby.rb +8 -8
- data/lib/rdoc/parser/ruby_tools.rb +5 -7
- data/lib/rdoc/parser/simple.rb +4 -21
- data/lib/rdoc/rdoc.rb +1 -0
- data/lib/rdoc/ri/task.rb +2 -2
- data/lib/rdoc/store.rb +2 -2
- data/lib/rdoc/task.rb +4 -4
- data/lib/rdoc/text.rb +1 -1
- data/lib/rdoc/token_stream.rb +13 -1
- data/lib/rdoc/tom_doc.rb +1 -1
- data/lib/rdoc/version.rb +1 -1
- data/rdoc.gemspec +3 -2
- metadata +44 -5
- data/README.rdoc +0 -144
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4714e3abeb6a0311e1571d60b94bd73313031928f083cf4210ea59972da2fa2f
|
|
4
|
+
data.tar.gz: c16eded024105e7c746b9b61294699ab31b53e45ac74d0576c96243b09ce4816
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cd1e0d7980fabb57130891c6d39db9ba83a1ab02d28feeaedae98a3e894d31e0c6bc6a57bc4006dd6e4677d74b433e7f1f1030eac40adc3d5e6810be2ac19692
|
|
7
|
+
data.tar.gz: ed843f9890ad564647b3b5f5cae1b33afe1402a8647cdd6251704ea7ba768314f594e68e525e117be545334f415d4e07e8ff86edc70624a04f6e3a2c41ac9438
|
data/History.rdoc
CHANGED
|
@@ -163,7 +163,7 @@
|
|
|
163
163
|
* Moved old DEVELOPERS file to CONTRIBUTING to match github conventions.
|
|
164
164
|
* TomDoc output now has a "Returns" heading. Issue #234 by Brian Henderson
|
|
165
165
|
* Metaprogrammed methods can now use the :args: directive in addition to the
|
|
166
|
-
|
|
166
|
+
\:call-seq: directive. Issue #236 by Mike Moore.
|
|
167
167
|
* Sections can be linked to using "@" like labels. If a section and a label
|
|
168
168
|
have the same name the section will be preferred. Issue #233 by Brian
|
|
169
169
|
Henderson.
|
data/README.md
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# RDoc - Ruby Documentation System
|
|
2
|
+
|
|
3
|
+
- GitHub: [https://github.com/ruby/rdoc](https://github.com/ruby/rdoc)
|
|
4
|
+
- Issues: [https://github.com/ruby/rdoc/issues](https://github.com/ruby/rdoc/issues)
|
|
5
|
+
|
|
6
|
+
## Description
|
|
7
|
+
|
|
8
|
+
RDoc produces HTML and command-line documentation for Ruby projects. RDoc includes the `rdoc` and `ri` tools for generating and displaying documentation from the command-line.
|
|
9
|
+
|
|
10
|
+
## Generating Documentation
|
|
11
|
+
|
|
12
|
+
Once installed, you can create documentation using the `rdoc` command
|
|
13
|
+
|
|
14
|
+
```shell
|
|
15
|
+
rdoc [options] [names...]
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
For an up-to-date option summary, type
|
|
19
|
+
|
|
20
|
+
```shell
|
|
21
|
+
rdoc --help
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
A typical use might be to generate documentation for a package of Ruby source (such as RDoc itself).
|
|
25
|
+
|
|
26
|
+
```shell
|
|
27
|
+
rdoc
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
This command generates documentation for all the Ruby and C source files in and below the current directory. These will be stored in a documentation tree starting in the subdirectory `doc`.
|
|
31
|
+
|
|
32
|
+
You can make this slightly more useful for your readers by having the index page contain the documentation for the primary file. In our case, we could type
|
|
33
|
+
|
|
34
|
+
```shell
|
|
35
|
+
rdoc --main README.md
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
You'll find information on the various formatting tricks you can use in comment blocks in the documentation this generates.
|
|
39
|
+
|
|
40
|
+
RDoc uses file extensions to determine how to process each file. File names ending `.rb` and `.rbw` are assumed to be Ruby source. Files ending `.c` are parsed as C files. All other files are assumed to contain just Markup-style markup (with or without leading `#` comment markers). If directory names are passed to RDoc, they are scanned recursively for C and Ruby source files only.
|
|
41
|
+
|
|
42
|
+
To generate documentation using `rake` see [RDoc::Task](https://ruby.github.io/rdoc/RDoc/Task.html).
|
|
43
|
+
|
|
44
|
+
To generate documentation programmatically:
|
|
45
|
+
|
|
46
|
+
```rb
|
|
47
|
+
require 'rdoc/rdoc'
|
|
48
|
+
|
|
49
|
+
options = RDoc::Options.new
|
|
50
|
+
options.files = ['a.rb', 'b.rb']
|
|
51
|
+
options.setup_generator 'darkfish'
|
|
52
|
+
# see RDoc::Options
|
|
53
|
+
|
|
54
|
+
rdoc = RDoc::RDoc.new
|
|
55
|
+
rdoc.document options
|
|
56
|
+
# see RDoc::RDoc
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
You can specify the target files for document generation with `.document` file in the project root directory. `.document` file contains a list of file and directory names including comment lines starting with `#`. See [https://github.com/ruby/rdoc/blob/master/.document](https://github.com/ruby/rdoc/blob/master/.document) as an example.
|
|
60
|
+
|
|
61
|
+
## Writing Documentation
|
|
62
|
+
|
|
63
|
+
To write documentation for RDoc place a comment above the class, module, method, constant, or attribute you want documented:
|
|
64
|
+
|
|
65
|
+
```rb
|
|
66
|
+
##
|
|
67
|
+
# This class represents an arbitrary shape by a series of points.
|
|
68
|
+
class Shape
|
|
69
|
+
##
|
|
70
|
+
# Creates a new shape described by a +polyline+.
|
|
71
|
+
#
|
|
72
|
+
# If the +polyline+ does not end at the same point it started at the
|
|
73
|
+
# first pointed is copied and placed at the end of the line.
|
|
74
|
+
#
|
|
75
|
+
# An ArgumentError is raised if the line crosses itself, but shapes may
|
|
76
|
+
# be concave.
|
|
77
|
+
def initialize polyline
|
|
78
|
+
# ...
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The default comment markup format is the RDoc::Markup format. TomDoc, Markdown and RD format comments are also supported. You can set the default comment format for your entire project by creating a `.rdoc_options` file. See RDoc::Options@Saved+Options for instructions on creating one. You can also set the comment format for a single file through the `:markup:` directive, but this is only recommended if you wish to switch markup formats. See RDoc::Markup@Other+directives.
|
|
84
|
+
|
|
85
|
+
Comments can contain directives that tell RDoc information that it cannot otherwise discover through parsing. See RDoc::Markup@Directives to control what is or is not documented, to define method arguments or to break up methods in a class by topic. See RDoc::Parser::Ruby for directives used to teach RDoc about metaprogrammed methods.
|
|
86
|
+
|
|
87
|
+
See RDoc::Parser::C for documenting C extensions with RDoc.
|
|
88
|
+
|
|
89
|
+
To determine how well your project is documented run `rdoc -C lib` to get a documentation coverage report. `rdoc -C1 lib` includes parameter names in the documentation coverage report.
|
|
90
|
+
|
|
91
|
+
## Theme Options
|
|
92
|
+
|
|
93
|
+
There are a few community-maintained themes for RDoc:
|
|
94
|
+
|
|
95
|
+
- [rorvswild-theme-rdoc](https://github.com/BaseSecrete/rorvswild-theme-rdoc)
|
|
96
|
+
- [hanna](https://github.com/jeremyevans/hanna) (a fork maintained by [Jeremy Evans](https://github.com/jeremyevans))
|
|
97
|
+
|
|
98
|
+
Please follow the theme's README for usage instructions.
|
|
99
|
+
|
|
100
|
+
## Bugs
|
|
101
|
+
|
|
102
|
+
See CONTRIBUTING.rdoc for information on filing a bug report. It's OK to file a bug report for anything you're having a problem with. If you can't figure out how to make RDoc produce the output you like that is probably a documentation bug.
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
RDoc is Copyright (c) 2001-2003 Dave Thomas, The Pragmatic Programmers. Portions (c) 2007-2011 Eric Hodel. Portions copyright others, see individual files and LEGAL.rdoc for details.
|
|
107
|
+
|
|
108
|
+
RDoc is free software, and may be redistributed under the terms specified in LICENSE.rdoc.
|
|
109
|
+
|
|
110
|
+
## Warranty
|
|
111
|
+
|
|
112
|
+
This software is provided "as is" and without any express or implied warranties, including, without limitation, the implied warranties of merchantability and fitness for a particular purpose.
|
data/RI.md
CHANGED
|
@@ -48,7 +48,7 @@ the [Ruby online documentation](https://docs.ruby-lang.org/en/master):
|
|
|
48
48
|
- If you are working in a terminal window, typing `ri _whatever_` (or just `ri`)
|
|
49
49
|
may be faster than navigating to a browser window and searching for documentation.
|
|
50
50
|
- If you are working in an
|
|
51
|
-
[irb \(interactive Ruby\)](https://
|
|
51
|
+
[irb \(interactive Ruby\)](https://ruby.github.io/irb/index.html)
|
|
52
52
|
session, you _already_ have immediate access to `ri`:
|
|
53
53
|
just type `'show_doc'`.
|
|
54
54
|
|
|
@@ -16,6 +16,16 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
16
16
|
|
|
17
17
|
attr_accessor :absolute_name
|
|
18
18
|
|
|
19
|
+
##
|
|
20
|
+
# Base name of this file
|
|
21
|
+
|
|
22
|
+
attr_reader :base_name
|
|
23
|
+
|
|
24
|
+
##
|
|
25
|
+
# Base name of this file without the extension
|
|
26
|
+
|
|
27
|
+
attr_reader :page_name
|
|
28
|
+
|
|
19
29
|
##
|
|
20
30
|
# All the classes or modules that were declared in
|
|
21
31
|
# this file. These are assigned to either +#classes_hash+
|
|
@@ -40,6 +50,14 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
40
50
|
@relative_name = relative_name
|
|
41
51
|
@parser = nil
|
|
42
52
|
|
|
53
|
+
if relative_name
|
|
54
|
+
@base_name = File.basename(relative_name)
|
|
55
|
+
@page_name = @base_name.sub(/\.(rb|rdoc|txt|md)\z/i, '')
|
|
56
|
+
else
|
|
57
|
+
@base_name = nil
|
|
58
|
+
@page_name = nil
|
|
59
|
+
end
|
|
60
|
+
|
|
43
61
|
@classes_or_modules = []
|
|
44
62
|
end
|
|
45
63
|
|
|
@@ -105,23 +123,8 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
105
123
|
@classes_or_modules << mod
|
|
106
124
|
end
|
|
107
125
|
|
|
108
|
-
##
|
|
109
|
-
# Base name of this file
|
|
110
|
-
|
|
111
|
-
def base_name
|
|
112
|
-
File.basename @relative_name
|
|
113
|
-
end
|
|
114
|
-
|
|
115
126
|
alias name base_name
|
|
116
127
|
|
|
117
|
-
##
|
|
118
|
-
# Only a TopLevel that contains text file) will be displayed. See also
|
|
119
|
-
# RDoc::CodeObject#display?
|
|
120
|
-
|
|
121
|
-
def display?
|
|
122
|
-
text? and super
|
|
123
|
-
end
|
|
124
|
-
|
|
125
128
|
##
|
|
126
129
|
# See RDoc::TopLevel::find_class_or_module
|
|
127
130
|
#--
|
|
@@ -212,16 +215,6 @@ class RDoc::TopLevel < RDoc::Context
|
|
|
212
215
|
end
|
|
213
216
|
end
|
|
214
217
|
|
|
215
|
-
##
|
|
216
|
-
# Base name of this file without the extension
|
|
217
|
-
|
|
218
|
-
def page_name
|
|
219
|
-
basename = File.basename @relative_name
|
|
220
|
-
basename =~ /\.(rb|rdoc|txt|md)$/i
|
|
221
|
-
|
|
222
|
-
$` || basename
|
|
223
|
-
end
|
|
224
|
-
|
|
225
218
|
##
|
|
226
219
|
# Path to this file for use with HTML generator output.
|
|
227
220
|
|
data/lib/rdoc/comment.rb
CHANGED
|
@@ -162,6 +162,12 @@ class RDoc::Comment
|
|
|
162
162
|
self
|
|
163
163
|
end
|
|
164
164
|
|
|
165
|
+
# Change normalized, when creating already normalized comment.
|
|
166
|
+
|
|
167
|
+
def normalized=(value)
|
|
168
|
+
@normalized = value
|
|
169
|
+
end
|
|
170
|
+
|
|
165
171
|
##
|
|
166
172
|
# Was this text normalized?
|
|
167
173
|
|
|
@@ -223,14 +229,190 @@ class RDoc::Comment
|
|
|
223
229
|
@format == 'tomdoc'
|
|
224
230
|
end
|
|
225
231
|
|
|
226
|
-
|
|
227
|
-
# Create a new parsed comment from a document
|
|
232
|
+
MULTILINE_DIRECTIVES = %w[call-seq].freeze # :nodoc:
|
|
228
233
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
234
|
+
# There are more, but already handled by RDoc::Parser::C
|
|
235
|
+
COLON_LESS_DIRECTIVES = %w[call-seq Document-method].freeze # :nodoc:
|
|
236
|
+
|
|
237
|
+
DIRECTIVE_OR_ESCAPED_DIRECTIV_REGEXP = /\A(?<colon>\\?:|:?)(?<directive>[\w-]+):(?<param>.*)/
|
|
238
|
+
|
|
239
|
+
private_constant :MULTILINE_DIRECTIVES, :COLON_LESS_DIRECTIVES, :DIRECTIVE_OR_ESCAPED_DIRECTIV_REGEXP
|
|
240
|
+
|
|
241
|
+
class << self
|
|
242
|
+
|
|
243
|
+
##
|
|
244
|
+
# Create a new parsed comment from a document
|
|
235
245
|
|
|
246
|
+
def from_document(document) # :nodoc:
|
|
247
|
+
comment = RDoc::Comment.new('')
|
|
248
|
+
comment.document = document
|
|
249
|
+
comment.location = RDoc::TopLevel.new(document.file) if document.file
|
|
250
|
+
comment
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
# Parse comment, collect directives as an attribute and return [normalized_comment_text, directives_hash]
|
|
254
|
+
# This method expands include and removes everything not needed in the document text, such as
|
|
255
|
+
# private section, directive line, comment characters `# /* * */` and indent spaces.
|
|
256
|
+
#
|
|
257
|
+
# RDoc comment consists of include, directive, multiline directive, private section and comment text.
|
|
258
|
+
#
|
|
259
|
+
# Include
|
|
260
|
+
# # :include: filename
|
|
261
|
+
#
|
|
262
|
+
# Directive
|
|
263
|
+
# # :directive-without-value:
|
|
264
|
+
# # :directive-with-value: value
|
|
265
|
+
#
|
|
266
|
+
# Multiline directive (only :call-seq:)
|
|
267
|
+
# # :multiline-directive:
|
|
268
|
+
# # value1
|
|
269
|
+
# # value2
|
|
270
|
+
#
|
|
271
|
+
# Private section
|
|
272
|
+
# #--
|
|
273
|
+
# # private comment
|
|
274
|
+
# #++
|
|
275
|
+
|
|
276
|
+
def parse(text, filename, line_no, type, &include_callback)
|
|
277
|
+
case type
|
|
278
|
+
when :ruby
|
|
279
|
+
text = text.gsub(/^#+/, '') if text.start_with?('#')
|
|
280
|
+
private_start_regexp = /^-{2,}$/
|
|
281
|
+
private_end_regexp = /^\+{2}$/
|
|
282
|
+
indent_regexp = /^\s*/
|
|
283
|
+
when :c
|
|
284
|
+
private_start_regexp = /^(\s*\*)?-{2,}$/
|
|
285
|
+
private_end_regexp = /^(\s*\*)?\+{2}$/
|
|
286
|
+
indent_regexp = /^\s*(\/\*+|\*)?\s*/
|
|
287
|
+
text = text.gsub(/\s*\*+\/\s*\z/, '')
|
|
288
|
+
when :simple
|
|
289
|
+
# Unlike other types, this implementation only looks for two dashes at
|
|
290
|
+
# the beginning of the line. Three or more dashes are considered to be
|
|
291
|
+
# a rule and ignored.
|
|
292
|
+
private_start_regexp = /^-{2}$/
|
|
293
|
+
private_end_regexp = /^\+{2}$/
|
|
294
|
+
indent_regexp = /^\s*/
|
|
295
|
+
end
|
|
296
|
+
|
|
297
|
+
directives = {}
|
|
298
|
+
lines = text.split("\n")
|
|
299
|
+
in_private = false
|
|
300
|
+
comment_lines = []
|
|
301
|
+
until lines.empty?
|
|
302
|
+
line = lines.shift
|
|
303
|
+
read_lines = 1
|
|
304
|
+
if in_private
|
|
305
|
+
# If `++` appears in a private section that starts with `--`, private section ends.
|
|
306
|
+
in_private = false if line.match?(private_end_regexp)
|
|
307
|
+
line_no += read_lines
|
|
308
|
+
next
|
|
309
|
+
elsif line.match?(private_start_regexp)
|
|
310
|
+
# If `--` appears in a line, private section starts.
|
|
311
|
+
in_private = true
|
|
312
|
+
line_no += read_lines
|
|
313
|
+
next
|
|
314
|
+
end
|
|
315
|
+
|
|
316
|
+
prefix = line[indent_regexp]
|
|
317
|
+
prefix_indent = ' ' * prefix.size
|
|
318
|
+
line = line.byteslice(prefix.bytesize..)
|
|
319
|
+
|
|
320
|
+
if (directive_match = DIRECTIVE_OR_ESCAPED_DIRECTIV_REGEXP.match(line))
|
|
321
|
+
colon = directive_match[:colon]
|
|
322
|
+
directive = directive_match[:directive]
|
|
323
|
+
raw_param = directive_match[:param]
|
|
324
|
+
param = raw_param.strip
|
|
325
|
+
else
|
|
326
|
+
colon = directive = raw_param = param = nil
|
|
327
|
+
end
|
|
328
|
+
|
|
329
|
+
if !directive
|
|
330
|
+
comment_lines << prefix_indent + line
|
|
331
|
+
elsif colon == '\\:'
|
|
332
|
+
# If directive is escaped, unescape it
|
|
333
|
+
comment_lines << prefix_indent + line.sub('\\:', ':')
|
|
334
|
+
elsif raw_param.start_with?(':') || (colon.empty? && !COLON_LESS_DIRECTIVES.include?(directive))
|
|
335
|
+
# Something like `:toto::` is not a directive
|
|
336
|
+
# Only few directives allows to start without a colon
|
|
337
|
+
comment_lines << prefix_indent + line
|
|
338
|
+
elsif directive == 'include'
|
|
339
|
+
filename_to_include = param
|
|
340
|
+
include_callback.call(filename_to_include, prefix_indent).lines.each { |l| comment_lines << l.chomp }
|
|
341
|
+
elsif MULTILINE_DIRECTIVES.include?(directive)
|
|
342
|
+
value_lines = take_multiline_directive_value_lines(directive, filename, line_no, lines, prefix_indent.size, indent_regexp, !param.empty?)
|
|
343
|
+
read_lines += value_lines.size
|
|
344
|
+
lines.shift(value_lines.size)
|
|
345
|
+
unless param.empty?
|
|
346
|
+
# Accept `:call-seq: first-line\n second-line` for now
|
|
347
|
+
value_lines.unshift(param)
|
|
348
|
+
end
|
|
349
|
+
value = value_lines.join("\n")
|
|
350
|
+
directives[directive] = [value.empty? ? nil : value, line_no]
|
|
351
|
+
else
|
|
352
|
+
directives[directive] = [param.empty? ? nil : param, line_no]
|
|
353
|
+
end
|
|
354
|
+
line_no += read_lines
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
normalized_comment = String.new(encoding: text.encoding) << normalize_comment_lines(comment_lines).join("\n")
|
|
358
|
+
[normalized_comment, directives]
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
# Remove preceding indent spaces and blank lines from the comment lines
|
|
362
|
+
|
|
363
|
+
private def normalize_comment_lines(lines)
|
|
364
|
+
blank_line_regexp = /\A\s*\z/
|
|
365
|
+
lines = lines.dup
|
|
366
|
+
lines.shift while lines.first&.match?(blank_line_regexp)
|
|
367
|
+
lines.pop while lines.last&.match?(blank_line_regexp)
|
|
368
|
+
|
|
369
|
+
min_spaces = lines.map do |l|
|
|
370
|
+
l.match(/\A *(?=\S)/)&.end(0)
|
|
371
|
+
end.compact.min
|
|
372
|
+
if min_spaces && min_spaces > 0
|
|
373
|
+
lines.map { |l| l[min_spaces..] || '' }
|
|
374
|
+
else
|
|
375
|
+
lines
|
|
376
|
+
end
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
# Take value lines of multiline directive
|
|
380
|
+
|
|
381
|
+
private def take_multiline_directive_value_lines(directive, filename, line_no, lines, base_indent_size, indent_regexp, has_param)
|
|
382
|
+
return [] if lines.empty?
|
|
383
|
+
|
|
384
|
+
first_indent_size = lines.first.match(indent_regexp).end(0)
|
|
385
|
+
|
|
386
|
+
# Blank line or unindented line is not part of multiline-directive value
|
|
387
|
+
return [] if first_indent_size <= base_indent_size
|
|
388
|
+
|
|
389
|
+
if has_param
|
|
390
|
+
# :multiline-directive: line1
|
|
391
|
+
# line2
|
|
392
|
+
# line3
|
|
393
|
+
#
|
|
394
|
+
value_lines = lines.take_while do |l|
|
|
395
|
+
l.rstrip.match(indent_regexp).end(0) > base_indent_size
|
|
396
|
+
end
|
|
397
|
+
min_indent = value_lines.map { |l| l.match(indent_regexp).end(0) }.min
|
|
398
|
+
value_lines.map { |l| l[min_indent..] }
|
|
399
|
+
else
|
|
400
|
+
# Take indented lines accepting blank lines between them
|
|
401
|
+
value_lines = lines.take_while do |l|
|
|
402
|
+
l = l.rstrip
|
|
403
|
+
indent = l[indent_regexp]
|
|
404
|
+
if indent == l || indent.size >= first_indent_size
|
|
405
|
+
true
|
|
406
|
+
end
|
|
407
|
+
end
|
|
408
|
+
value_lines.map! { |l| (l[first_indent_size..] || '').chomp }
|
|
409
|
+
|
|
410
|
+
if value_lines.size != lines.size && !value_lines.last.empty?
|
|
411
|
+
warn "#{filename}:#{line_no} Multiline directive :#{directive}: should end with a blank line."
|
|
412
|
+
end
|
|
413
|
+
value_lines.pop while value_lines.last&.empty?
|
|
414
|
+
value_lines
|
|
415
|
+
end
|
|
416
|
+
end
|
|
417
|
+
end
|
|
236
418
|
end
|
data/lib/rdoc/cross_reference.rb
CHANGED
|
@@ -200,7 +200,7 @@ class RDoc::CrossReference
|
|
|
200
200
|
ref = resolve_method name unless ref
|
|
201
201
|
|
|
202
202
|
# Try a page name
|
|
203
|
-
ref = @store.page name if not ref and name =~ /^[\w
|
|
203
|
+
ref = @store.page name if not ref and name =~ /^[\w.\/]+$/
|
|
204
204
|
|
|
205
205
|
ref = nil if RDoc::Alias === ref # external alias, can't link to it
|
|
206
206
|
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
##
|
|
4
|
+
# Aliki theme for RDoc documentation
|
|
5
|
+
#
|
|
6
|
+
# Author: Stan Lo
|
|
7
|
+
#
|
|
8
|
+
|
|
9
|
+
class RDoc::Generator::Aliki < RDoc::Generator::Darkfish
|
|
10
|
+
RDoc::RDoc.add_generator self
|
|
11
|
+
|
|
12
|
+
def initialize(store, options)
|
|
13
|
+
super
|
|
14
|
+
aliki_template_dir = File.expand_path(File.join(__dir__, 'template', 'aliki'))
|
|
15
|
+
@template_dir = Pathname.new(aliki_template_dir)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
##
|
|
19
|
+
# Copy only the static assets required by the Aliki theme. Unlike Darkfish we
|
|
20
|
+
# don't ship embedded fonts or image sprites, so limit the asset list to keep
|
|
21
|
+
# generated documentation lightweight.
|
|
22
|
+
|
|
23
|
+
def write_style_sheet
|
|
24
|
+
debug_msg "Copying Aliki static files"
|
|
25
|
+
options = { verbose: $DEBUG_RDOC, noop: @dry_run }
|
|
26
|
+
|
|
27
|
+
install_rdoc_static_file @template_dir + 'css/rdoc.css', "./css/rdoc.css", options
|
|
28
|
+
|
|
29
|
+
unless @options.template_stylesheets.empty?
|
|
30
|
+
FileUtils.cp @options.template_stylesheets, '.', **options
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
Dir[(@template_dir + 'js/**/*').to_s].each do |path|
|
|
34
|
+
next if File.directory?(path)
|
|
35
|
+
next if File.basename(path).start_with?('.')
|
|
36
|
+
|
|
37
|
+
dst = Pathname.new(path).relative_path_from(@template_dir)
|
|
38
|
+
|
|
39
|
+
install_rdoc_static_file @template_dir + path, dst, options
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<aside class="table-of-contents" role="complementary" aria-label="Table of Contents">
|
|
2
|
+
<div class="toc-sticky">
|
|
3
|
+
<h3 class="toc-heading">On This Page</h3>
|
|
4
|
+
<nav class="toc-nav" id="toc-nav" aria-label="Page sections">
|
|
5
|
+
<!-- Generated by JavaScript based on page headings -->
|
|
6
|
+
</nav>
|
|
7
|
+
</div>
|
|
8
|
+
</aside>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<footer class="site-footer">
|
|
2
|
+
<% if @options.footer_content && !@options.footer_content.empty? %>
|
|
3
|
+
<div class="footer-content">
|
|
4
|
+
<% @options.footer_content.each do |column_title, links| %>
|
|
5
|
+
<div>
|
|
6
|
+
<h3><%= h column_title %></h3>
|
|
7
|
+
<ul>
|
|
8
|
+
<% links.each do |text, url| %>
|
|
9
|
+
<li><a href="<%= h url %>"><%= h text %></a></li>
|
|
10
|
+
<% end %>
|
|
11
|
+
</ul>
|
|
12
|
+
</div>
|
|
13
|
+
<% end %>
|
|
14
|
+
</div>
|
|
15
|
+
<% end %>
|
|
16
|
+
|
|
17
|
+
<div class="footer-bottom">
|
|
18
|
+
<p>
|
|
19
|
+
Generated by <a href="https://ruby.github.io/rdoc/">RDoc <%= RDoc::VERSION %></a>
|
|
20
|
+
using the Aliki theme by <a href="http://st0012.dev">Stan Lo</a>
|
|
21
|
+
</p>
|
|
22
|
+
</div>
|
|
23
|
+
</footer>
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
<meta charset="<%= @options.charset %>">
|
|
2
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
3
|
+
|
|
4
|
+
<title><%= h @title %></title>
|
|
5
|
+
|
|
6
|
+
<%- if defined?(klass) %>
|
|
7
|
+
<meta
|
|
8
|
+
name="keywords"
|
|
9
|
+
content="ruby,<%= h "#{klass.type},#{klass.full_name}" %>"
|
|
10
|
+
>
|
|
11
|
+
<%- if klass.comment.empty? %>
|
|
12
|
+
<meta
|
|
13
|
+
name="description"
|
|
14
|
+
content="Documentation for the <%= h "#{klass.full_name} #{klass.type}" %>"
|
|
15
|
+
>
|
|
16
|
+
<%- else %>
|
|
17
|
+
<meta
|
|
18
|
+
name="description"
|
|
19
|
+
content="<%= h "#{klass.type} #{klass.full_name}: #{excerpt(klass.comment)}" %>"
|
|
20
|
+
>
|
|
21
|
+
<%- end %>
|
|
22
|
+
<%- elsif defined?(file) %>
|
|
23
|
+
<meta name="keywords" content="ruby,documentation,<%= h file.page_name %>">
|
|
24
|
+
<meta
|
|
25
|
+
name="description"
|
|
26
|
+
content="<%= h "#{file.page_name}: #{excerpt(file.comment)}" %>"
|
|
27
|
+
>
|
|
28
|
+
<%- elsif @title %>
|
|
29
|
+
<meta name="keywords" content="ruby,documentation,<%= h @title %>">
|
|
30
|
+
<%- if @options.main_page and
|
|
31
|
+
main_page = @files.find { |f| f.full_name == @options.main_page } then %>
|
|
32
|
+
<meta
|
|
33
|
+
name="description"
|
|
34
|
+
content="<%= h "#{@title}: #{excerpt(main_page.comment)}" %>"
|
|
35
|
+
>
|
|
36
|
+
<%- else %>
|
|
37
|
+
<meta name="description" content="Documentation for <%= h @title %>">
|
|
38
|
+
<%- end %>
|
|
39
|
+
<%- end %>
|
|
40
|
+
|
|
41
|
+
<%- if canonical_url = @options.canonical_root %>
|
|
42
|
+
<% canonical_url = current.canonical_url if defined?(current) %>
|
|
43
|
+
<link rel="canonical" href="<%= canonical_url %>">
|
|
44
|
+
<%- end %>
|
|
45
|
+
|
|
46
|
+
<!-- Open Graph / Facebook -->
|
|
47
|
+
<meta property="og:type" content="website">
|
|
48
|
+
<meta property="og:title" content="<%= h @title %>">
|
|
49
|
+
|
|
50
|
+
<%- if defined?(klass) %>
|
|
51
|
+
<%- if klass.comment.empty? %>
|
|
52
|
+
<meta
|
|
53
|
+
property="og:description"
|
|
54
|
+
content="Documentation for <%= h klass.full_name %> <%= h klass.type %> - API reference and code examples"
|
|
55
|
+
>
|
|
56
|
+
<%- else %>
|
|
57
|
+
<meta property="og:description" content="<%= h excerpt(klass.comment) %>">
|
|
58
|
+
<%- end %>
|
|
59
|
+
<%- elsif defined?(file) %>
|
|
60
|
+
<%- if file.comment.empty? %>
|
|
61
|
+
<meta
|
|
62
|
+
property="og:description"
|
|
63
|
+
content="<%= h file.page_name %> - <%= h @title %> documentation"
|
|
64
|
+
>
|
|
65
|
+
<%- else %>
|
|
66
|
+
<meta property="og:description" content="<%= h excerpt(file.comment) %>">
|
|
67
|
+
<%- end %>
|
|
68
|
+
<%- else %>
|
|
69
|
+
<meta
|
|
70
|
+
property="og:description"
|
|
71
|
+
content="API documentation for <%= h @title %> - Browse classes, modules, and methods"
|
|
72
|
+
>
|
|
73
|
+
<%- end %>
|
|
74
|
+
|
|
75
|
+
<%- if canonical_url = @options.canonical_root %>
|
|
76
|
+
<% canonical_url = current.canonical_url if defined?(current) %>
|
|
77
|
+
<meta property="og:url" content="<%= canonical_url %>">
|
|
78
|
+
<%- end %>
|
|
79
|
+
|
|
80
|
+
<!-- Twitter -->
|
|
81
|
+
<meta name="twitter:card" content="summary">
|
|
82
|
+
<meta name="twitter:title" content="<%= h @title %>">
|
|
83
|
+
|
|
84
|
+
<%- if defined?(klass) %>
|
|
85
|
+
<%- if klass.comment.empty? %>
|
|
86
|
+
<meta
|
|
87
|
+
name="twitter:description"
|
|
88
|
+
content="Documentation for <%= h klass.full_name %> <%= h klass.type %> - API reference and code examples"
|
|
89
|
+
>
|
|
90
|
+
<%- else %>
|
|
91
|
+
<meta name="twitter:description" content="<%= h excerpt(klass.comment) %>">
|
|
92
|
+
<%- end %>
|
|
93
|
+
<%- elsif defined?(file) %>
|
|
94
|
+
<%- if file.comment.empty? %>
|
|
95
|
+
<meta
|
|
96
|
+
name="twitter:description"
|
|
97
|
+
content="<%= h file.page_name %> - <%= h @title %> documentation"
|
|
98
|
+
>
|
|
99
|
+
<%- else %>
|
|
100
|
+
<meta name="twitter:description" content="<%= h excerpt(file.comment) %>">
|
|
101
|
+
<%- end %>
|
|
102
|
+
<%- else %>
|
|
103
|
+
<meta
|
|
104
|
+
name="twitter:description"
|
|
105
|
+
content="API documentation for <%= h @title %> - Browse classes, modules, and methods"
|
|
106
|
+
>
|
|
107
|
+
<%- end %>
|
|
108
|
+
|
|
109
|
+
<script type="text/javascript">
|
|
110
|
+
var rdoc_rel_prefix = "<%= h asset_rel_prefix %>/";
|
|
111
|
+
var index_rel_prefix = "<%= h rel_prefix %>/";
|
|
112
|
+
</script>
|
|
113
|
+
|
|
114
|
+
<script
|
|
115
|
+
src="<%= h asset_rel_prefix %>/js/theme-toggle.js?v=<%= h RDoc::VERSION %>"
|
|
116
|
+
></script>
|
|
117
|
+
|
|
118
|
+
<script
|
|
119
|
+
src="<%= h asset_rel_prefix %>/js/navigation.js?v=<%= h RDoc::VERSION %>"
|
|
120
|
+
defer
|
|
121
|
+
></script>
|
|
122
|
+
|
|
123
|
+
<script
|
|
124
|
+
src="<%= h asset_rel_prefix %>/js/search.js?v=<%= h RDoc::VERSION %>"
|
|
125
|
+
defer
|
|
126
|
+
></script>
|
|
127
|
+
|
|
128
|
+
<script
|
|
129
|
+
src="<%= h asset_rel_prefix %>/js/search_index.js?v=<%= h RDoc::VERSION %>"
|
|
130
|
+
defer
|
|
131
|
+
></script>
|
|
132
|
+
|
|
133
|
+
<script
|
|
134
|
+
src="<%= h asset_rel_prefix %>/js/searcher.js?v=<%= h RDoc::VERSION %>"
|
|
135
|
+
defer
|
|
136
|
+
></script>
|
|
137
|
+
|
|
138
|
+
<script
|
|
139
|
+
src="<%= h asset_rel_prefix %>/js/c_highlighter.js?v=<%= h RDoc::VERSION %>"
|
|
140
|
+
defer
|
|
141
|
+
></script>
|
|
142
|
+
|
|
143
|
+
<script
|
|
144
|
+
src="<%= h asset_rel_prefix %>/js/aliki.js?v=<%= h RDoc::VERSION %>"
|
|
145
|
+
defer
|
|
146
|
+
></script>
|
|
147
|
+
|
|
148
|
+
<link
|
|
149
|
+
href="<%= h asset_rel_prefix %>/css/rdoc.css?v=<%= h RDoc::VERSION %>"
|
|
150
|
+
rel="stylesheet"
|
|
151
|
+
>
|
|
152
|
+
|
|
153
|
+
<%- @options.template_stylesheets.each do |stylesheet| %>
|
|
154
|
+
<link
|
|
155
|
+
href="<%= h asset_rel_prefix %>/<%= h File.basename stylesheet %>?v=<%= h RDoc::VERSION %>"
|
|
156
|
+
rel="stylesheet"
|
|
157
|
+
>
|
|
158
|
+
<%- end %>
|