X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=utils%2Fja_filter.rb;h=d335c4a70249f29ad84317495439d6a6f3324e21;hb=d31549712c20fd05b2b7702e29aaa0258162597c;hp=342894967d31739d77b95ae1c52c7b85ca1bf0e5;hpb=dfec347c2d2c2a2bed2a8f008cc42137e5e90d2f;p=m17n%2Fm17n-docs.git diff --git a/utils/ja_filter.rb b/utils/ja_filter.rb index 3428949..d335c4a 100755 --- a/utils/ja_filter.rb +++ b/utils/ja_filter.rb @@ -2,6 +2,7 @@ buf = [] doxy = 0 +example = 0 def commentblock(buf) unless buf == [] @@ -13,38 +14,62 @@ def commentblock(buf) while gets - gsub!("@seealso", "@par »²¾È:") - gsub!("@errors", "@par ¥¨¥é¡¼:") - gsub!("@returns", "@par Ìá¤êÃÍ:") - gsub!("@return", "@par Ìá¤êÃÍ:") + gsub!("@seealso", "@par 参照:") + gsub!("@errors", "@par エラー:") + gsub!("@returns", "@par 戻り値:") + gsub!("@return", "@par 戻り値:") #let doxygen find functions gsub!(/[a-zA-Z_]\s\(\)/) {|m| m.delete!(" ")} #make variables in function descriptions shown in bold gsub!(/\$[A-Z_]+/) {|m| m.delete!("$").reverse.downcase!.concat(" b@").reverse} + 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 + if doxy == 1 # empty line in doxygen comment buf.push($_) end - when /\/\/\/\// + 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 - else + 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 + commentblock(buf) + buf = [] + print $_.gsub!(/\/\*\s.*\*\//," ") # should be omiited in code +# end end + when /\/\*{2,3}en.*\*\// #english one liner is omitted when /\/\*\*ja.*\*\// #one liner when /\/\*\*\*ja.*\*\// #one liner - buf.push($_.gsub!(/\/\*+ja/, " ").gsub!(/\*\//, " ")) + buf.push($_.gsub!(/\/\*+ja/, " ").gsub!(/\*\//, " ")).push("\n") when /\/\*\*\s.*\*\// #one liner when /\/\*\*\*\s.*\*\// #one liner buf.push($_.gsub!(/\/\*+/, " ").gsub!(/\*\//, " ")).push("\n") @@ -59,18 +84,10 @@ while gets doxy = 1 when /EXAMPLE_CODE/ - buf.push($_.gsub!(/#if EXAMPLE_CODE/, "\n \n @par Î㡧 \n @code")) - doxy = 1 + #start example code lines + buf.push($_.gsub!(/#if EXAMPLE_CODE/, "\n \n @par 例: \n @code")) + 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!(/\*\//, " ")) @@ -86,11 +103,12 @@ while gets buf = [] print($_) end + end end end commentblock(buf) # Local Variables: -# coding: euc-jp -# End: \ No newline at end of file +# coding: utf-8 +# End: