*** empty log message ***
[m17n/m17n-docs.git] / utils / ja_filter.rb
1 #! /usr/bin/ruby
2
3 buf = [] 
4 doxy = 0
5
6 def commentblock(buf)
7     unless buf == []    
8       print "/** "      
9       buf.each do |i| print i end
10       print "*/\n"      
11     end 
12    end  
13
14 while gets
15
16   gsub!("@seealso", "@par »²¾È:")
17   gsub!("@errors", "@par ¥¨¥é¡¼:")
18   gsub!("@returns", "@par Ìá¤êÃÍ:")
19   gsub!("@return", "@par Ìá¤êÃÍ:")
20  #let doxygen find functions
21   gsub!(/[a-zA-Z_]\s\(\)/) {|m| m.delete!(" ")}
22  #make variables in function descriptions shown in bold
23   gsub!(/\$[A-Z_]+/) {|m| m.delete!("$").reverse.downcase!.concat(" b@").reverse}
24
25    case  $_
26      when /^\s*$/
27         if doxy == 1 
28            buf.push($_)
29            end
30      when /\/\/\/\// 
31         commentblock(buf)
32         buf = []
33    
34      when /\/\*\s.*\*\//        # /* comment */ type comment
35         if doxy == 1            
36         buf.push($_.gsub!(/\*\//, " ").gsub!(/\/\*/, "//")) # should be included only in the example code
37         else
38           if doxy == 0 
39           commentblock(buf)
40           buf = []
41           print $_.gsub!(/\/\*\s.*\*\//," ")                # should be omiited in code
42           end
43         end
44      when /\/\*{2,3}en.*\*\//   #english one liner is omitted
45      when /\/\*\*ja.*\*\//      #one liner
46      when /\/\*\*\*ja.*\*\//    #one liner
47         buf.push($_.gsub!(/\/\*+ja/, " ").gsub!(/\*\//, " "))
48      when /\/\*\*\s.*\*\//      #one liner
49      when /\/\*\*\*\s.*\*\//    #one liner
50         buf.push($_.gsub!(/\/\*+/, " ").gsub!(/\*\//, " ")).push("\n")
51
52      when /\/\*{1,2}\s|\/\*{2,3}en|\/\*\*ja/  #this is not for Ja nor users
53         doxy = -1
54      when /\/\*\*\*ja/
55         buf.push($_.gsub!(/\/\*+ja/, " "))
56         doxy = 1
57      when /\/\*\*\*/    
58         buf.push($_.gsub!(/\/\*+/, " "))
59         doxy = 1
60
61      when /EXAMPLE_CODE/ 
62         buf.push($_.gsub!(/#if EXAMPLE_CODE/, "\n \n @par Î㡧 \n @code"))
63         doxy = 1
64
65      when /#endif/
66         if doxy == 1
67            buf.push($_.gsub!(/#endif/, "@endcode"))
68         else
69            commentblock(buf)
70            buf = []
71            print $_
72         end
73         doxy = 0
74      when /\*\//
75         if doxy == 1
76            buf.push($_.gsub!(/\*\//, " "))
77         end
78         doxy = 0
79      else 
80         case doxy 
81           when -1
82           when 1        
83            buf.push($_) 
84           else 
85            commentblock(buf)
86            buf = []
87            print($_)
88         end
89    end
90 end
91
92 commentblock(buf)
93
94 # Local Variables:
95 # coding: euc-jp
96 # End: