rdoc 2.1.0 → 2.2.0
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/History.txt +82 -1
- data/Manifest.txt +8 -0
- data/README.txt +33 -9
- data/RI.txt +58 -0
- data/Rakefile +2 -0
- data/bin/ri +1 -2
- data/lib/rdoc.rb +154 -36
- data/lib/rdoc/code_objects.rb +38 -2
- data/lib/rdoc/diagram.rb +17 -15
- data/lib/rdoc/generator.rb +21 -15
- data/lib/rdoc/generator/chm/chm.rb +2 -0
- data/lib/rdoc/generator/html.rb +137 -89
- data/lib/rdoc/generator/html/common.rb +24 -0
- data/lib/rdoc/generator/html/frameless.rb +28 -731
- data/lib/rdoc/generator/html/hefss.rb +47 -311
- data/lib/rdoc/generator/html/html.rb +226 -156
- data/lib/rdoc/generator/html/kilmer.rb +31 -298
- data/lib/rdoc/generator/html/kilmerfactory.rb +427 -0
- data/lib/rdoc/generator/html/one_page_html.rb +6 -5
- data/lib/rdoc/generator/texinfo.rb +3 -6
- data/lib/rdoc/generator/xml.rb +4 -7
- data/lib/rdoc/generator/xml/xml.rb +21 -9
- data/lib/rdoc/markup.rb +0 -95
- data/lib/rdoc/markup/inline.rb +1 -1
- data/lib/rdoc/markup/to_html.rb +9 -6
- data/lib/rdoc/markup/to_html_crossref.rb +67 -21
- data/lib/rdoc/markup/to_texinfo.rb +1 -1
- data/lib/rdoc/parser.rb +22 -1
- data/lib/rdoc/parser/c.rb +14 -16
- data/lib/rdoc/parser/ruby.rb +3 -3
- data/lib/rdoc/parser/simple.rb +1 -1
- data/lib/rdoc/rdoc.rb +0 -1
- data/lib/rdoc/ri/cache.rb +5 -6
- data/lib/rdoc/ri/descriptions.rb +3 -0
- data/lib/rdoc/ri/display.rb +157 -37
- data/lib/rdoc/ri/driver.rb +314 -198
- data/lib/rdoc/ri/formatter.rb +1 -1
- data/lib/rdoc/ri/paths.rb +2 -11
- data/lib/rdoc/ri/reader.rb +3 -3
- data/lib/rdoc/ri/util.rb +0 -2
- data/test/binary.dat +0 -0
- data/test/rdoc_markup_to_html_crossref_reference.rb +31 -0
- data/test/test_attribute_manager.rb +73 -0
- data/test/test_rdoc_info_formatting.rb +6 -6
- data/test/test_rdoc_info_sections.rb +2 -2
- data/test/test_rdoc_markup_attribute_manager.rb +14 -14
- data/test/test_rdoc_markup_to_html.rb +15 -3
- data/test/test_rdoc_markup_to_html_crossref.rb +276 -7
- data/test/test_rdoc_parser.rb +13 -0
- data/test/test_rdoc_parser_c.rb +1 -1
- data/test/test_rdoc_parser_ruby.rb +72 -1
- data/test/test_rdoc_ri_default_display.rb +23 -22
- data/test/test_rdoc_ri_driver.rb +1 -1
- data/test/test_rdoc_ri_formatter.rb +1 -1
- metadata +27 -35
- data.tar.gz.sig +0 -1
- metadata.gz.sig +0 -0
@@ -1,7 +1,10 @@
|
|
1
1
|
require 'rdoc/generator/html'
|
2
|
+
require 'rdoc/generator/html/common'
|
2
3
|
|
3
4
|
module RDoc::Generator::HTML::ONE_PAGE_HTML
|
4
5
|
|
6
|
+
include RDoc::Generator::HTML::Common
|
7
|
+
|
5
8
|
CONTENTS_XML = <<-EOF
|
6
9
|
<% if defined? classes and classes["description"] then %>
|
7
10
|
<%= classes["description"] %>
|
@@ -76,16 +79,14 @@ module RDoc::Generator::HTML::ONE_PAGE_HTML
|
|
76
79
|
<% end %>
|
77
80
|
EOF
|
78
81
|
|
79
|
-
ONE_PAGE = %{
|
80
|
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
81
|
-
<html>
|
82
|
+
ONE_PAGE = XHTML_STRICT_PREAMBLE + HTML_ELEMENT + %{
|
82
83
|
<head>
|
83
84
|
<title><%= values["title"] %></title>
|
84
85
|
<meta http-equiv="Content-Type" content="text/html; charset=<%= values["charset"] %>" />
|
85
86
|
</head>
|
86
87
|
<body>
|
87
88
|
<% values["files"].each do |files| %>
|
88
|
-
<h2>File: <%= files["short_name"] %></h2>
|
89
|
+
<h2>File: <a name="<%= files["href"] %>"><%= files["short_name"] %></a></h2>
|
89
90
|
<table>
|
90
91
|
<tr><td>Path:</td><td><%= files["full_path"] %></td></tr>
|
91
92
|
<tr><td>Modified:</td><td><%= files["dtm_modified"] %></td></tr>
|
@@ -97,7 +98,7 @@ module RDoc::Generator::HTML::ONE_PAGE_HTML
|
|
97
98
|
<h2>Classes</h2>
|
98
99
|
<% values["classes"].each do |classes| %>
|
99
100
|
<% if classes["parent"] then %>
|
100
|
-
<h3><%= classes["classmod"] %> <%= classes["
|
101
|
+
<h3><%= classes["classmod"] %> <a name="<%= classes["href"] %>"><%= classes["full_name"] %></a> < <%= href classes["par_url"], classes["parent"] %></h3>
|
101
102
|
<% end %>
|
102
103
|
<% unless classes["parent"] then %>
|
103
104
|
<h3><%= classes["classmod"] %> <%= classes["full_name"] %></h3>
|
@@ -3,13 +3,10 @@ require 'rdoc/generator'
|
|
3
3
|
require 'rdoc/markup/to_texinfo'
|
4
4
|
|
5
5
|
module RDoc
|
6
|
-
RDoc::GENERATORS['texinfo'] = RDoc::Generator.new("rdoc/generator/texinfo",
|
7
|
-
:Texinfo,
|
8
|
-
'texinfo')
|
9
6
|
module Generator
|
10
7
|
# This generates Texinfo files for viewing with GNU Info or Emacs
|
11
8
|
# from RDoc extracted from Ruby source files.
|
12
|
-
class
|
9
|
+
class TEXINFO
|
13
10
|
# What should the .info file be named by default?
|
14
11
|
DEFAULT_INFO_FILENAME = 'rdoc.info'
|
15
12
|
|
@@ -26,8 +23,8 @@ module RDoc
|
|
26
23
|
# Generate the +texinfo+ files
|
27
24
|
def generate(toplevels)
|
28
25
|
@toplevels = toplevels
|
29
|
-
@files, @classes = ::RDoc::Generator::Context.
|
30
|
-
|
26
|
+
@files, @classes = ::RDoc::Generator::Context.build_indices(@toplevels,
|
27
|
+
@options)
|
31
28
|
|
32
29
|
(@files + @classes).each { |x| x.value_hash }
|
33
30
|
|
data/lib/rdoc/generator/xml.rb
CHANGED
@@ -34,15 +34,15 @@ class RDoc::Generator::XML < RDoc::Generator::HTML
|
|
34
34
|
##
|
35
35
|
# Generate:
|
36
36
|
#
|
37
|
-
# * a list of
|
38
|
-
# * a list of
|
37
|
+
# * a list of File objects for each TopLevel object.
|
38
|
+
# * a list of Class objects for each first level
|
39
39
|
# class or module in the TopLevel objects
|
40
40
|
# * a complete list of all hyperlinkable terms (file,
|
41
41
|
# class, module, and method names)
|
42
42
|
|
43
43
|
def build_indices
|
44
44
|
@info.each do |toplevel|
|
45
|
-
@files << RDoc::Generator::
|
45
|
+
@files << RDoc::Generator::File.new(toplevel, @options, RDoc::Generator::FILE_DIR)
|
46
46
|
end
|
47
47
|
|
48
48
|
RDoc::TopLevel.all_classes_and_modules.each do |cls|
|
@@ -51,7 +51,7 @@ class RDoc::Generator::XML < RDoc::Generator::HTML
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def build_class_list(from, html_file, class_dir)
|
54
|
-
@classes << RDoc::Generator::
|
54
|
+
@classes << RDoc::Generator::Class.new(from, html_file, class_dir, @options)
|
55
55
|
from.each_classmodule do |mod|
|
56
56
|
build_class_list(mod, html_file, class_dir)
|
57
57
|
end
|
@@ -68,9 +68,6 @@ class RDoc::Generator::XML < RDoc::Generator::HTML
|
|
68
68
|
'classes' => gen_into(@classes)
|
69
69
|
}
|
70
70
|
|
71
|
-
# this method is defined in the template file
|
72
|
-
write_extra_pages if defined? write_extra_pages
|
73
|
-
|
74
71
|
template = RDoc::TemplatePage.new @template::ONE_PAGE
|
75
72
|
|
76
73
|
if @options.op_name
|
@@ -17,11 +17,23 @@ module RDoc::Generator::XML::XML
|
|
17
17
|
href="<%= requires["aref"] %>"
|
18
18
|
<% end %>
|
19
19
|
/>
|
20
|
-
<% end
|
20
|
+
<% end %><%# files["requires"] %>
|
21
21
|
</required-file-list>
|
22
22
|
<% end %>
|
23
23
|
<% if defined? classes and classes["sections"] then %>
|
24
24
|
<% classes["sections"].each do |sections| %>
|
25
|
+
<% if sections["constants"] then %>
|
26
|
+
<constant-list>
|
27
|
+
<% sections["constants"].each do |constant| %>
|
28
|
+
<constant name="<%= constant["name"] %>">
|
29
|
+
<% if constant["value"] then %>
|
30
|
+
<value><%= constant["value"] %></value>
|
31
|
+
<% end %>
|
32
|
+
<description><%= constant["a_desc"] %></description>
|
33
|
+
</constant>
|
34
|
+
<% end %><%# sections["constants"] %>
|
35
|
+
</constant-list>
|
36
|
+
<% end %>
|
25
37
|
<% if sections["attributes"] then %>
|
26
38
|
<attribute-list>
|
27
39
|
<% sections["attributes"].each do |attributes| %>
|
@@ -31,7 +43,7 @@ module RDoc::Generator::XML::XML
|
|
31
43
|
<% end %>
|
32
44
|
<description><%= attributes["a_desc"] %></description>
|
33
45
|
</attribute>
|
34
|
-
<% end
|
46
|
+
<% end %><%# sections["attributes"] %>
|
35
47
|
</attribute-list>
|
36
48
|
<% end %>
|
37
49
|
<% if sections["method_list"] then %>
|
@@ -52,12 +64,12 @@ module RDoc::Generator::XML::XML
|
|
52
64
|
</source-code-listing>
|
53
65
|
<% end %>
|
54
66
|
</method>
|
55
|
-
<% end
|
67
|
+
<% end %><%# method_list["methods"] %>
|
56
68
|
<% end %>
|
57
|
-
<% end
|
69
|
+
<% end %><%# sections["method_list"] %>
|
58
70
|
</method-list>
|
59
71
|
<% end %>
|
60
|
-
<% end
|
72
|
+
<% end %><%# classes["sections"] %>
|
61
73
|
<% end %>
|
62
74
|
<% if defined? classes and classes["includes"] then %>
|
63
75
|
<included-module-list>
|
@@ -67,7 +79,7 @@ module RDoc::Generator::XML::XML
|
|
67
79
|
href="<%= includes["aref"] %>"
|
68
80
|
<% end %>
|
69
81
|
/>
|
70
|
-
<% end
|
82
|
+
<% end %><%# classes["includes"] %>
|
71
83
|
</included-module-list>
|
72
84
|
<% end %>
|
73
85
|
</contents>
|
@@ -84,7 +96,7 @@ module RDoc::Generator::XML::XML
|
|
84
96
|
</file-info>
|
85
97
|
} + CONTENTS_XML + %{
|
86
98
|
</file>
|
87
|
-
<% end
|
99
|
+
<% end %><%# values["files"] %>
|
88
100
|
</file-list>
|
89
101
|
<class-module-list>
|
90
102
|
<% values["classes"].each do |classes| %>
|
@@ -94,7 +106,7 @@ module RDoc::Generator::XML::XML
|
|
94
106
|
<infiles>
|
95
107
|
<% classes["infiles"].each do |infiles| %>
|
96
108
|
<infile><%= href infiles["full_path_url"], infiles["full_path"] %></infile>
|
97
|
-
<% end
|
109
|
+
<% end %><%# classes["infiles"] %>
|
98
110
|
</infiles>
|
99
111
|
<% end %>
|
100
112
|
<% if classes["parent"] then %>
|
@@ -103,7 +115,7 @@ module RDoc::Generator::XML::XML
|
|
103
115
|
</classmod-info>
|
104
116
|
} + CONTENTS_XML + %{
|
105
117
|
</<%= classes["classmod"] %>>
|
106
|
-
<% end
|
118
|
+
<% end %><%# values["classes"] %>
|
107
119
|
</class-module-list>
|
108
120
|
</rdoc>
|
109
121
|
}
|
data/lib/rdoc/markup.rb
CHANGED
@@ -20,101 +20,6 @@ require 'rdoc'
|
|
20
20
|
# RDoc::Markup could be the basis for formatting RDoc style comment blocks,
|
21
21
|
# Wiki entries, and online FAQs.
|
22
22
|
#
|
23
|
-
# = Basic Formatting
|
24
|
-
#
|
25
|
-
# * RDoc::Markup looks for a document's natural left margin. This is
|
26
|
-
# used as the initial margin for the document.
|
27
|
-
#
|
28
|
-
# * Consecutive lines starting at this margin are considered to be a
|
29
|
-
# paragraph.
|
30
|
-
#
|
31
|
-
# * If a paragraph starts with a "*", "-", or with "<digit>.", then it is
|
32
|
-
# taken to be the start of a list. The margin in increased to be the first
|
33
|
-
# non-space following the list start flag. Subsequent lines should be
|
34
|
-
# indented to this \new margin until the list ends. For example:
|
35
|
-
#
|
36
|
-
# * this is a list with three paragraphs in
|
37
|
-
# the first item. This is the first paragraph.
|
38
|
-
#
|
39
|
-
# And this is the second paragraph.
|
40
|
-
#
|
41
|
-
# 1. This is an indented, numbered list.
|
42
|
-
# 2. This is the second item in that list
|
43
|
-
#
|
44
|
-
# This is the third conventional paragraph in the
|
45
|
-
# first list item.
|
46
|
-
#
|
47
|
-
# * This is the second item in the original list
|
48
|
-
#
|
49
|
-
# * You can also construct labeled lists, sometimes called description
|
50
|
-
# or definition lists. Do this by putting the label in square brackets
|
51
|
-
# and indenting the list body:
|
52
|
-
#
|
53
|
-
# [cat] a small furry mammal
|
54
|
-
# that seems to sleep a lot
|
55
|
-
#
|
56
|
-
# [ant] a little insect that is known
|
57
|
-
# to enjoy picnics
|
58
|
-
#
|
59
|
-
# A minor variation on labeled lists uses two colons to separate the
|
60
|
-
# label from the list body:
|
61
|
-
#
|
62
|
-
# cat:: a small furry mammal
|
63
|
-
# that seems to sleep a lot
|
64
|
-
#
|
65
|
-
# ant:: a little insect that is known
|
66
|
-
# to enjoy picnics
|
67
|
-
#
|
68
|
-
# This latter style guarantees that the list bodies' left margins are
|
69
|
-
# aligned: think of them as a two column table.
|
70
|
-
#
|
71
|
-
# * Any line that starts to the right of the current margin is treated
|
72
|
-
# as verbatim text. This is useful for code listings. The example of a
|
73
|
-
# list above is also verbatim text.
|
74
|
-
#
|
75
|
-
# * A line starting with an equals sign (=) is treated as a
|
76
|
-
# heading. Level one headings have one equals sign, level two headings
|
77
|
-
# have two,and so on.
|
78
|
-
#
|
79
|
-
# * A line starting with three or more hyphens (at the current indent)
|
80
|
-
# generates a horizontal rule. The more hyphens, the thicker the rule
|
81
|
-
# (within reason, and if supported by the output device)
|
82
|
-
#
|
83
|
-
# * You can use markup within text (except verbatim) to change the
|
84
|
-
# appearance of parts of that text. Out of the box, RDoc::Markup
|
85
|
-
# supports word-based and general markup.
|
86
|
-
#
|
87
|
-
# Word-based markup uses flag characters around individual words:
|
88
|
-
#
|
89
|
-
# [\*word*] displays word in a *bold* font
|
90
|
-
# [\_word_] displays word in an _emphasized_ font
|
91
|
-
# [\+word+] displays word in a +code+ font
|
92
|
-
#
|
93
|
-
# General markup affects text between a start delimiter and and end
|
94
|
-
# delimiter. Not surprisingly, these delimiters look like HTML markup.
|
95
|
-
#
|
96
|
-
# [\<b>text...</b>] displays word in a *bold* font
|
97
|
-
# [\<em>text...</em>] displays word in an _emphasized_ font
|
98
|
-
# [\<i>text...</i>] displays word in an _emphasized_ font
|
99
|
-
# [\<tt>text...</tt>] displays word in a +code+ font
|
100
|
-
#
|
101
|
-
# Unlike conventional Wiki markup, general markup can cross line
|
102
|
-
# boundaries. You can turn off the interpretation of markup by
|
103
|
-
# preceding the first character with a backslash, so \\\<b>bold
|
104
|
-
# text</b> and \\\*bold* produce \<b>bold text</b> and \*bold*
|
105
|
-
# respectively.
|
106
|
-
#
|
107
|
-
# * Hyperlinks to the web starting http:, mailto:, ftp:, or www. are
|
108
|
-
# recognized. An HTTP url that references an external image file is
|
109
|
-
# converted into an inline <IMG..>. Hyperlinks starting 'link:' are
|
110
|
-
# assumed to refer to local files whose path is relative to the --op
|
111
|
-
# directory.
|
112
|
-
#
|
113
|
-
# Hyperlinks can also be of the form <tt>label</tt>[url], in which
|
114
|
-
# case the label is used in the displayed text, and <tt>url</tt> is
|
115
|
-
# used as the target. If <tt>label</tt> contains multiple words,
|
116
|
-
# put it in braces: <em>{multi word label}[</em>url<em>]</em>.
|
117
|
-
#
|
118
23
|
# == Synopsis
|
119
24
|
#
|
120
25
|
# This code converts +input_string+ to HTML. The conversion takes place in
|
data/lib/rdoc/markup/inline.rb
CHANGED
data/lib/rdoc/markup/to_html.rb
CHANGED
@@ -57,7 +57,7 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
|
|
57
57
|
|
58
58
|
##
|
59
59
|
# Generate a hyperlink for url, labeled with text. Handle the
|
60
|
-
# special cases for img: and link: described under
|
60
|
+
# special cases for img: and link: described under handle_special_HYPERLINK
|
61
61
|
|
62
62
|
def gen_url(url, text)
|
63
63
|
if url =~ /([A-Za-z]+):(.*)/ then
|
@@ -304,9 +304,12 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
|
|
304
304
|
# some of these patterns are taken from SmartyPants...
|
305
305
|
|
306
306
|
def convert_string_fancy(item)
|
307
|
-
# convert
|
308
|
-
item.gsub(
|
307
|
+
# convert ampersand before doing anything else
|
308
|
+
item.gsub(/&/, '&').
|
309
309
|
|
310
|
+
# convert -- to em-dash, (-- to en-dash)
|
311
|
+
gsub(/---?/, '—'). #gsub(/--/, '–').
|
312
|
+
|
310
313
|
# convert ... to elipsis (and make sure .... becomes .<elipsis>)
|
311
314
|
gsub(/\.\.\.\./, '.…').gsub(/\.\.\./, '…').
|
312
315
|
|
@@ -318,15 +321,15 @@ class RDoc::Markup::ToHtml < RDoc::Markup::Formatter
|
|
318
321
|
gsub(/'/, '‘').
|
319
322
|
|
320
323
|
# convert double closing quote
|
321
|
-
gsub(%r{([^ \t\r\n\[\{\(])\
|
324
|
+
gsub(%r{([^ \t\r\n\[\{\(])\"(?=\W)}, '\1”'). # }
|
322
325
|
|
323
326
|
# convert double opening quote
|
324
|
-
gsub(/
|
327
|
+
gsub(/"/, '“').
|
325
328
|
|
326
329
|
# convert copyright
|
327
330
|
gsub(/\(c\)/, '©').
|
328
331
|
|
329
|
-
# convert
|
332
|
+
# convert registered trademark
|
330
333
|
gsub(/\(r\)/, '®')
|
331
334
|
end
|
332
335
|
|
@@ -9,6 +9,68 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
9
9
|
|
10
10
|
attr_accessor :context
|
11
11
|
|
12
|
+
# Regular expressions to match class and method references.
|
13
|
+
#
|
14
|
+
# 1.) There can be a '\' in front of text to suppress
|
15
|
+
# any cross-references (note, however, that the single '\'
|
16
|
+
# is written as '\\\\' in order to escape it twice, once
|
17
|
+
# in the Ruby String literal and once in the regexp).
|
18
|
+
# 2.) There can be a '::' in front of class names to reference
|
19
|
+
# from the top-level namespace.
|
20
|
+
# 3.) The method can be followed by parenthesis,
|
21
|
+
# which may or may not have things inside (this
|
22
|
+
# apparently is allowed for Fortran 95, but I also think that this
|
23
|
+
# is a good idea for Ruby, as it is very reasonable to want to
|
24
|
+
# reference a call with arguments).
|
25
|
+
#
|
26
|
+
# NOTE: In order to support Fortran 95 properly, the [A-Z] below
|
27
|
+
# should be changed to [A-Za-z]. This slows down rdoc significantly,
|
28
|
+
# however, and the Fortran 95 support is broken in any case due to
|
29
|
+
# the return in handle_special_CROSSREF if the token consists
|
30
|
+
# entirely of lowercase letters.
|
31
|
+
#
|
32
|
+
# The markup/cross-referencing engine needs a rewrite for
|
33
|
+
# Fortran 95 to be supported properly.
|
34
|
+
CLASS_REGEXP_STR = '\\\\?((?:\:{2})?[A-Z]\w*(?:\:\:\w+)*)'
|
35
|
+
METHOD_REGEXP_STR = '(\w+[!?=]?)(?:\([\.\w+\*\/\+\-\=\<\>]*\))?'
|
36
|
+
|
37
|
+
# Regular expressions matching text that should potentially have
|
38
|
+
# cross-reference links generated are passed to add_special.
|
39
|
+
# Note that these expressions are meant to pick up text for which
|
40
|
+
# cross-references have been suppressed, since the suppression
|
41
|
+
# characters are removed by the code that is triggered.
|
42
|
+
CROSSREF_REGEXP = /(
|
43
|
+
# A::B::C.meth
|
44
|
+
#{CLASS_REGEXP_STR}[\.\#]#{METHOD_REGEXP_STR}
|
45
|
+
|
46
|
+
# Stand-alone method (proceeded by a #)
|
47
|
+
| \\?\##{METHOD_REGEXP_STR}
|
48
|
+
|
49
|
+
# A::B::C
|
50
|
+
# The stuff after CLASS_REGEXP_STR is a
|
51
|
+
# nasty hack. CLASS_REGEXP_STR unfortunately matches
|
52
|
+
# words like dog and cat (these are legal "class"
|
53
|
+
# names in Fortran 95). When a word is flagged as a
|
54
|
+
# potential cross-reference, limitations in the markup
|
55
|
+
# engine suppress other processing, such as typesetting.
|
56
|
+
# This is particularly noticeable for contractions.
|
57
|
+
# In order that words like "can't" not
|
58
|
+
# be flagged as potential cross-references, only
|
59
|
+
# flag potential class cross-references if the character
|
60
|
+
# after the cross-referece is a space or sentence
|
61
|
+
# punctuation.
|
62
|
+
| #{CLASS_REGEXP_STR}(?=[\s\)\.\?\!\,\;]|\z)
|
63
|
+
|
64
|
+
# Things that look like filenames
|
65
|
+
# The key thing is that there must be at least
|
66
|
+
# one special character (period, slash, or
|
67
|
+
# underscore).
|
68
|
+
| \w+[_\/\.][\w\/\.]+
|
69
|
+
|
70
|
+
# Things that have markup suppressed
|
71
|
+
| \\[^\s]
|
72
|
+
)/x
|
73
|
+
|
12
74
|
##
|
13
75
|
# We need to record the html path of our caller so we can generate
|
14
76
|
# correct relative paths for any hyperlinks that we find
|
@@ -17,18 +79,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
17
79
|
raise ArgumentError, 'from_path cannot be nil' if from_path.nil?
|
18
80
|
super()
|
19
81
|
|
20
|
-
|
21
|
-
@markup.add_special(/(
|
22
|
-
# A::B.meth(**) (for operator in Fortran95)
|
23
|
-
\w+(::\w+)*[.\#]\w+(\([\.\w+\*\/\+\-\=\<\>]+\))?
|
24
|
-
# meth(**) (for operator in Fortran95)
|
25
|
-
| \#\w+(\([.\w\*\/\+\-\=\<\>]+\))?
|
26
|
-
| \b([A-Z]\w*(::\w+)*[.\#]\w+) # A::B.meth
|
27
|
-
| \b([A-Z]\w+(::\w+)*) # A::B
|
28
|
-
| \#\w+[!?=]? # #meth_name
|
29
|
-
| \\?\b\w+([_\/\.]+\w+)*[!?=]? # meth_name
|
30
|
-
)/x,
|
31
|
-
:CROSSREF)
|
82
|
+
@markup.add_special(CROSSREF_REGEXP, :CROSSREF)
|
32
83
|
|
33
84
|
@from_path = from_path
|
34
85
|
@context = context
|
@@ -48,6 +99,9 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
48
99
|
def handle_special_CROSSREF(special)
|
49
100
|
name = special.text
|
50
101
|
|
102
|
+
# This ensures that words entirely consisting of lowercase letters will
|
103
|
+
# not have cross-references generated (to suppress lots of
|
104
|
+
# erroneous cross-references to "new" in text, for instance)
|
51
105
|
return name if name =~ /\A[a-z]*\z/
|
52
106
|
|
53
107
|
return @seen[name] if @seen.include? name
|
@@ -70,14 +124,7 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
70
124
|
# (in which case it would match the last pattern, which just checks
|
71
125
|
# whether the string as a whole is a known symbol).
|
72
126
|
|
73
|
-
if
|
74
|
-
container = $1
|
75
|
-
method = $2
|
76
|
-
ref = @context.find_symbol container, method
|
77
|
-
end
|
78
|
-
|
79
|
-
if !ref and
|
80
|
-
/([A-Za-z][\w:]*)[.\#](\w+(\([\.\w+\*\/\+\-\=\<\>]+\))?)/ =~ lookup then
|
127
|
+
if /#{CLASS_REGEXP_STR}[\.\#]#{METHOD_REGEXP_STR}/ =~ lookup then
|
81
128
|
container = $1
|
82
129
|
method = $2
|
83
130
|
ref = @context.find_symbol container, method
|
@@ -99,4 +146,3 @@ class RDoc::Markup::ToHtmlCrossref < RDoc::Markup::ToHtml
|
|
99
146
|
end
|
100
147
|
|
101
148
|
end
|
102
|
-
|