Skip to content

Commit 86640e0

Browse files
committed
Update documentation
1 parent dd0c878 commit 86640e0

File tree

11 files changed

+140
-13
lines changed

11 files changed

+140
-13
lines changed

TODO.rdoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Some file contains some things that might happen in RDoc, or might not
33
=== RDoc 3.10
44

55
* Copy static files into doc dir for HTML
6+
* Add sections to the ToC
67

78
=== RDoc 3.11
89

@@ -11,6 +12,7 @@ Some file contains some things that might happen in RDoc, or might not
1112
* Parse only changed files (like in ruby)
1213
* Page of Glory (or Shame) in HTML output showing documentation coverage
1314
statistics.
15+
* Link to the parent-class implementation of methods that use super
1416

1517
=== RDoc 4
1618

lib/rdoc/cross_reference.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ class RDoc::CrossReference
9191
# labels for headings
9292
(?:@[\w+%-]+)?/x
9393

94+
##
95+
# Hash of references that have been looked-up to their replacements
96+
9497
attr_accessor :seen
9598

9699
##

lib/rdoc/markup/heading.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@ class RDoc::Markup::Heading < Struct.new :level, :text
66
@to_html = nil
77
@to_label = nil
88

9+
##
10+
# A singleton RDoc::Markup::ToLabel formatter for headings.
11+
912
def self.to_label
1013
@to_label ||= RDoc::Markup::ToLabel.new
1114
end
1215

16+
##
17+
# A singleton plain HTML formatter for headings. Used for creating labels
18+
# for the Table of Contents
19+
1320
def self.to_html
1421
return @to_html if @to_html
1522

lib/rdoc/markup/pre_process.rb

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
class RDoc::Markup::PreProcess
1212

13+
##
14+
# An RDoc::Options instance that will be filled in with overrides from
15+
# directives
16+
1317
attr_accessor :options
1418

1519
##
@@ -75,8 +79,9 @@ def initialize(input_file_name, include_path)
7579
# If no matching directive was registered the directive is restored to the
7680
# text.
7781
#
78-
# If +code_object+ is given and the param is set as metadata on the
79-
# +code_object+. See RDoc::CodeObject#metadata
82+
# If +code_object+ is given and the directive is unknown then the
83+
# directive's parameter is set as metadata on the +code_object+. See
84+
# RDoc::CodeObject#metadata for details.
8085

8186
def handle text, code_object = nil, &block
8287
if RDoc::Comment === text then
@@ -116,6 +121,14 @@ def handle text, code_object = nil, &block
116121
text
117122
end
118123

124+
##
125+
# Performs the actions described by +directive+ and its parameter +param+.
126+
#
127+
# +code_object+ is used for directives that operate on a class or module.
128+
# +prefix+ is used to ensure the replacement for handled directives is
129+
# correct. +encoding+ is used for the <tt>include</tt> directive.
130+
#
131+
# For a list of directives in RDoc see RDoc::Markup.
119132
#--
120133
# When 1.8.7 support is ditched prefix can be defaulted to ''
121134

lib/rdoc/markup/to_html_snippet.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ def start_accepting
121121
@characters = 0
122122
end
123123

124+
##
125+
# Removes escaping from the cross-references in +special+
126+
124127
def handle_special_CROSSREF special
125128
special.text.sub(/\A\\/, '')
126129
end
@@ -226,18 +229,29 @@ def convert_flow flow
226229
res.join
227230
end
228231

232+
##
233+
# Maintains a bitmask to allow HTML elements to be closed properly. See
234+
# RDoc::Markup::Formatter.
235+
229236
def on_tags res, item
230237
@mask ^= item.turn_on
231238

232239
super
233240
end
234241

242+
##
243+
# Maintains a bitmask to allow HTML elements to be closed properly. See
244+
# RDoc::Markup::Formatter.
245+
235246
def off_tags res, item
236247
@mask ^= item.turn_off
237248

238249
super
239250
end
240251

252+
##
253+
# Truncates +text+ at the end of the first word after the character_limit.
254+
241255
def truncate text
242256
length = text.length
243257
characters = @characters
@@ -247,7 +261,7 @@ def truncate text
247261

248262
remaining = @character_limit - characters
249263

