1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Fix parse bug with toplevel methods. Allow RDoc in =begin rdoc/=end comments (experimental)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6066 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
dave 2004-04-02 01:20:58 +00:00
parent 64ec09d456
commit ef38efca9f
5 changed files with 66 additions and 26 deletions

View file

@ -3,6 +3,18 @@ Fri Apr 2 07:31:38 2004 Yukihiro Matsumoto <matz@ruby-lang.org>
* ext/socket/socket.c (make_hostent): fix memory leak, based on * ext/socket/socket.c (make_hostent): fix memory leak, based on
the patch from HORIKAWA Hisashi <vzw00011@nifty.ne.jp>. the patch from HORIKAWA Hisashi <vzw00011@nifty.ne.jp>.
Thu Apr 1 22:55:33 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/parsers/parse_rb.rb: Allow rdoc comments in
=begin rdoc/=end
* lib/rdoc/parsers/parse_rb.rb: Fix problem with comment in
top-level method being taken as file comment.
Thu Apr 1 22:55:04 2004 Dave Thomas <dave@pragprog.com>
* lib/rdoc/ri/ri_options.rb: Fix undefined variable warning.
Thu Apr 1 19:58:37 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp> Thu Apr 1 19:58:37 2004 NAKAMURA, Hiroshi <nakahiro@sarion.co.jp>
* lib/soap/mapping/{factory.rb,registry.rb}: fixed illegal mapped URI * lib/soap/mapping/{factory.rb,registry.rb}: fixed illegal mapped URI

View file

@ -240,7 +240,15 @@ can see the formatted result in EXAMPLE.rb and Anagram.
= Markup = Markup
Comment blocks can be written fairly naturally. Comment blocks can be written fairly naturally, either using '#' on
successive lines of the comment, or by including the comment in
an =begin/=end block. If you use the latter form, the =begin line
must be flagged with an RDoc tag:
=begin rdoc
Documentation to
be processed by RDoc.
=end
Paragraphs are lines that share the left margin. Text indented past Paragraphs are lines that share the left margin. Text indented past
this margin are formatted verbatim. this margin are formatted verbatim.

View file

@ -404,6 +404,15 @@ module RDoc
@@all_classes = {} @@all_classes = {}
@@all_modules = {} @@all_modules = {}
def comment=(t)
if @c
fail t
else
@c = true
end
super
end
def TopLevel::reset def TopLevel::reset
@@all_classes = {} @@all_classes = {}
@@all_modules = {} @@all_modules = {}

View file

@ -624,7 +624,14 @@ class RubyLex
ungetc ungetc
@ltype = nil @ltype = nil
Token(TkRD_COMMENT).set_text(str)
if str =~ /\A=begin\s+rdoc/i
str.sub!(/\A=begin.*\n/, '')
str.sub!(/^=end.*/m, '')
Token(TkCOMMENT).set_text(str)
else
Token(TkRD_COMMENT)#.set_text(str)
end
end end
@OP.def_rule("\n") do @OP.def_rule("\n") do
@ -1394,7 +1401,7 @@ module RDoc
@read = [] @read = []
catch(:eof) do catch(:eof) do
begin begin
parse_statements(@top_level) parse_toplevel_statements(@top_level)
rescue Exception => e rescue Exception => e
$stderr.puts "\n\n" $stderr.puts "\n\n"
$stderr.puts "RDoc failure in #@input_file_name at or around " + $stderr.puts "RDoc failure in #@input_file_name at or around " +
@ -1546,18 +1553,22 @@ module RDoc
res res
end end
def parse_statements(container, single=NORMAL, current_method = nil) def parse_toplevel_statements(container)
nest = 1
save_visibility = container.visibility
if container.kind_of?(TopLevel)
comment = collect_first_comment comment = collect_first_comment
look_for_directives_in(container, comment) look_for_directives_in(container, comment)
container.comment = comment unless comment.empty? container.comment = comment unless comment.empty?
else parse_statements(container, NORMAL, nil, comment)
comment = ''
end end
def parse_statements(container, single=NORMAL, current_method=nil, comment='')
nest = 1
save_visibility = container.visibility
# if container.kind_of?(TopLevel)
# else
# comment = ''
# end
non_comment_seen = true non_comment_seen = true
while tk = get_tk while tk = get_tk

View file

@ -5,7 +5,7 @@ module RI
require 'rdoc/ri/ri_display' require 'rdoc/ri/ri_display'
VERSION_STRING = "beta1" VERSION_STRING = "ri: beta1"
CVS_ID = "$Id$"; CVS_ID = "$Id$";
class Options class Options
@ -171,7 +171,7 @@ module RI
# Show the version and exit # Show the version and exit
def show_version def show_version
cvs_info = CVS_ID.split cvs_info = CVS_ID.split
puts "ri #{VERSION_STRING} (#{cvs_info[2]} #{cvs_info[3]})" puts "#{VERSION_STRING} (#{cvs_info[2]} #{cvs_info[3]})"
exit(0) exit(0)
end end
@ -230,7 +230,7 @@ module RI
# Return the doc_dir as an array, or nil if no overriding doc dir was given # Return the doc_dir as an array, or nil if no overriding doc dir was given
def paths def paths
@doc_dir ? [ @doc_dir ] : nil defined?(@doc_dir) ? [ @doc_dir ] : nil
end end
# Return an instance of the displayer (the thing that actually writes # Return an instance of the displayer (the thing that actually writes