From: nisikimi Date: Wed, 13 Sep 2006 08:32:51 +0000 (+0000) Subject: flag for example lines added X-Git-Tag: XML-base~38 X-Git-Url: http://git.chise.org/gitweb/?a=commitdiff_plain;h=6fd9919eb000993fc9ecf5f9ac10d0fea530afa3;p=m17n%2Fm17n-docs.git flag for example lines added --- diff --git a/utils/usr_filter_example_flag.rb b/utils/usr_filter_example_flag.rb new file mode 100644 index 0000000..f9c8f62 --- /dev/null +++ b/utils/usr_filter_example_flag.rb @@ -0,0 +1,112 @@ +#! /usr/bin/ruby + +buf = [] +doxy = 0 +example = 0 + +def commentblock(buf) + unless buf == [] + print "/** " + buf.each do |i| print i end + print "*/\n" + end + end + +while gets + + gsub!("@seealso", "@par See Also:") + gsub!("@errors", "@par Errors:") + gsub!("@returns", "@par Return value:") + gsub!("@return", "@par Return value:") + #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")) + doxy = 0 + example = 0 + else + buf.push($_) + end + + else + case $_ + + when /^\s*$/ + if doxy == 1 + buf.push($_) + end + + when /\/\*=\*\// + commentblock(buf) + buf = [] + +# 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 + when /\/\*\*en.*\*\// #one liner + when /\/\*\*\*en.*\*\// #one liner + buf.push($_.gsub!(/\/\*+en/, " ").gsub!(/\*\//, " ")).push("\n") + when /\/\*\*\s.*\*\// #one liner + when /\/\*\*\*\s.*\*\// #one liner + buf.push($_.gsub!(/\/\*+/, " ").gsub!(/\*\//, " ")).push("\n") + + when /\/\*{1,2}\s|\/\*{2,3}ja|\/\*\*en/ #this is not for En nor users + doxy = -1 + when /\/\*\*\*en/ + buf.push($_.gsub!(/\/\*+en/, " ")) + doxy = 1 + when /\/\*\*\*/ + buf.push($_.gsub!(/\/\*+/, " ")) + doxy = 1 + + when /EXAMPLE_CODE/ + buf.push($_.gsub!(/#if EXAMPLE_CODE/, "\n \n @par Example:\n @code")) + doxy = 1 + example = 1 + + when /\*\// + if doxy == 1 + buf.push($_.gsub!(/\*\//, " ")) + end + doxy = 0 + else + case doxy + when -1 + when 1 + buf.push($_) + else + commentblock(buf) + buf = [] + print($_) + end + end + end +end + +commentblock(buf)