[#4595] New block syntax — Daniel Amelang <daniel.amelang@...>

I'm really sorry if this isn't the place to talk about this. I've

25 messages 2005/03/21
[#4606] Re: New block syntax — "David A. Black" <dblack@...> 2005/03/21

Hi --

[#4629] Re: New block syntax — "Sean E. Russell" <ser@...> 2005/03/30

On Monday 21 March 2005 16:17, David A. Black wrote:

[#4648] about REXML::Encoding — speakillof <speakillof@...>

Hi.

15 messages 2005/03/31
[#4659] Re: about REXML::Encoding — "Sean E. Russell" <ser@...> 2005/04/04

On Thursday 31 March 2005 09:44, speakillof wrote:

[PATCH] RDoc - :nodoc: and macro in C

From: nobu.nokada@...
Date: 2005-03-15 15:27:06 UTC
List: ruby-core #4572
Hi,

A patch for rdoc to:

* lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser#find_body): allow
  macros as methods.

* lib/rdoc/parsers/parse_c.rb (RDoc::C_Parser#find_call_seq): allow
  :nodoc: modifier in C.


Index: lib/rdoc/parsers/parse_c.rb
===================================================================
RCS file: /home/nakada/cvs/ruby/lib/rdoc/parsers/parse_c.rb,v
retrieving revision 1.27
diff -U2 -p -r1.27 parse_c.rb
--- lib/rdoc/parsers/parse_c.rb	4 Mar 2005 10:40:09 -0000	1.27
+++ lib/rdoc/parsers/parse_c.rb	15 Mar 2005 15:13:20 -0000
@@ -507,5 +507,5 @@ module RDoc
 
         if source_file
-		  file_name = File.join(@file_dir, source_file)
+          file_name = File.join(@file_dir, source_file)
           body = (@@known_bodies[source_file] ||= File.read(file_name))
         else
@@ -520,9 +520,9 @@ module RDoc
 
     # Find the C code corresponding to a Ruby method
-    def find_body(meth_name, meth_obj, body)
-      if body =~ %r{((?>/\*.*?\*/\s*))(static\s+)?VALUE\s+#{meth_name}
-                    \s*(\(.*?\)).*?^}xm
-
-        comment, params = $1, $3
+    def find_body(meth_name, meth_obj, body, quiet = false)
+      case body
+      when %r{((?>/\*.*?\*/\s*))(?:static\s+)?VALUE\s+#{meth_name}
+              \s*(\(.*?\)).*?^}xm
+        comment, params = $1, $2
         body_text = $&
 
@@ -544,5 +544,5 @@ module RDoc
         comment = override_comment if override_comment
 
-        find_call_seq(comment, meth_obj) if comment
+        find_modifiers(comment, meth_obj) if comment
         
 #        meth_obj.params = params
@@ -550,5 +550,14 @@ module RDoc
         meth_obj.add_token(RubyToken::Token.new(1,1).set_text(body_text))
         meth_obj.comment = mangle_comment(comment)
-        
+      when %r{((?>/\*.*?\*/\s*))^\s*\#\s*define\s+#{meth_name}\s+(\w+)}m
+        comment = $1
+        find_body($2, meth_obj, body, true)
+        find_modifiers(comment, meth_obj)
+        meth_obj.comment = mangle_comment(comment) + meth_obj.comment
+      when %r{^\s*\#\s*define\s+#{meth_name}\s+(\w+)}m
+        unless find_body($1, meth_obj, body, true)
+          $stderr.puts "No definition for #{meth_name}" unless quiet
+          return false
+        end
       else
 
@@ -557,10 +566,12 @@ module RDoc
 
         if comment
-          find_call_seq(comment, meth_obj)
+          find_modifiers(comment, meth_obj)
           meth_obj.comment = mangle_comment(comment)
         else
-          $stderr.puts "No definition for #{meth_name}"
+          $stderr.puts "No definition for #{meth_name}" unless quiet
+          return false
         end
       end
+      true
     end
 
@@ -573,6 +584,11 @@ module RDoc
     #        Array.new(10)
     # use it for the parameters
-    def find_call_seq(comment, meth_obj)
-      if comment.sub!(/call-seq:(.*?)^\s*\*?\s*$/m, '')
+    def find_modifiers(comment, meth_obj)
+      if comment.sub!(/:nodoc:\s*^\s*\*?\s*$/m, '') or
+         comment.sub!(/\A\/\*\s*:nodoc:\s*\*\/\Z/, '')
+        meth_obj.document_self = false
+      end
+      if comment.sub!(/call-seq:(.*?)^\s*\*?\s*$/m, '') or
+         comment.sub!(/\A\/\*\s*call-seq:(.*?)\*\/\Z/, '')
         seq = $1
         seq.gsub!(/^\s*\*\s*/, '')


-- 
Nobu Nakada

In This Thread

Prev Next