@@ -97,42 +97,23 @@ def extract_call_seq method
9797 # comment. The difficulty is to make sure not to match lines starting
9898 # with ARGF at the same indent, but that are after the first description
9999 # paragraph.
100- if @text =~ /^\s *:?call-seq:(.*?(?:\S ).*?)^\s *$/m then
100+ if /^(?<S> ((?!\n )\s )*+ (?# whitespaces except newline))
101+ :?call-seq:(?<B> \g <S>(?<N>\n |\z ) (?# blank line))?
102+ (?<seq>
103+ (?>(?<H> \g <S>\w + (?# ' # ARGF' in the example above))
104+ .*\g <N>)?
105+ (\g <S>\S .*\g <N> (?# other non-blank line))*+
106+ (\g <B>+(\k <H>.*\g <N> (?# ARGF.to_a lines))++)*+
107+ )
108+ (^\s *$|\z )
109+ /x =~ @text
110+ seq = $~[ :seq ]
111+
101112 all_start , all_stop = $~. offset ( 0 )
102- seq_start , seq_stop = $~. offset ( 1 )
103-
104- # we get the following lines that start with the leading word at the
105- # same indent, even if they have blank lines before
106- if $1 =~ /(^\s *\n )+^(\s *\w +)/m then
107- leading = $2 # ' * ARGF' in the example above
108- re = %r%
109- \A (
110- (^\s *\n )+
111- (^#{ Regexp . escape leading } .*?\n )+
112- )+
113- ^\s *$
114- %xm
115-
116- if @text [ seq_stop ..-1 ] =~ re then
117- all_stop = seq_stop + $~. offset ( 0 ) . last
118- seq_stop = seq_stop + $~. offset ( 1 ) . last
119- end
120- end
121-
122- seq = @text [ seq_start ..seq_stop ]
123- seq . gsub! ( /^\s *(\S |\n )/m , '\1' )
124113 @text . slice! all_start ...all_stop
125114
126- method . call_seq = seq . chomp
127-
128- else
129- regexp = /^\s *:?call-seq:(.*?)(^\s *$|\z )/m
130- if regexp =~ @text then
131- @text = @text . sub ( regexp , '' )
132- seq = $1
133- seq . gsub! ( /^\s */ , '' )
134- method . call_seq = seq
135- end
115+ seq . gsub! ( /^\s */ , '' )
116+ method . call_seq = seq
136117 end
137118
138119 method
0 commit comments