rdoc 3.9.5 → 3.10.pre.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rdoc might be problematic. Click here for more details.
- data.tar.gz.sig +0 -0
- data/.autotest +6 -3
- data/History.txt +63 -13
- data/LICENSE.rdoc +57 -0
- data/Manifest.txt +60 -6
- data/Rakefile +24 -12
- data/TODO.rdoc +30 -0
- data/bin/rdoc +0 -2
- data/lib/rdoc.rb +55 -2
- data/lib/rdoc/alias.rb +0 -2
- data/lib/rdoc/anon_class.rb +0 -2
- data/lib/rdoc/any_method.rb +0 -3
- data/lib/rdoc/attr.rb +0 -2
- data/lib/rdoc/class_module.rb +40 -7
- data/lib/rdoc/code_object.rb +1 -3
- data/lib/rdoc/code_objects.rb +3 -21
- data/lib/rdoc/comment.rb +225 -0
- data/lib/rdoc/constant.rb +0 -2
- data/lib/rdoc/context.rb +37 -120
- data/lib/rdoc/context/section.rb +114 -0
- data/lib/rdoc/cross_reference.rb +16 -7
- data/lib/rdoc/encoding.rb +0 -2
- data/lib/rdoc/gauntlet.rb +1 -1
- data/lib/rdoc/generator.rb +7 -2
- data/lib/rdoc/generator/darkfish.rb +126 -20
- data/lib/rdoc/generator/json_index.rb +240 -0
- data/lib/rdoc/generator/markup.rb +17 -54
- data/lib/rdoc/generator/ri.rb +0 -3
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +16 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +8 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +16 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +7 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +10 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +10 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +10 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +161 -0
- data/lib/rdoc/generator/template/darkfish/fileinfo.rhtml +32 -0
- data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
- data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +16 -61
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +99 -64
- data/lib/rdoc/generator/template/darkfish/js/jquery.js +15 -29
- data/lib/rdoc/generator/template/darkfish/js/search.js +94 -0
- data/lib/rdoc/generator/template/darkfish/page.rhtml +16 -0
- data/lib/rdoc/generator/template/darkfish/rdoc.css +126 -286
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +50 -0
- data/lib/rdoc/generator/template/json_index/js/navigation.js +142 -0
- data/lib/rdoc/generator/template/json_index/js/searcher.js +228 -0
- data/lib/rdoc/ghost_method.rb +0 -2
- data/lib/rdoc/include.rb +0 -2
- data/lib/rdoc/markup.rb +204 -43
- data/lib/rdoc/markup/attr_changer.rb +25 -0
- data/lib/rdoc/markup/attr_span.rb +29 -0
- data/lib/rdoc/markup/attribute.rb +51 -0
- data/lib/rdoc/markup/document.rb +22 -1
- data/lib/rdoc/markup/formatter.rb +4 -11
- data/lib/rdoc/markup/formatter_test_case.rb +1 -2
- data/lib/rdoc/markup/heading.rb +44 -0
- data/lib/rdoc/markup/include.rb +42 -0
- data/lib/rdoc/markup/inline.rb +1 -144
- data/lib/rdoc/markup/list.rb +2 -1
- data/lib/rdoc/markup/parser.rb +6 -16
- data/lib/rdoc/markup/pre_process.rb +64 -10
- data/lib/rdoc/markup/raw.rb +1 -1
- data/lib/rdoc/markup/special.rb +40 -0
- data/lib/rdoc/markup/text_formatter_test_case.rb +0 -2
- data/lib/rdoc/markup/to_ansi.rb +0 -2
- data/lib/rdoc/markup/to_bs.rb +0 -2
- data/lib/rdoc/markup/to_html.rb +102 -34
- data/lib/rdoc/markup/to_html_crossref.rb +36 -5
- data/lib/rdoc/markup/to_html_snippet.rb +270 -0
- data/lib/rdoc/markup/to_label.rb +55 -0
- data/lib/rdoc/markup/to_rdoc.rb +0 -3
- data/lib/rdoc/markup/to_table_of_contents.rb +62 -0
- data/lib/rdoc/markup/to_test.rb +0 -3
- data/lib/rdoc/markup/to_tt_only.rb +0 -3
- data/lib/rdoc/markup/verbatim.rb +18 -0
- data/lib/rdoc/meta_method.rb +0 -2
- data/lib/rdoc/method_attr.rb +17 -1
- data/lib/rdoc/normal_class.rb +0 -2
- data/lib/rdoc/normal_module.rb +0 -2
- data/lib/rdoc/options.rb +18 -3
- data/lib/rdoc/parser.rb +74 -42
- data/lib/rdoc/parser/c.rb +79 -118
- data/lib/rdoc/parser/rd.rb +22 -0
- data/lib/rdoc/parser/ruby.rb +86 -54
- data/lib/rdoc/parser/simple.rb +21 -9
- data/lib/rdoc/parser/text.rb +11 -0
- data/lib/rdoc/rd.rb +95 -0
- data/lib/rdoc/rd/block_parser.ry +638 -0
- data/lib/rdoc/rd/inline.rb +71 -0
- data/lib/rdoc/rd/inline_parser.ry +575 -0
- data/lib/rdoc/rdoc.rb +8 -23
- data/lib/rdoc/require.rb +0 -2
- data/lib/rdoc/ri.rb +4 -2
- data/lib/rdoc/ri/driver.rb +2 -6
- data/lib/rdoc/ri/store.rb +0 -1
- data/lib/rdoc/ruby_lex.rb +43 -20
- data/lib/rdoc/ruby_token.rb +44 -2
- data/lib/rdoc/single_class.rb +0 -2
- data/lib/rdoc/stats.rb +0 -5
- data/lib/rdoc/task.rb +2 -6
- data/lib/rdoc/test_case.rb +59 -0
- data/lib/rdoc/text.rb +42 -30
- data/lib/rdoc/token_stream.rb +45 -0
- data/lib/rdoc/tom_doc.rb +232 -0
- data/lib/rdoc/top_level.rb +36 -4
- data/test/test_attribute_manager.rb +26 -29
- data/test/test_rdoc_any_method.rb +2 -26
- data/test/test_rdoc_attr.rb +4 -4
- data/test/test_rdoc_class_module.rb +95 -12
- data/test/test_rdoc_code_object.rb +10 -3
- data/test/test_rdoc_comment.rb +504 -0
- data/test/test_rdoc_context.rb +60 -11
- data/test/test_rdoc_context_section.rb +16 -17
- data/test/test_rdoc_cross_reference.rb +17 -2
- data/test/test_rdoc_encoding.rb +4 -7
- data/test/test_rdoc_generator_darkfish.rb +12 -11
- data/test/test_rdoc_generator_json_index.rb +255 -0
- data/test/test_rdoc_generator_markup.rb +56 -0
- data/test/test_rdoc_generator_ri.rb +8 -11
- data/test/test_rdoc_markup.rb +9 -5
- data/test/test_rdoc_markup_attribute_manager.rb +5 -8
- data/test/test_rdoc_markup_document.rb +34 -6
- data/test/test_rdoc_markup_formatter.rb +11 -13
- data/test/test_rdoc_markup_heading.rb +20 -0
- data/test/test_rdoc_markup_include.rb +19 -0
- data/test/test_rdoc_markup_indented_paragraph.rb +4 -5
- data/test/test_rdoc_markup_paragraph.rb +2 -5
- data/test/test_rdoc_markup_parser.rb +87 -7
- data/test/test_rdoc_markup_pre_process.rb +60 -9
- data/test/test_rdoc_markup_raw.rb +4 -6
- data/test/test_rdoc_markup_to_ansi.rb +1 -4
- data/test/test_rdoc_markup_to_bs.rb +1 -4
- data/test/test_rdoc_markup_to_html.rb +170 -31
- data/test/test_rdoc_markup_to_html_crossref.rb +89 -11
- data/test/test_rdoc_markup_to_html_snippet.rb +668 -0
- data/test/test_rdoc_markup_to_label.rb +50 -0
- data/test/test_rdoc_markup_to_rdoc.rb +1 -4
- data/test/test_rdoc_markup_to_table_of_contents.rb +90 -0
- data/test/test_rdoc_markup_to_tt_only.rb +1 -4
- data/test/test_rdoc_markup_verbatim.rb +16 -0
- data/test/test_rdoc_method_attr.rb +16 -1
- data/test/test_rdoc_options.rb +17 -7
- data/test/test_rdoc_parser.rb +75 -6
- data/test/test_rdoc_parser_c.rb +56 -104
- data/test/test_rdoc_parser_rd.rb +52 -0
- data/test/test_rdoc_parser_ruby.rb +264 -323
- data/test/test_rdoc_parser_simple.rb +33 -17
- data/test/test_rdoc_rd.rb +30 -0
- data/test/test_rdoc_rd_block_parser.rb +527 -0
- data/test/test_rdoc_rd_inline.rb +63 -0
- data/test/test_rdoc_rd_inline_parser.rb +173 -0
- data/test/test_rdoc_rdoc.rb +7 -9
- data/test/test_rdoc_ri_driver.rb +10 -15
- data/test/test_rdoc_ri_paths.rb +6 -6
- data/test/test_rdoc_ri_store.rb +6 -13
- data/test/test_rdoc_ruby_lex.rb +53 -5
- data/test/test_rdoc_rubygems_hook.rb +2 -1
- data/test/test_rdoc_stats.rb +83 -103
- data/test/test_rdoc_task.rb +5 -4
- data/test/test_rdoc_text.rb +156 -11
- data/test/test_rdoc_token_stream.rb +42 -0
- data/test/test_rdoc_tom_doc.rb +458 -0
- data/test/test_rdoc_top_level.rb +49 -2
- data/test/xref_test_case.rb +4 -8
- metadata +217 -111
- metadata.gz.sig +0 -0
- checksums.yaml +0 -7
- checksums.yaml.gz.sig +0 -0
- data/CVE-2013-0256.rdoc +0 -49
- data/LICENSE.txt +0 -57
- data/lib/rdoc/generator/template/darkfish/classpage.rhtml +0 -321
- data/lib/rdoc/generator/template/darkfish/filepage.rhtml +0 -124
- data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +0 -114
- data/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +0 -10
@@ -0,0 +1,25 @@
|
|
1
|
+
class RDoc::Markup
|
2
|
+
|
3
|
+
AttrChanger = Struct.new :turn_on, :turn_off # :nodoc:
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
##
|
8
|
+
# An AttrChanger records a change in attributes. It contains a bitmap of the
|
9
|
+
# attributes to turn on, and a bitmap of those to turn off.
|
10
|
+
|
11
|
+
class RDoc::Markup::AttrChanger
|
12
|
+
|
13
|
+
def to_s # :nodoc:
|
14
|
+
"Attr: +#{RDoc::Markup::Attribute.as_string turn_on}/-#{RDoc::Markup::Attribute.as_string turn_off}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def inspect # :nodoc:
|
18
|
+
"+%s/-%s" % [
|
19
|
+
RDoc::Markup::Attribute.as_string(turn_on),
|
20
|
+
RDoc::Markup::Attribute.as_string(turn_off),
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
##
|
2
|
+
# An array of attributes which parallels the characters in a string.
|
3
|
+
|
4
|
+
class RDoc::Markup::AttrSpan
|
5
|
+
|
6
|
+
##
|
7
|
+
# Creates a new AttrSpan for +length+ characters
|
8
|
+
|
9
|
+
def initialize(length)
|
10
|
+
@attrs = Array.new(length, 0)
|
11
|
+
end
|
12
|
+
|
13
|
+
##
|
14
|
+
# Toggles +bits+ from +start+ to +length+
|
15
|
+
def set_attrs(start, length, bits)
|
16
|
+
for i in start ... (start+length)
|
17
|
+
@attrs[i] |= bits
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
##
|
22
|
+
# Accesses flags for character +n+
|
23
|
+
|
24
|
+
def [](n)
|
25
|
+
@attrs[n]
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
##
|
2
|
+
# We manage a set of attributes. Each attribute has a symbol name and a bit
|
3
|
+
# value.
|
4
|
+
|
5
|
+
class RDoc::Markup::Attribute
|
6
|
+
|
7
|
+
##
|
8
|
+
# Special attribute type. See RDoc::Markup#add_special
|
9
|
+
|
10
|
+
SPECIAL = 1
|
11
|
+
|
12
|
+
@@name_to_bitmap = { :_SPECIAL_ => SPECIAL }
|
13
|
+
@@next_bitmap = 2
|
14
|
+
|
15
|
+
##
|
16
|
+
# Returns a unique bit for +name+
|
17
|
+
|
18
|
+
def self.bitmap_for(name)
|
19
|
+
bitmap = @@name_to_bitmap[name]
|
20
|
+
unless bitmap then
|
21
|
+
bitmap = @@next_bitmap
|
22
|
+
@@next_bitmap <<= 1
|
23
|
+
@@name_to_bitmap[name] = bitmap
|
24
|
+
end
|
25
|
+
bitmap
|
26
|
+
end
|
27
|
+
|
28
|
+
##
|
29
|
+
# Returns a string representation of +bitmap+
|
30
|
+
|
31
|
+
def self.as_string(bitmap)
|
32
|
+
return "none" if bitmap.zero?
|
33
|
+
res = []
|
34
|
+
@@name_to_bitmap.each do |name, bit|
|
35
|
+
res << name if (bitmap & bit) != 0
|
36
|
+
end
|
37
|
+
res.join(",")
|
38
|
+
end
|
39
|
+
|
40
|
+
##
|
41
|
+
# yields each attribute name in +bitmap+
|
42
|
+
|
43
|
+
def self.each_name_of(bitmap)
|
44
|
+
@@name_to_bitmap.each do |name, bit|
|
45
|
+
next if bit == SPECIAL
|
46
|
+
yield name.to_s if (bitmap & bit) != 0
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
data/lib/rdoc/markup/document.rb
CHANGED
@@ -7,7 +7,7 @@ class RDoc::Markup::Document
|
|
7
7
|
# The file this document was created from. See also
|
8
8
|
# RDoc::ClassModule#add_comment
|
9
9
|
|
10
|
-
|
10
|
+
attr_reader :file
|
11
11
|
|
12
12
|
##
|
13
13
|
# The parts of the Document
|
@@ -74,6 +74,18 @@ class RDoc::Markup::Document
|
|
74
74
|
@parts.empty? or (@parts.length == 1 and merged? and @parts.first.empty?)
|
75
75
|
end
|
76
76
|
|
77
|
+
##
|
78
|
+
# The file this Document was created from.
|
79
|
+
|
80
|
+
def file= location
|
81
|
+
@file = case location
|
82
|
+
when RDoc::TopLevel then
|
83
|
+
location.absolute_name
|
84
|
+
else
|
85
|
+
location
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
77
89
|
##
|
78
90
|
# When this is a collection of documents (#file is not set and this document
|
79
91
|
# contains only other documents as its direct children) #merge replaces
|
@@ -123,5 +135,14 @@ class RDoc::Markup::Document
|
|
123
135
|
self.parts.push(*parts)
|
124
136
|
end
|
125
137
|
|
138
|
+
##
|
139
|
+
# Returns an Array of headings in the document.
|
140
|
+
#
|
141
|
+
# Require 'rdoc/markup/formatter' before calling this method.
|
142
|
+
|
143
|
+
def table_of_contents
|
144
|
+
accept RDoc::Markup::ToTableOfContents.to_toc
|
145
|
+
end
|
146
|
+
|
126
147
|
end
|
127
148
|
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require 'rdoc/markup'
|
2
|
-
|
3
1
|
##
|
4
2
|
# Base class for RDoc markup formatters
|
5
3
|
#
|
6
|
-
# Formatters
|
4
|
+
# Formatters are a visitor that converts an RDoc::Markup tree (from a comment)
|
5
|
+
# into some kind of output. RDoc ships with formatters for converting back to
|
6
|
+
# rdoc, ANSI text, HTML, a Table of Contents and other formats.
|
7
7
|
#
|
8
8
|
# If you'd like to write your own Formatter use
|
9
9
|
# RDoc::Markup::FormatterTestCase. If you're writing a text-output formatter
|
@@ -58,7 +58,7 @@ class RDoc::Markup::Formatter
|
|
58
58
|
##
|
59
59
|
# Marks up +content+
|
60
60
|
|
61
|
-
def convert
|
61
|
+
def convert content
|
62
62
|
@markup.convert content, self
|
63
63
|
end
|
64
64
|
|
@@ -160,10 +160,3 @@ class RDoc::Markup::Formatter
|
|
160
160
|
|
161
161
|
end
|
162
162
|
|
163
|
-
class RDoc::Markup
|
164
|
-
autoload :ToAnsi, 'rdoc/markup/to_ansi'
|
165
|
-
autoload :ToBs, 'rdoc/markup/to_bs'
|
166
|
-
autoload :ToHtml, 'rdoc/markup/to_html'
|
167
|
-
autoload :ToHtmlCrossref, 'rdoc/markup/to_html_crossref'
|
168
|
-
autoload :ToRdoc, 'rdoc/markup/to_rdoc'
|
169
|
-
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'minitest/unit'
|
2
|
-
require 'rdoc/markup/formatter'
|
3
2
|
|
4
3
|
##
|
5
4
|
# Test case for creating new RDoc::Markup formatters. See
|
@@ -54,8 +53,8 @@ class RDoc::Markup::FormatterTestCase < MiniTest::Unit::TestCase
|
|
54
53
|
def setup
|
55
54
|
super
|
56
55
|
|
57
|
-
@m = RDoc::Markup.new
|
58
56
|
@RM = RDoc::Markup
|
57
|
+
@m = @RM.new
|
59
58
|
|
60
59
|
@bullet_list = @RM::List.new(:BULLET,
|
61
60
|
@RM::ListItem.new(nil, @RM::Paragraph.new('l1')),
|
data/lib/rdoc/markup/heading.rb
CHANGED
@@ -3,6 +3,35 @@
|
|
3
3
|
|
4
4
|
class RDoc::Markup::Heading < Struct.new :level, :text
|
5
5
|
|
6
|
+
@to_html = nil
|
7
|
+
@to_label = nil
|
8
|
+
|
9
|
+
##
|
10
|
+
# A singleton RDoc::Markup::ToLabel formatter for headings.
|
11
|
+
|
12
|
+
def self.to_label
|
13
|
+
@to_label ||= RDoc::Markup::ToLabel.new
|
14
|
+
end
|
15
|
+
|
16
|
+
##
|
17
|
+
# A singleton plain HTML formatter for headings. Used for creating labels
|
18
|
+
# for the Table of Contents
|
19
|
+
|
20
|
+
def self.to_html
|
21
|
+
return @to_html if @to_html
|
22
|
+
|
23
|
+
markup = RDoc::Markup.new
|
24
|
+
markup.add_special RDoc::CrossReference::CROSSREF_REGEXP, :CROSSREF
|
25
|
+
|
26
|
+
@to_html = RDoc::Markup::ToHtml.new
|
27
|
+
|
28
|
+
def @to_html.handle_special_CROSSREF special
|
29
|
+
special.text.sub(/^\\/, '')
|
30
|
+
end
|
31
|
+
|
32
|
+
@to_html
|
33
|
+
end
|
34
|
+
|
6
35
|
##
|
7
36
|
# Calls #accept_heading on +visitor+
|
8
37
|
|
@@ -10,6 +39,21 @@ class RDoc::Markup::Heading < Struct.new :level, :text
|
|
10
39
|
visitor.accept_heading self
|
11
40
|
end
|
12
41
|
|
42
|
+
##
|
43
|
+
# An HTML-safe label for this header.
|
44
|
+
|
45
|
+
def label
|
46
|
+
"label-#{self.class.to_label.convert text.dup}"
|
47
|
+
end
|
48
|
+
|
49
|
+
##
|
50
|
+
# HTML markup of the text of this label without the surrounding header
|
51
|
+
# element.
|
52
|
+
|
53
|
+
def plain_html
|
54
|
+
self.class.to_html.to_html(text.dup)
|
55
|
+
end
|
56
|
+
|
13
57
|
def pretty_print q # :nodoc:
|
14
58
|
q.group 2, "[head: #{level} ", ']' do
|
15
59
|
q.pp text
|
@@ -0,0 +1,42 @@
|
|
1
|
+
##
|
2
|
+
# A file included at generation time. Objects of this class are created by
|
3
|
+
# RDoc::RD for an extension-less include.
|
4
|
+
#
|
5
|
+
# This implementation in incomplete.
|
6
|
+
|
7
|
+
class RDoc::Markup::Include
|
8
|
+
|
9
|
+
##
|
10
|
+
# The filename to be included, without extension
|
11
|
+
|
12
|
+
attr_reader :file
|
13
|
+
|
14
|
+
##
|
15
|
+
# Directories to search for #file
|
16
|
+
|
17
|
+
attr_reader :include_path
|
18
|
+
|
19
|
+
##
|
20
|
+
# Creates a new include that will import +file+ from +include_path+
|
21
|
+
|
22
|
+
def initialize file, include_path
|
23
|
+
@file = file
|
24
|
+
@include_path = include_path
|
25
|
+
end
|
26
|
+
|
27
|
+
def == other # :nodoc:
|
28
|
+
self.class === other and
|
29
|
+
@file == other.file and @include_path == other.include_path
|
30
|
+
end
|
31
|
+
|
32
|
+
def pretty_print q # :nodoc:
|
33
|
+
q.group 2, '[incl ', ']' do
|
34
|
+
q.text file
|
35
|
+
q.breakable
|
36
|
+
q.text 'from '
|
37
|
+
q.pp include_path
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
data/lib/rdoc/markup/inline.rb
CHANGED
@@ -1,144 +1 @@
|
|
1
|
-
|
2
|
-
class RDoc::Markup
|
3
|
-
|
4
|
-
##
|
5
|
-
# We manage a set of attributes. Each attribute has a symbol name and a bit
|
6
|
-
# value.
|
7
|
-
|
8
|
-
class Attribute
|
9
|
-
|
10
|
-
##
|
11
|
-
# Special attribute type. See RDoc::Markup#add_special
|
12
|
-
|
13
|
-
SPECIAL = 1
|
14
|
-
|
15
|
-
@@name_to_bitmap = { :_SPECIAL_ => SPECIAL }
|
16
|
-
@@next_bitmap = 2
|
17
|
-
|
18
|
-
##
|
19
|
-
# Returns a unique bit for +name+
|
20
|
-
|
21
|
-
def self.bitmap_for(name)
|
22
|
-
bitmap = @@name_to_bitmap[name]
|
23
|
-
unless bitmap then
|
24
|
-
bitmap = @@next_bitmap
|
25
|
-
@@next_bitmap <<= 1
|
26
|
-
@@name_to_bitmap[name] = bitmap
|
27
|
-
end
|
28
|
-
bitmap
|
29
|
-
end
|
30
|
-
|
31
|
-
##
|
32
|
-
# Returns a string representation of +bitmap+
|
33
|
-
|
34
|
-
def self.as_string(bitmap)
|
35
|
-
return "none" if bitmap.zero?
|
36
|
-
res = []
|
37
|
-
@@name_to_bitmap.each do |name, bit|
|
38
|
-
res << name if (bitmap & bit) != 0
|
39
|
-
end
|
40
|
-
res.join(",")
|
41
|
-
end
|
42
|
-
|
43
|
-
##
|
44
|
-
# yields each attribute name in +bitmap+
|
45
|
-
|
46
|
-
def self.each_name_of(bitmap)
|
47
|
-
@@name_to_bitmap.each do |name, bit|
|
48
|
-
next if bit == SPECIAL
|
49
|
-
yield name.to_s if (bitmap & bit) != 0
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
|
55
|
-
AttrChanger = Struct.new :turn_on, :turn_off # :nodoc:
|
56
|
-
|
57
|
-
##
|
58
|
-
# An AttrChanger records a change in attributes. It contains a bitmap of the
|
59
|
-
# attributes to turn on, and a bitmap of those to turn off.
|
60
|
-
|
61
|
-
class AttrChanger
|
62
|
-
def to_s # :nodoc:
|
63
|
-
"Attr: +#{Attribute.as_string turn_on}/-#{Attribute.as_string turn_off}"
|
64
|
-
end
|
65
|
-
|
66
|
-
def inspect # :nodoc:
|
67
|
-
"+%s/-%s" % [
|
68
|
-
Attribute.as_string(turn_on),
|
69
|
-
Attribute.as_string(turn_off),
|
70
|
-
]
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
##
|
75
|
-
# An array of attributes which parallels the characters in a string.
|
76
|
-
|
77
|
-
class AttrSpan
|
78
|
-
|
79
|
-
##
|
80
|
-
# Creates a new AttrSpan for +length+ characters
|
81
|
-
|
82
|
-
def initialize(length)
|
83
|
-
@attrs = Array.new(length, 0)
|
84
|
-
end
|
85
|
-
|
86
|
-
##
|
87
|
-
# Toggles +bits+ from +start+ to +length+
|
88
|
-
def set_attrs(start, length, bits)
|
89
|
-
for i in start ... (start+length)
|
90
|
-
@attrs[i] |= bits
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
##
|
95
|
-
# Accesses flags for character +n+
|
96
|
-
|
97
|
-
def [](n)
|
98
|
-
@attrs[n]
|
99
|
-
end
|
100
|
-
|
101
|
-
end
|
102
|
-
|
103
|
-
##
|
104
|
-
# Hold details of a special sequence
|
105
|
-
|
106
|
-
class Special
|
107
|
-
|
108
|
-
##
|
109
|
-
# Special type
|
110
|
-
|
111
|
-
attr_reader :type
|
112
|
-
|
113
|
-
##
|
114
|
-
# Special text
|
115
|
-
|
116
|
-
attr_accessor :text
|
117
|
-
|
118
|
-
##
|
119
|
-
# Creates a new special sequence of +type+ with +text+
|
120
|
-
|
121
|
-
def initialize(type, text)
|
122
|
-
@type, @text = type, text
|
123
|
-
end
|
124
|
-
|
125
|
-
##
|
126
|
-
# Specials are equal when the have the same text and type
|
127
|
-
|
128
|
-
def ==(o)
|
129
|
-
self.text == o.text && self.type == o.type
|
130
|
-
end
|
131
|
-
|
132
|
-
def inspect # :nodoc:
|
133
|
-
"#<RDoc::Markup::Special:0x%x @type=%p, name=%p @text=%p>" % [
|
134
|
-
object_id, @type, RDoc::Markup::Attribute.as_string(type), text.dump]
|
135
|
-
end
|
136
|
-
|
137
|
-
def to_s # :nodoc:
|
138
|
-
"Special: type=#{type}, name=#{RDoc::Markup::Attribute.as_string type}, text=#{text.dump}"
|
139
|
-
end
|
140
|
-
|
141
|
-
end
|
142
|
-
|
143
|
-
end
|
144
|
-
|
1
|
+
warn "requiring rdoc/markup/inline is deprecated and will be removed in RDoc 4." if $-w
|
data/lib/rdoc/markup/list.rb
CHANGED
@@ -14,7 +14,8 @@ class RDoc::Markup::List
|
|
14
14
|
attr_reader :items
|
15
15
|
|
16
16
|
##
|
17
|
-
# Creates a new list of +type+ with +items
|
17
|
+
# Creates a new list of +type+ with +items+. Valid list types are:
|
18
|
+
# +:BULLET+, +:LABEL+, +:LALPHA+, +:NOTE+, +:NUMBER+, +:UALPHA+
|
18
19
|
|
19
20
|
def initialize type = nil, *items
|
20
21
|
@type = type
|