diff options
Diffstat (limited to 'lib/rdoc/parser/ruby.rb')
-rw-r--r-- | lib/rdoc/parser/ruby.rb | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/lib/rdoc/parser/ruby.rb b/lib/rdoc/parser/ruby.rb index c9a12a8fe8..8b7c9c3eff 100644 --- a/lib/rdoc/parser/ruby.rb +++ b/lib/rdoc/parser/ruby.rb @@ -405,9 +405,17 @@ class RDoc::Parser::Ruby < RDoc::Parser # # This routine modifies its +comment+ parameter. - def look_for_directives_in context, comment - @preprocess.handle comment, context do |directive, param| + def look_for_directives_in(context, comment) + preprocess = RDoc::Markup::PreProcess.new @file_name, @options.rdoc_include + + preprocess.handle comment, context do |directive, param| case directive + when 'enddoc' then + context.done_documenting = true + '' + when 'main' then + @options.main_page = param if @options.respond_to? :main_page + '' when 'method', 'singleton-method', 'attr', 'attr_accessor', 'attr_reader', 'attr_writer' then false # handled elsewhere @@ -415,6 +423,16 @@ class RDoc::Parser::Ruby < RDoc::Parser context.set_current_section param, comment comment.replace '' break + when 'startdoc' then + context.start_doc + context.force_documentation = true + '' + when 'stopdoc' then + context.stop_doc + '' + when 'title' then + @options.default_title = param if @options.respond_to? :default_title= + '' end end @@ -611,7 +629,6 @@ class RDoc::Parser::Ruby < RDoc::Parser cls_type = single == SINGLE ? RDoc::SingleClass : RDoc::NormalClass cls = declaration_context.add_class cls_type, given_name, superclass - cls.ignore unless container.document_children read_documentation_modifiers cls, RDoc::CLASS_MODIFIERS cls.record_location @top_level @@ -662,7 +679,7 @@ class RDoc::Parser::Ruby < RDoc::Parser ## # Parses a constant in +context+ with +comment+ - def parse_constant container, tk, comment + def parse_constant(container, tk, comment) offset = tk.seek line_no = tk.line_no @@ -701,8 +718,7 @@ class RDoc::Parser::Ruby < RDoc::Parser when TkRPAREN, TkRBRACE, TkRBRACK, TkEND then nest -= 1 when TkCOMMENT then - if nest <= 0 && - (@scanner.lex_state == EXPR_END || !@scanner.continue) then + if nest <= 0 && @scanner.lex_state == EXPR_END unget_tk tk break end @@ -717,6 +733,7 @@ class RDoc::Parser::Ruby < RDoc::Parser end container.add_module_alias mod, name, @top_level if mod + get_tk # TkNL break end when TkNL then @@ -1310,7 +1327,11 @@ class RDoc::Parser::Ruby < RDoc::Parser keep_comment = true when TkCLASS then - parse_class container, single, tk, comment + if container.document_children then + parse_class container, single, tk, comment + else + nest += 1 + end when TkMODULE then if container.document_children then @@ -1495,13 +1516,11 @@ class RDoc::Parser::Ruby < RDoc::Parser ## # Parses statements in the top-level +container+ - def parse_top_level_statements container + def parse_top_level_statements(container) comment = collect_first_comment - look_for_directives_in container, comment - + look_for_directives_in(container, comment) # HACK move if to RDoc::Context#comment= container.comment = comment if container.document_self unless comment.empty? - parse_statements container, NORMAL, nil, comment end @@ -1624,17 +1643,16 @@ class RDoc::Parser::Ruby < RDoc::Parser # Handles the directive for +context+ if the directive is listed in +allow+. # This method is called for directives following a definition. - def read_documentation_modifiers context, allow + def read_documentation_modifiers(context, allow) directive, value = read_directive allow return unless directive - @preprocess.handle_directive '', directive, value, context do |dir, param| - if %w[notnew not_new not-new].include? dir then - context.dont_rename_initialize = true - - true - end + case directive + when 'notnew', 'not_new', 'not-new' then + context.dont_rename_initialize = true + else + RDoc::Parser.process_directive context, directive, value end end |