summaryrefslogtreecommitdiff
path: root/lib/rdoc/ri
diff options
context:
space:
mode:
authordave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-21 07:28:54 +0000
committerdave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-12-21 07:28:54 +0000
commitda99e407fbf36051bf9ebce01418589bff557298 (patch)
tree2d673dc5133830cc910ac4e05106236659ff1658 /lib/rdoc/ri
parent6228cbe5efb35f3fb867f42525905cf2ded37aad (diff)
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.rb19
-rw-r--r--lib/rdoc/ri/ri_formatter.rb30
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(/&gt;/, '>').
gsub(/&lt;/, '<').
gsub(/&quot;/, '"').
@@ -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
+
+