mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
tool/strip-rdoc.rb: optimize
This script is called from Doxygen many times. Worth optimising. [ci skip]
This commit is contained in:
parent
94e5953b48
commit
ef74483594
Notes:
git
2021-09-10 20:01:58 +09:00
1 changed files with 9 additions and 21 deletions
|
@ -1,26 +1,14 @@
|
||||||
#!ruby
|
#!ruby
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
# Filter for preventing Doxygen from processing RDoc comments.
|
# Filter for preventing Doxygen from processing RDoc comments.
|
||||||
# Used by the Doxygen template.
|
# Used by the Doxygen template.
|
||||||
|
|
||||||
ARGF.binmode
|
print ARGF.binmode.read.tap {|src|
|
||||||
source = ARGF.read
|
src.gsub!(%r|(/\*[!*])(?:(?!\*/).)+?^\s*\*\s?\-\-\s*$(.+?\*/)|m) {
|
||||||
source = source.gsub(%r{/\*([!*])((?!\*/).+?)\*/}m) do |comment|
|
marker = $1
|
||||||
marker, comment = $1, $2
|
comment = $2
|
||||||
next "/**#{comment}*/" unless /^\s*\*\s?\-\-\s*$/ =~ comment
|
comment.sub!(%r|^\s*\*\s?\+\+\s*$.+?(\s*\*/)\z|m, '\\1')
|
||||||
doxybody = nil
|
marker + comment
|
||||||
comment.each_line do |line|
|
}
|
||||||
if doxybody
|
}
|
||||||
if /^\s*\*\s?\+\+\s*$/ =~ line
|
|
||||||
break
|
|
||||||
end
|
|
||||||
doxybody << line
|
|
||||||
else
|
|
||||||
if /^\s*\*\s?--\s*$/ =~ line
|
|
||||||
doxybody = "\n"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
"/*#{marker}#{doxybody}*/"
|
|
||||||
end
|
|
||||||
print source
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue