rdoc 6.14.1 → 6.15.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 +112 -0
- data/RI.md +1 -1
- data/lib/rdoc/code_object/top_level.rb +0 -8
- data/lib/rdoc/cross_reference.rb +1 -1
- 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/json_index/js/searcher.js +6 -1
- data/lib/rdoc/markdown.kpeg +72 -18
- data/lib/rdoc/markdown.rb +411 -547
- data/lib/rdoc/markup/to_html.rb +156 -10
- data/lib/rdoc/markup/to_html_crossref.rb +53 -23
- data/lib/rdoc/options.rb +1 -1
- 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/version.rb +1 -1
- data/rdoc.gemspec +7 -4
- metadata +19 -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: 737b80cad7809fc0b20efe70270867bcc3a7f3ae7c5c0e1f818769b8ab40c7cc
|
4
|
+
data.tar.gz: 6754787e054cab04658a068f8e3a2be8cacb1473991d91a330beb0118bf22930
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fad664b000fbb058f96f2e7f032ba767b86213a21380cf584d30ff34710acc5c383bc5053b2a06e3e7190c9f4188d397ba7bc9be226d82231fd2bad76c046258
|
7
|
+
data.tar.gz: 5afe676ff848a49515c6fba65fc5e8a4b765c5e52af6c0128caa36a7a1253a41fc3ac0b0ef2098f74fd69269e285c8d3ec67128cc631b60c97062c5c9fe7cbc0
|
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
|
|
@@ -114,14 +114,6 @@ class RDoc::TopLevel < RDoc::Context
|
|
114
114
|
|
115
115
|
alias name base_name
|
116
116
|
|
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
117
|
##
|
126
118
|
# See RDoc::TopLevel::find_class_or_module
|
127
119
|
#--
|
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
|
|
@@ -72,10 +72,30 @@ function hookSearch() {
|
|
72
72
|
}
|
73
73
|
|
74
74
|
search.select = function(result) {
|
75
|
-
|
75
|
+
var href = result.firstChild.firstChild.href;
|
76
|
+
var query = this.input.value;
|
77
|
+
if (query) {
|
78
|
+
var url = new URL(href, window.location.origin);
|
79
|
+
url.searchParams.set('q', query);
|
80
|
+
url.searchParams.set('nav', '0');
|
81
|
+
href = url.toString();
|
82
|
+
}
|
83
|
+
window.location.href = href;
|
76
84
|
}
|
77
85
|
|
78
86
|
search.scrollIntoView = search.scrollInWindow;
|
87
|
+
|
88
|
+
// Check for ?q= URL parameter and trigger search automatically
|
89
|
+
if (typeof URLSearchParams !== 'undefined') {
|
90
|
+
var urlParams = new URLSearchParams(window.location.search);
|
91
|
+
var queryParam = urlParams.get('q');
|
92
|
+
if (queryParam) {
|
93
|
+
var navParam = urlParams.get('nav');
|
94
|
+
var autoSelect = navParam !== '0';
|
95
|
+
input.value = queryParam;
|
96
|
+
search.search(queryParam, autoSelect);
|
97
|
+
}
|
98
|
+
}
|
79
99
|
};
|
80
100
|
|
81
101
|
function hookFocus() {
|
@@ -34,6 +34,8 @@ Search.prototype = Object.assign({}, Navigation, new function() {
|
|
34
34
|
}
|
35
35
|
|
36
36
|
this.search = function(value, selectFirstMatch) {
|
37
|
+
this.selectFirstMatch = selectFirstMatch;
|
38
|
+
|
37
39
|
value = value.trim().toLowerCase();
|
38
40
|
if (value) {
|
39
41
|
this.setNavigationActive(true);
|
@@ -76,7 +78,15 @@ Search.prototype = Object.assign({}, Navigation, new function() {
|
|
76
78
|
//TODO: ECMAScript
|
77
79
|
//if (jQuery.browser.msie) this.$element[0].className += '';
|
78
80
|
|
79
|
-
if (
|
81
|
+
if (this.selectFirstMatch && this.current) {
|
82
|
+
this.selectFirstMatch = false;
|
83
|
+
this.select(this.current);
|
84
|
+
}
|
85
|
+
|
86
|
+
if (isLast) {
|
87
|
+
this.selectFirstMatch = false;
|
88
|
+
this.result.setAttribute('aria-busy', 'false');
|
89
|
+
}
|
80
90
|
}
|
81
91
|
|
82
92
|
this.move = function(isDown) {
|
@@ -58,7 +58,12 @@ Searcher.prototype = new function() {
|
|
58
58
|
|
59
59
|
function buildRegexps(queries) {
|
60
60
|
return queries.map(function(query) {
|
61
|
-
|
61
|
+
var pattern = [];
|
62
|
+
for (var i = 0; i < query.length; i++) {
|
63
|
+
var char = RegExp.escape(query[i]);
|
64
|
+
pattern.push('([' + char + '])([^' + char + ']*?)');
|
65
|
+
}
|
66
|
+
return new RegExp(pattern.join(''), 'i');
|
62
67
|
});
|
63
68
|
}
|
64
69
|
|
data/lib/rdoc/markdown.kpeg
CHANGED
@@ -496,6 +496,57 @@
|
|
496
496
|
"<s>#{text}</s>"
|
497
497
|
end
|
498
498
|
end
|
499
|
+
|
500
|
+
##
|
501
|
+
# Wraps `text` in code markup for rdoc inline formatting
|
502
|
+
|
503
|
+
def code text
|
504
|
+
# trim even spaces
|
505
|
+
text = $2 while /\A( +|\t+)(.*)\1\z/ =~ text
|
506
|
+
# escape unescaped backslash at the end
|
507
|
+
backslash_at_end = "\\" if /(?<!\\)(?:\\\\)*\\\z/.match?(text)
|
508
|
+
"<code>#{text}#{backslash_at_end}</code>"
|
509
|
+
end
|
510
|
+
|
511
|
+
##
|
512
|
+
# Parses inline markdown in table cells
|
513
|
+
|
514
|
+
def parse_table_cells(table)
|
515
|
+
# Parse header cells
|
516
|
+
table.header = table.header.map { |cell| parse_cell_inline(cell) }
|
517
|
+
|
518
|
+
# Parse body cells
|
519
|
+
table.body = table.body.map do |row|
|
520
|
+
row.map { |cell| parse_cell_inline(cell) }
|
521
|
+
end
|
522
|
+
|
523
|
+
table
|
524
|
+
end
|
525
|
+
|
526
|
+
##
|
527
|
+
# Parses inline markdown in a single table cell
|
528
|
+
|
529
|
+
def parse_cell_inline(text)
|
530
|
+
return text if text.nil? || text.empty?
|
531
|
+
|
532
|
+
# Create a new parser instance for the cell
|
533
|
+
cell_parser = RDoc::Markdown.new(@extensions, @debug)
|
534
|
+
|
535
|
+
# Parse the cell content
|
536
|
+
doc = cell_parser.parse(text)
|
537
|
+
|
538
|
+
# Extract the parsed content
|
539
|
+
if doc && doc.parts && !doc.parts.empty?
|
540
|
+
para = doc.parts.first
|
541
|
+
if para.is_a?(RDoc::Markup::Paragraph)
|
542
|
+
para.parts.join
|
543
|
+
else
|
544
|
+
text
|
545
|
+
end
|
546
|
+
else
|
547
|
+
text
|
548
|
+
end
|
549
|
+
end
|
499
550
|
}
|
500
551
|
|
501
552
|
root = Doc
|
@@ -1064,32 +1115,32 @@ Ticks3 = "```" !"`"
|
|
1064
1115
|
Ticks4 = "````" !"`"
|
1065
1116
|
Ticks5 = "`````" !"`"
|
1066
1117
|
|
1067
|
-
Code = ( Ticks1
|
1118
|
+
Code = ( Ticks1 < (
|
1068
1119
|
( !"`" Nonspacechar )+ | !Ticks1 /`+/ |
|
1069
|
-
!
|
1070
|
-
)+ >
|
1071
|
-
Ticks2
|
1120
|
+
!Ticks1 ( @Spacechar | @Newline !@BlankLine )
|
1121
|
+
)+ > Ticks1 |
|
1122
|
+
Ticks2 < (
|
1072
1123
|
( !"`" Nonspacechar )+ |
|
1073
1124
|
!Ticks2 /`+/ |
|
1074
|
-
!
|
1075
|
-
)+ >
|
1076
|
-
Ticks3
|
1125
|
+
!Ticks2 ( @Spacechar | @Newline !@BlankLine )
|
1126
|
+
)+ > Ticks2 |
|
1127
|
+
Ticks3 < (
|
1077
1128
|
( !"`" Nonspacechar )+ |
|
1078
1129
|
!Ticks3 /`+/ |
|
1079
|
-
!
|
1080
|
-
)+ >
|
1081
|
-
Ticks4
|
1130
|
+
!Ticks3 ( @Spacechar | @Newline !@BlankLine )
|
1131
|
+
)+ > Ticks3 |
|
1132
|
+
Ticks4 < (
|
1082
1133
|
( !"`" Nonspacechar )+ |
|
1083
1134
|
!Ticks4 /`+/ |
|
1084
|
-
!
|
1085
|
-
)+ >
|
1086
|
-
Ticks5
|
1135
|
+
!Ticks4 ( @Spacechar | @Newline !@BlankLine )
|
1136
|
+
)+ > Ticks4 |
|
1137
|
+
Ticks5 < (
|
1087
1138
|
( !"`" Nonspacechar )+ |
|
1088
1139
|
!Ticks5 /`+/ |
|
1089
|
-
!
|
1090
|
-
)+ >
|
1140
|
+
!Ticks5 ( @Spacechar | @Newline !@BlankLine )
|
1141
|
+
)+ > Ticks5
|
1091
1142
|
)
|
1092
|
-
{
|
1143
|
+
{ code text }
|
1093
1144
|
|
1094
1145
|
RawHtml = < (HtmlComment | HtmlBlockScript | HtmlTag) >
|
1095
1146
|
{ if html? then text else '' end }
|
@@ -1201,7 +1252,10 @@ CodeFence = &{ github? }
|
|
1201
1252
|
|
1202
1253
|
Table = &{ github? }
|
1203
1254
|
TableHead:header TableLine:line TableRow+:body
|
1204
|
-
{
|
1255
|
+
{
|
1256
|
+
table = RDoc::Markup::Table.new(header, line, body)
|
1257
|
+
parse_table_cells(table)
|
1258
|
+
}
|
1205
1259
|
|
1206
1260
|
TableHead = TableItem2+:items "|"? @Newline
|
1207
1261
|
{ items }
|
@@ -1210,7 +1264,7 @@ TableRow = ( ( TableItem:item1 TableItem2*:items { [item1, *items] } ):row | Tab
|
|
1210
1264
|
{ row }
|
1211
1265
|
TableItem2 = "|" TableItem
|
1212
1266
|
TableItem = < /(?:\\.|[^|\n])+/ >
|
1213
|
-
{ text.strip.gsub(/\\(
|
1267
|
+
{ text.strip.gsub(/\\([|])/, '\1') }
|
1214
1268
|
|
1215
1269
|
TableLine = ( ( TableAlign:align1 TableAlign2*:aligns {[align1, *aligns] } ):line | TableAlign2+:line ) "|"? @Newline
|
1216
1270
|
{ line }
|