X-Git-Url: http://git.chise.org/gitweb/?p=m17n%2Fm17n-docs.git;a=blobdiff_plain;f=utils%2Fusr_filter.rb;h=52ac7106df0c672edc174bc6df2b6bdca2f0bbdb;hp=2bb63b0366f22121d6e0195d5c34d4d113fdfda4;hb=70c33845161fed9f14fc4564c2cc0b53facd02bb;hpb=3d3d7bb7f3976172462be1fbeb1dbcfa93dfb844 diff --git a/utils/usr_filter.rb b/utils/usr_filter.rb index 2bb63b0..52ac710 100755 --- a/utils/usr_filter.rb +++ b/utils/usr_filter.rb @@ -2,6 +2,7 @@ buf = [] doxy = 0 +example = 0 def commentblock(buf) unless buf == [] @@ -13,8 +14,6 @@ def commentblock(buf) while gets -# print "****", $_, "\n" - gsub!("@seealso", "@par See Also:") gsub!("@errors", "@par Errors:") gsub!("@returns", "@par Return value:") @@ -24,29 +23,54 @@ while gets #make variables in function descriptions shown in bold gsub!(/\$[A-Z_]+/) {|m| m.delete!("$").reverse.downcase!.concat(" b@").reverse} - case $_ - when /^\s*$/ - if doxy == 1 - buf.push($_) - end - when /\/\/\/\// - commentblock(buf) + if example == 1 + case $_ + when /#endif/ + buf.push($_.gsub!(/#endif/, "@endcode")) + example = 0 + else + buf.push($_) + end + + else # when example == 0 + + case $_ + + when /^\s*$/ + if doxy == 1 # empty line in doxygen comment + buf.push($_) + end + + when /\/\*=\*\// #/*=*/ (flush) + commentblock(buf) buf = [] - - when /^\/\*\s.*\*\// # /* comment */ type comment - if doxy == 1 - buf.push($_.gsub!(/\*\//, " ").gsub!(/\/\*/, "//")) # should be included only in the example code - end - when /\/\*\s.*\*\// # code + /* comment */ type comment - if doxy == 1 - buf.push($_.gsub!(/\*\//, " ").gsub!(/\/\*/, "//")) # should be included in the example code - else - if doxy == 0 - commentblock(buf) - buf = [] - print $_.gsub!(/\/\*\s.*\*\//," ") # should be omiited in code - end + when /\/\* @[{}] \*\// # /* comment */ type comment + commentblock(buf) + buf = [] + print($_) + + when /^\/\*\s.*\*\// # /* comment */ type comment +# if doxy == 1 +# # should be included only in the example code +# ## We used to do the following substituion as a workaround of +# ## a Doxygen bug. +# ## buf.push($_.gsub!(/\*\//, " ").gsub!(/\/\*/, "//")) +# buf.push($_) +# end + + when /\/\*\s.*\*\// # code + /* comment */ type comment +# if doxy == 1 +# # should be included in the example code +# ## See the above comment. +# ## buf.push($_.gsub!(/\*\//, " ").gsub!(/\/\*/, "//")) +# buf.push($_) # should be included in the example code +# else + if doxy == 0 + commentblock(buf) + buf = [] + print $_.gsub!(/\/\*\s.*\*\//," ") # should be omiited in code +# end end when /\/\*{2,3}ja.*\*\// #japanese one liner @@ -66,19 +90,13 @@ while gets buf.push($_.gsub!(/\/\*+/, " ")) doxy = 1 + when /\/\*/ #other comment + when /EXAMPLE_CODE/ + #start example code lines buf.push($_.gsub!(/#if EXAMPLE_CODE/, "\n \n @par Example:\n @code")) - doxy = 1 + example = 1 - when /#endif/ - if doxy == 1 - buf.push($_.gsub!(/#endif/, "@endcode")) - else - commentblock(buf) - buf = [] - print $_ - end - doxy = 0 when /\*\// if doxy == 1 buf.push($_.gsub!(/\*\//, " ")) @@ -94,6 +112,7 @@ while gets buf = [] print($_) end + end end end