250-
text =~ /\A(.{#{remaining},}?)(\s|$)/m
264+
text =~ /\A(.{#{remaining},}?)(\s|$)/m # TODO word-break instead of \s?
251265

252266
$1
253267
end

lib/rdoc/method_attr.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@ def inspect # :nodoc:
343343
]
344344
end
345345

346+
##
347+
# Used by RDoc::Generator::JsonIndex to create a record for the search
348+
# engine.
349+
346350
def search_record
347351
[
348352
@name,
@@ -354,6 +358,7 @@ def search_record
354358
snippet(@comment),
355359
]
356360
end
361+
357362
def to_s # :nodoc:
358363
if @is_alias_for
359364
"#{self.class.name}: #{full_name} -> #{is_alias_for}"

lib/rdoc/parser/rd.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ class RDoc::Parser::RD < RDoc::Parser
88

99
parse_files_matching(/\.rd(?:\.[^.]+)?$/)
1010

11+
##
12+
# Creates an rd-format TopLevel for the given file.
13+
1114
def scan
1215
comment = RDoc::Comment.new @content, @top_level
1316
comment.format = 'rd'

lib/rdoc/rd/block_parser.ry

Lines changed: 63 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ end
228228

229229
---- inner
230230

231+
# :stopdoc:
232+
231233
TMPFILE = ["rdtmp", $$, 0]
232234

233235
MARK_TO_LEVEL = {
@@ -239,10 +241,27 @@ MARK_TO_LEVEL = {
239241
'++' => 6,
240242
}
241243

244+
# :startdoc:
245+
246+
##
247+
# Footnotes for this document
248+
242249
attr_reader :footnotes
250+
251+
##
252+
# Labels for items in this document
253+
243254
attr_reader :labels
255+
256+
##
257+
# Path to find included files in
258+
244259
attr_accessor :include_path
245260

261+
##
262+
# Creates a new RDoc::RD::BlockParser. Use #parse to parse an rd-format
263+
# document.
264+
246265
def initialize
247266
@inline_parser = RDoc::RD::InlineParser.new self
248267
@include_path = []
@@ -252,6 +271,9 @@ def initialize
252271
@labels = {}
253272
end
254273

274+
##
275+
# Parses +src+ and returns an RDoc::Markup::Document.
276+
255277
def parse src
256278
@src = src
257279
@src.push false
@@ -293,7 +315,10 @@ def parse src
293315
document
294316
end
295317

296-
def next_token
318+
##
319+
# Returns the next token from the document
320+
321+
def next_token # :nodoc:
297322
# preprocessing
298323
# if it is not in RD part
299324
# => method
@@ -445,12 +470,10 @@ def next_token
445470
end
446471
end
447472

448-
=begin private
449-
--- RDParser#if_current_indent_equal(indent)
450-
if (({@current_indent == ((|indent|))})) then yield block, otherwise
451-
process indentation.
452-
=end
453-
# always @current_indent = @indent_stack.join("")
473+
##
474+
# Yields to the given block if +indent+ matches the current indent, otherwise
475+
# an indentation token is processed.
476+
454477
def if_current_indent_equal(indent)
455478
indent = indent.sub(/\t/, "\s" * 8)
456479
if @current_indent == indent
@@ -466,6 +489,9 @@ def if_current_indent_equal(indent)
466489
end
467490
private :if_current_indent_equal
468491

492+
##
493+
# Cuts off excess whitespace in +src+
494+
469495
def cut_off(src)
470496
ret = []
471497
whiteline_buf = []
@@ -499,6 +525,9 @@ def set_term_to_element(parent, term)
499525
end
500526
private :set_term_to_element
501527

528+
##
529+
# Raises a ParseError
530+
502531
def on_error(et, ev, _values)
503532
prv, cur, nxt = format_line_num(@i, @i+1, @i+2)
504533

@@ -512,17 +541,26 @@ RD syntax error: line #{@i+1}:
512541
Msg
513542
end
514543

544+
##
545+
# Current line number
546+
515547
def line_index
516548
@i
517549
end
518550

551+
##
552+
# Parses subtree +src+
553+
519554
def parse_subtree src
520555
@subparser ||= RDoc::RD::BlockParser.new
521556

522557
@subparser.parse src
523558
end
524559
private :parse_subtree
525560

561+
##
562+
# Retrieves the content for +file+ from the include_path
563+
526564
def get_included(file)
527565
included = []
528566

@@ -539,23 +577,35 @@ def get_included(file)
539577
end
540578
private :get_included
541579

542-
def format_line_num(*args)
543-
width = args.collect{|i| i.to_s.length }.max
544-
args.collect{|i| sprintf("%#{width}d", i) }
580+
##
581+
# Formats line numbers +line_numbers+ prettily
582+
583+
def format_line_num(*line_numbers)
584+
width = line_numbers.collect{|i| i.to_s.length }.max
585+
line_numbers.collect{|i| sprintf("%#{width}d", i) }
545586
end
546587
private :format_line_num
547588

589+
##
590+
# Retrieves the content of +values+ as a single String
591+
548592
def content values
549593
values.map { |value| value.content }.join
550594
end
551595

596+
##
597+
# Creates a paragraph for +value+
598+
552599
def paragraph value
553600
content = cut_off(value).join(' ').rstrip
554601
contents = @inline_parser.parse content
555602

556603
RDoc::Markup::Paragraph.new(*contents)
557604
end
558605

606+
##
607+
# Adds footnote +content+ to the document
608+
559609
def add_footnote content
560610
index = @footnotes.length + 1
561611

@@ -566,6 +616,9 @@ def add_footnote content
566616
index
567617
end
568618

619+
##
620+
# Adds label +label+ to the document
621+
569622
def add_label label
570623
@labels[label] = true
571624

lib/rdoc/rd/inline_parser.ry

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,9 @@ class InlineParser
355355
end
356356

357357
---- inner
358+
359+
# :stopdoc:
360+
358361
EM_OPEN = '((*'
359362
EM_OPEN_RE = /\A#{Regexp.quote(EM_OPEN)}/
360363
EM_CLOSE = '*))'
@@ -417,6 +420,8 @@ OTHER_RE = Regexp.new(
417420
#{Regexp.quote(BACK_SLASH)}|
418421
#{Regexp.quote(URL)})", other_re_mode)
419422

423+
# :startdoc:
424+
420425
def initialize block_parser
421426
@block_parser = block_parser
422427
end

lib/rdoc/test_case.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ def setup
4040
@pwd = Dir.pwd
4141
end
4242

43+
##
44+
# Creates an RDoc::Comment with +text+ which was defined on +top_level+.
45+
# By default the comment has the 'rdoc' format.
46+
4347
def comment text, top_level = @top_level
4448
RDoc::Comment.new text, top_level
4549
end

0 commit comments

Comments
 (0)