*** empty log message ***
[m17n/m17n-docs.git] / utils / dev_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 See Also:")
17   gsub!("@errors", "@par Errors:")
18  #let doxygen find functions
19   gsub!(/[a-z_]\s\(\)/) {|m| m.delete!(" ")}
20  #make variables in function descriptions shown in bold
21   gsub!(/\$[A-Z_]+/) {|m| m.delete!("$").reverse.downcase!.concat(" e@").reverse}
22
23    case  $_
24      when /^$/
25         if doxy == 1 
26            buf.push($_)
27            end
28      when /\/\/\/\// 
29         commentblock(buf)
30         buf = []
31    
32      when /\/\*\s.*\*\//        # /* comment */ type comment
33         if doxy == 1            # should be included only in the example code
34         buf.push($_.gsub!(/\*\//, " ").gsub!(/\/\*/, "//"))
35         end
36      when /\/\*{2,3}ja.*\*\//   #japanese one liner
37      when /\/\*{2,3}en.*\*\//   #one liner
38         buf.push($_.gsub!(/\/\*+en/, " ").gsub!(/\*\//, " ")).push("\n")
39      when /\/\*{2,3}.*\*\//     #one liner
40         buf.push($_.gsub!(/\/\*+/, " ").gsub!(/\*\//, " ")).push("\n")
41
42      when /\/\*\s|\/\*{2,3}ja/
43         doxy = -1
44      when /\/\*{2,3}en/
45         buf.push($_.gsub!(/\/\*+en/, " "))
46         doxy = 1
47      when /\/\*{2,3}/   
48         buf.push($_.gsub!(/\/\*+/, " "))
49         doxy = 1
50
51      when /EXAMPLE_CODE/ 
52         buf.push($_.gsub!(/#if EXAMPLE_CODE/, "@code \n"))
53         doxy = 1
54
55      when /#endif/
56         if doxy == 1
57            buf.push($_.gsub!(/#endif/, "@endcode"))
58         else
59            commentblock(buf)
60            buf = []
61            print $_
62         end
63         doxy = 0
64      when /\*\//
65         if doxy == 1
66            buf.push($_.gsub!(/\*\//, " "))
67         end
68         doxy = 0
69      else 
70         case doxy 
71           when -1
72           when 1        
73            buf.push($_) 
74           else 
75            commentblock(buf)
76            buf = []
77            print($_)
78         end
79    end
80 end