[前][次][番号順一覧][スレッド一覧]

ruby-changes:68481

From: Mike <ko1@a...>
Date: Sat, 16 Oct 2021 01:39:21 +0900 (JST)
Subject: [ruby-changes:68481] d4894e81c0 (master): [ruby/rdoc] extract Comment creation in Parser::C

https://git.ruby-lang.org/ruby.git/commit/?id=d4894e81c0

From d4894e81c0a2acb826686f178e4b1b1ed88adefa Mon Sep 17 00:00:00 2001
From: Mike Dalessio <mike.dalessio@g...>
Date: Mon, 11 Oct 2021 16:47:36 -0400
Subject: [ruby/rdoc] extract Comment creation in Parser::C

This is a prefactor for fixing comment format handling.

https://github.com/ruby/rdoc/commit/a3d366feed
---
 lib/rdoc/parser/c.rb | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/lib/rdoc/parser/c.rb b/lib/rdoc/parser/c.rb
index 9d8db6cdee..ee24a271cf 100644
--- a/lib/rdoc/parser/c.rb
+++ b/lib/rdoc/parser/c.rb
@@ -439,7 +439,7 @@ class RDoc::Parser::C < RDoc::Parser https://github.com/ruby/ruby/blob/trunk/lib/rdoc/parser/c.rb#L439
       next unless cls = @classes[c]
       m = @known_classes[m] || m
 
-      comment = RDoc::Comment.new '', @top_level, :c
+      comment = new_comment '', @top_level, :c
       incl = cls.add_include RDoc::Include.new(m, comment)
       incl.record_location @top_level
     end
@@ -521,7 +521,7 @@ class RDoc::Parser::C < RDoc::Parser https://github.com/ruby/ruby/blob/trunk/lib/rdoc/parser/c.rb#L521
                                    \s*"#{Regexp.escape new_name}"\s*,
                                    \s*"#{Regexp.escape old_name}"\s*\);%xm
 
-    RDoc::Comment.new($1 || '', @top_level, :c)
+    new_comment($1 || '', @top_level, :c)
   end
 
   ##
@@ -560,7 +560,7 @@ class RDoc::Parser::C < RDoc::Parser https://github.com/ruby/ruby/blob/trunk/lib/rdoc/parser/c.rb#L560
                 ''
               end
 
-    RDoc::Comment.new comment, @top_level, :c
+    new_comment comment, @top_level, :c
   end
 
   ##
@@ -600,7 +600,7 @@ class RDoc::Parser::C < RDoc::Parser https://github.com/ruby/ruby/blob/trunk/lib/rdoc/parser/c.rb#L600
 
     case type
     when :func_def
-      comment = RDoc::Comment.new args[0], @top_level, :c
+      comment = new_comment args[0], @top_level, :c
       body = args[1]
       offset, = args[2]
 
@@ -630,7 +630,7 @@ class RDoc::Parser::C < RDoc::Parser https://github.com/ruby/ruby/blob/trunk/lib/rdoc/parser/c.rb#L630
 
       body
     when :macro_def
-      comment = RDoc::Comment.new args[0], @top_level, :c
+      comment = new_comment args[0], @top_level, :c
       body = args[1]
       offset, = args[2]
 
@@ -737,7 +737,7 @@ class RDoc::Parser::C < RDoc::Parser https://github.com/ruby/ruby/blob/trunk/lib/rdoc/parser/c.rb#L737
       comment = ''
     end
 
-    comment = RDoc::Comment.new comment, @top_level, :c
+    comment = new_comment comment, @top_level, :c
     comment.normalize
 
     look_for_directives_in class_mod, comment
@@ -782,7 +782,7 @@ class RDoc::Parser::C < RDoc::Parser https://github.com/ruby/ruby/blob/trunk/lib/rdoc/parser/c.rb#L782
       table[const_name] ||
       ''
 
-    RDoc::Comment.new comment, @top_level, :c
+    new_comment comment, @top_level, :c
   end
 
   ##
@@ -813,7 +813,7 @@ class RDoc::Parser::C < RDoc::Parser https://github.com/ruby/ruby/blob/trunk/lib/rdoc/parser/c.rb#L813
 
     return unless comment
 
-    RDoc::Comment.new comment, @top_level, :c
+    new_comment comment, @top_level, :c
   end
 
   ##
@@ -947,7 +947,7 @@ class RDoc::Parser::C < RDoc::Parser https://github.com/ruby/ruby/blob/trunk/lib/rdoc/parser/c.rb#L947
 
         new_comment = "#{$1}#{new_comment.lstrip}"
 
-        new_comment = RDoc::Comment.new new_comment, @top_level, :c
+        new_comment = self.new_comment(new_comment, @top_level, :c)
 
         con = RDoc::Constant.new const_name, new_definition, new_comment
       else
@@ -1222,4 +1222,7 @@ class RDoc::Parser::C < RDoc::Parser https://github.com/ruby/ruby/blob/trunk/lib/rdoc/parser/c.rb#L1222
     @top_level
   end
 
+  def new_comment text = nil, location = nil, language = nil
+    RDoc::Comment.new(text, location, language)
+  end
 end
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]