@@ -97,42 +97,26 @@ def extract_call_seq method
97
97
# comment. The difficulty is to make sure not to match lines starting
98
98
# with ARGF at the same indent, but that are after the first description
99
99
# paragraph.
100
- if @text =~ /^\s *:?call-seq:(.*?(?:\S ).*?)^\s *$/m then
100
+ if /^(?<S> ((?!\n )\s )*+ (?# whitespaces except newline))
101
+ :?call-seq:
102
+ (?<B> \g <S>(?<N>\n |\z ) (?# trailing spaces))?
103
+ (?<seq>
104
+ (\g <S>(?!\w )\S .*\g <N>)*
105
+ (?>
106
+ (?<H> \g <S>\w + (?# ' # ARGF' in the example above))
107
+ .*\g <N>)?
108
+ (\g <S>\S .*\g <N> (?# other non-blank line))*+
109
+ (\g <B>+(\k <H>.*\g <N> (?# ARGF.to_a lines))++)*+
110
+ )
111
+ (?m:^\s *$|\z )
112
+ /x =~ @text
113
+ seq = $~[ :seq ]
114
+
101
115
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' )
124
116
@text . slice! all_start ...all_stop
125
117
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
118
+ seq . gsub! ( /^\s */ , '' )
119
+ method . call_seq = seq
136
120
end
137
121
138
122
method
0 commit comments