Skip to content

Commit 9a77350

Browse files
committed
Don't auto-link lowercase single words w/o #
1 parent 06a3f7b commit 9a77350

File tree

4 files changed

+53
-28
lines changed

4 files changed

+53
-28
lines changed

History.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
* Fixed "unitialized constant RDoc::Markup::ToHtml::HTML"
1616
* Fixed generation of relative links
1717
* Fixed various diagram generation issues
18+
* Fixed templates broken by switch to erb
19+
* Fixed issue with <!-- --> style comments
20+
* Lowercase words are no longer rdoc'd as methods without leading #, as
21+
described in the documentation
1822

1923
=== 2.0.0 / 2008-04-10
2024

lib/rdoc/code_objects.rb

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -408,26 +408,30 @@ def <=>(other)
408408
name <=> other.name
409409
end
410410

411-
# Look up the given symbol. If method is non-nil, then
412-
# we assume the symbol references a module that
413-
# contains that method
414-
def find_symbol(symbol, method=nil)
411+
##
412+
# Look up +symbol+. If +method+ is non-nil, then we assume the symbol
413+
# references a module that contains that method.
414+
415+
def find_symbol(symbol, method = nil)
415416
result = nil
417+
416418
case symbol
417-
when /^::(.*)/
419+
when /^::(.*)/ then
418420
result = toplevel.find_symbol($1)
419-
when /::/
421+
when /::/ then
420422
modules = symbol.split(/::/)
421-
unless modules.empty?
423+
424+
unless modules.empty? then
422425
module_name = modules.shift
423426
result = find_module_named(module_name)
424-
if result
427+
if result then
425428
modules.each do |name|
426429
result = result.find_module_named(name)
427430
break unless result
428431
end
429432
end
430433
end
434+
431435
else
432436
# if a method is specified, then we're definitely looking for
433437
# a module, otherwise it could be any symbol
@@ -445,14 +449,12 @@ def find_symbol(symbol, method=nil)
445449
end
446450
end
447451
end
448-
if result && method
449-
if !result.respond_to?(:find_local_symbol)
450-
#p result.name
451-
#p method
452-
fail
453-
end
452+
453+
if result and method then
454+
fail unless result.respond_to? :find_local_symbol
454455
result = result.find_local_symbol(method)
455456
end
457+
456458
result
457459
end
458460

lib/rdoc/markup/to_html_crossref.rb

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,41 +48,42 @@ def initialize(from_path, context, show_hash)
4848
def handle_special_CROSSREF(special)
4949
name = special.text
5050

51+
return name if name =~ /\A[a-z]*\z/
52+
5153
return @seen[name] if @seen.include? name
5254

53-
if name[0,1] == '#' then
55+
if name[0, 1] == '#' then
5456
lookup = name[1..-1]
5557
name = lookup unless @show_hash
5658
else
5759
lookup = name
5860
end
5961

60-
#
62+
6163
# Find class, module, or method in class or module.
62-
# Do not, however, use an if/elsif/else chain to do so. Instead, test
63-
# each possible pattern until one matches. The reason for this is that
64-
# a string like "YAML.txt" could be the txt() class method of class YAML
65-
# (in which case it would match the first pattern, which splits the
66-
# string into container and method components and looks up both) or a
67-
# filename (in which case it would match the last pattern, which just
68-
# checks whether the string as a whole is a known symbol).
6964
#
65+
# Do not, however, use an if/elsif/else chain to do so. Instead, test
66+
# each possible pattern until one matches. The reason for this is that a
67+
# string like "YAML.txt" could be the txt() class method of class YAML (in
68+
# which case it would match the first pattern, which splits the string
69+
# into container and method components and looks up both) or a filename
70+
# (in which case it would match the last pattern, which just checks
71+
# whether the string as a whole is a known symbol).
72+
7073
if /([A-Z][\w:]*)[.\#](\w+[!?=]?)/ =~ lookup then
7174
container = $1
7275
method = $2
7376
ref = @context.find_symbol container, method
7477
end
7578

76-
if (!ref &&
77-
/([A-Za-z][\w:]*)[.\#](\w+(\([\.\w+\*\/\+\-\=\<\>]+\))?)/ =~ lookup) then
79+
if !ref and
80+
/([A-Za-z][\w:]*)[.\#](\w+(\([\.\w+\*\/\+\-\=\<\>]+\))?)/ =~ lookup then
7881
container = $1
7982
method = $2
8083
ref = @context.find_symbol container, method
8184
end
8285

83-
if(!ref)
84-
ref = @context.find_symbol lookup
85-
end
86+
ref = @context.find_symbol lookup unless ref
8687

8788
out = if lookup =~ /^\\/ then
8889
$'
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
require 'test/unit'
2+
require 'rdoc/generator'
3+
require 'rdoc/markup/to_html_crossref'
4+
5+
class TestRdocMarkupToHtmlCrossref < Test::Unit::TestCase
6+
7+
def setup
8+
@xref = RDoc::Markup::ToHtmlCrossref.new 'from_path', nil, nil
9+
end
10+
11+
def test_handle_special_CROSSREF_no_underscore
12+
out = @xref.convert 'foo'
13+
14+
assert_equal "<p>\nfoo\n</p>\n", out
15+
end
16+
17+
end
18+

0 commit comments

Comments
 (0)