diff options
author | dave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-21 07:28:54 +0000 |
---|---|---|
committer | dave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-12-21 07:28:54 +0000 |
commit | da99e407fbf36051bf9ebce01418589bff557298 (patch) | |
tree | 2d673dc5133830cc910ac4e05106236659ff1658 /lib/rdoc/ri | |
parent | 6228cbe5efb35f3fb867f42525905cf2ded37aad (diff) | |
download | ruby-da99e407fbf36051bf9ebce01418589bff557298.tar.gz |
Add file.c comments (and necessary support in parse_c.rb)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/ri')
-rw-r--r-- | lib/rdoc/ri/ri_descriptions.rb | 19 | ||||
-rw-r--r-- | lib/rdoc/ri/ri_formatter.rb | 30 |
2 files changed, 39 insertions, 10 deletions
diff --git a/lib/rdoc/ri/ri_descriptions.rb b/lib/rdoc/ri/ri_descriptions.rb index 9e280abf94..9bd5c2d13b 100644 --- a/lib/rdoc/ri/ri_descriptions.rb +++ b/lib/rdoc/ri/ri_descriptions.rb @@ -76,13 +76,12 @@ module RI end end - class ClassDescription < Description + class ModuleDescription < Description attr_accessor :class_methods attr_accessor :instance_methods attr_accessor :attributes attr_accessor :constants - attr_accessor :superclass attr_accessor :includes # merge in another class desscription into this one @@ -92,6 +91,13 @@ module RI merge(@attributes, old.attributes) merge(@constants, old.constants) merge(@includes, old.includes) + if @comment.nil? || @comment.empty? + @comment = old.comment + end + end + + def display_name + "Module" end private @@ -104,6 +110,15 @@ module RI end end + class ClassDescription < ModuleDescription + attr_accessor :superclass + + def display_name + "Class" + end + end + + class MethodDescription < Description attr_accessor :is_class_method diff --git a/lib/rdoc/ri/ri_formatter.rb b/lib/rdoc/ri/ri_formatter.rb index 1e70529bfe..b3024d4c6c 100644 --- a/lib/rdoc/ri/ri_formatter.rb +++ b/lib/rdoc/ri/ri_formatter.rb @@ -1,11 +1,16 @@ module RI - class RiFormatter + class TextFormatter + + def TextFormatter.create(options, indent) + new(options, indent) + end attr_reader :indent - def initialize(width, indent) - @width = width - @indent = indent + def initialize(options, indent) + @options = options + @width = options.width + @indent = indent end @@ -23,7 +28,7 @@ module RI def wrap(txt, prefix=@indent, linelen=@width) return unless txt && !txt.empty? - work = txt.dup + work = conv_markup(txt) textLen = linelen - prefix.length patt = Regexp.new("^(.{0,#{textLen}})[ \n]") next_prefix = prefix.tr("^ ", " ") @@ -53,9 +58,6 @@ module RI # convert HTML entities back to ASCII def conv_html(txt) txt. - gsub(%r{<tt>(.*?)</tt>}) { "+#$1+" } . - gsub(%r{<b>(.*?)</b>}) { "*#$1*" } . - gsub(%r{<em>(.*?)</em>}) { "_#$1_" } . gsub(/>/, '>'). gsub(/</, '<'). gsub(/"/, '"'). @@ -63,6 +65,15 @@ module RI end + # convert markup into display form + def conv_markup(txt) + txt. + gsub(%r{<tt>(.*?)</tt>}) { "+#$1+" } . + gsub(%r{<code>(.*?)</code>}) { "+#$1+" } . + gsub(%r{<b>(.*?)</b>}) { "*#$1*" } . + gsub(%r{<em>(.*?)</em>}) { "_#$1_" } + end + ###################################################################### def display_list(list) @@ -167,4 +178,7 @@ module RI end end end + end + + |