mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add simple formatter to ri
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
d4e341c43d
commit
0964c47816
3 changed files with 76 additions and 15 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Sep 14 23:45:44 2004 Dave Thomas <dave@pragprog.com>
|
||||||
|
|
||||||
|
* lib/rdoc/ri/ri_formatter.rb (RI::TextFormatter::TextFormatter.for):
|
||||||
|
Add Eric Hodel's simpleformatter.
|
||||||
|
|
||||||
Tue Sep 14 22:11:08 2004 Minero Aoki <aamine@loveruby.net>
|
Tue Sep 14 22:11:08 2004 Minero Aoki <aamine@loveruby.net>
|
||||||
|
|
||||||
* parse.y [ripper]: Add rdoc.
|
* parse.y [ripper]: Add rdoc.
|
||||||
|
@ -46,6 +51,7 @@ Tue Sep 14 16:59:37 2004 Hidetoshi NAGAI <nagai@ai.kyutech.ac.jp>
|
||||||
|
|
||||||
* ext/tk/sample/safe-tk.rb: new sample script
|
* ext/tk/sample/safe-tk.rb: new sample script
|
||||||
|
|
||||||
|
|
||||||
Mon Sep 13 21:33:40 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
Mon Sep 13 21:33:40 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
|
||||||
|
|
||||||
* ext/openssl/ossl_x509name.c (ossl_x509name_to_s): add optional
|
* ext/openssl/ossl_x509name.c (ossl_x509name_to_s): add optional
|
||||||
|
|
|
@ -164,7 +164,10 @@ Options are:
|
||||||
include line numbers in the source code
|
include line numbers in the source code
|
||||||
|
|
||||||
[<tt>--main</tt> _name_]
|
[<tt>--main</tt> _name_]
|
||||||
set the class, module, or file to appear on the index page
|
the class of module _name_ will appear on the index page. If you
|
||||||
|
want to set a particular file as a main page (a README, for
|
||||||
|
example) simply specifiy its name as the first on the command
|
||||||
|
line.
|
||||||
|
|
||||||
[<tt>--merge</tt>]
|
[<tt>--merge</tt>]
|
||||||
when generating _ri_ output, if classes being processed already
|
when generating _ri_ output, if classes being processed already
|
||||||
|
|
|
@ -1,20 +1,6 @@
|
||||||
module RI
|
module RI
|
||||||
class TextFormatter
|
class TextFormatter
|
||||||
|
|
||||||
def TextFormatter.list
|
|
||||||
"plain, html, bs, ansi"
|
|
||||||
end
|
|
||||||
|
|
||||||
def TextFormatter.for(name)
|
|
||||||
case name
|
|
||||||
when /plain/i then TextFormatter
|
|
||||||
when /html/i then HtmlFormatter
|
|
||||||
when /bs/i then OverstrikeFormatter
|
|
||||||
when /ansi/i then AnsiFormatter
|
|
||||||
else nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
attr_reader :indent
|
attr_reader :indent
|
||||||
|
|
||||||
def initialize(options, indent)
|
def initialize(options, indent)
|
||||||
|
@ -594,6 +580,72 @@ module RI
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
##################################################
|
||||||
|
|
||||||
|
# This formatter reduces extra lines for a simpler output.
|
||||||
|
# It improves way output looks for tools like IRC bots.
|
||||||
|
|
||||||
|
class SimpleFormatter < TextFormatter
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
# No extra blank lines
|
||||||
|
|
||||||
|
def blankline
|
||||||
|
end
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
# Display labels only, no lines
|
||||||
|
|
||||||
|
def draw_line(label=nil)
|
||||||
|
unless label.nil? then
|
||||||
|
bold_print(label)
|
||||||
|
puts
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
# Place heading level indicators inline with heading.
|
||||||
|
|
||||||
|
def display_heading(text, level, indent)
|
||||||
|
case level
|
||||||
|
when 1
|
||||||
|
puts "= " + text.upcase
|
||||||
|
when 2
|
||||||
|
puts "-- " + text
|
||||||
|
else
|
||||||
|
print indent, text, "\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
# Finally, fill in the list of known formatters
|
||||||
|
|
||||||
|
class TextFormatter
|
||||||
|
|
||||||
|
FORMATTERS = {
|
||||||
|
"ansi" => AnsiFormatter,
|
||||||
|
"bs" => OverstrikeFormatter,
|
||||||
|
"html" => HtmlFormatter,
|
||||||
|
"plain" => TextFormatter,
|
||||||
|
"simple" => SimpleFormatter,
|
||||||
|
}
|
||||||
|
|
||||||
|
def TextFormatter.list
|
||||||
|
FORMATTERS.keys.sort.join(", ")
|
||||||
|
end
|
||||||
|
|
||||||
|
def TextFormatter.for(name)
|
||||||
|
FORMATTERS[name.downcase]
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue