зеркало из https://github.com/github/ruby.git
tool/strip-rdoc.rb: optimize
This script is called from Doxygen many times. Worth optimising. [ci skip]
This commit is contained in:
Родитель
94e5953b48
Коммит
ef74483594
|
@ -1,26 +1,14 @@
|
|||
#!ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
# Filter for preventing Doxygen from processing RDoc comments.
|
||||
# Used by the Doxygen template.
|
||||
|
||||
ARGF.binmode
|
||||
source = ARGF.read
|
||||
source = source.gsub(%r{/\*([!*])((?!\*/).+?)\*/}m) do |comment|
|
||||
marker, comment = $1, $2
|
||||
next "/**#{comment}*/" unless /^\s*\*\s?\-\-\s*$/ =~ comment
|
||||
doxybody = nil
|
||||
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
|
||||
print ARGF.binmode.read.tap {|src|
|
||||
src.gsub!(%r|(/\*[!*])(?:(?!\*/).)+?^\s*\*\s?\-\-\s*$(.+?\*/)|m) {
|
||||
marker = $1
|
||||
comment = $2
|
||||
comment.sub!(%r|^\s*\*\s?\+\+\s*$.+?(\s*\*/)\z|m, '\\1')
|
||||
marker + comment
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче