Add bmp2png utility.
[platform/upstream/SSAT.git] / doxygen-bash.sed
1 #!/bin/sed -nf
2 ##
3 ## Licensed under Apache-2.0
4 ##
5 ## Project Home Page: http://github.com/Anvil/bash-doxygen/
6 ## Project Author: Damien Nadé <github@livna.org>
7 ##
8
9 /^## \+@fn/{
10     :step
11     /@param [^ ]\+ .*$/{
12         # Groups are
13         # \1: @fn <funcname>
14         # \2: already identified params
15         # \3: previous doc string
16         # \4: @param<space>
17         # \5: newly identified param name plus optional dot-dot-dot string
18         # \6: optional dot-dot-dot string
19         # \7: everything after \5 to end of line
20         # Here, we-reinsert param names into the <funcname>()
21         s/\(@fn [^(\n]\+\)(\([^(]*\))\(.*\)\(@param \)\([^ \n]\+\(\.\.\.\)\?\)\([^\n]*\)$/\1(\2, \5)\3\4\5\7/
22     }
23     / *\(function \+\)\?[a-z:.A-Z0-9_]\+ *() *{ *$/!{
24         N
25         b step
26     }
27     # Remove optional 'function' keyword (and some extra spaces).
28     s/ *\(function \+\)\?\([a-z:.A-Z0-9_]\+ *() *{\) *$/\2/
29     # Here, we should have @fn (, param1, param2, param3), we remove
30     # the first extra ", ".
31     s/\(@fn[^(]\+\)(, /\1(/
32     # Remove the function body to avoid interference, and re-introduce
33     # list of parameters in the funcname(<here>).
34     s/\(@fn \([^(]\+\)(\)\([^)]*\)\().*\)\n\2() *{/\1\3\4\n\2(\3) { }/
35     # Replace all '## ' by '//! ' at beginning-of-line.
36     s/\(^\|\n\)##\n/\1\/\/!\n/g
37     s/\(^\|\n\)## /\1\/\/! /g
38     p
39     b end
40 }
41
42 /^declare /{
43     # The principle is quite easy. For every declare option, we add a
44     # keyword into the sed exchange buffer. Once everything is parsed,
45     # we add the variable identifier and maybe the variable default
46     # value, add that to the exchange buffer and print the result.
47
48     # Reset exchange buffer
49     x
50     s/.*//
51     x
52     # Remove declare keyword, we wont need it anymore
53     s/^declare \+//
54     # Simple declaration case.
55     /^[^-]/{
56         x
57         s/.*/&String /
58         x
59         b declareprint
60     }
61     # Concat options. Some of them are ignored, such as -f.
62     :declare
63     s/^-\([aAilrtux]\+\) \+-\([aAilrtux]\+\) \+/-\1\2 /
64     t declare
65
66     # Prepend Exported and ReadOnly attributes
67     /^-[aAiltur]*x/{
68         x
69         s/.*/&Exported /
70         x
71     }
72     /^-[aAiltux]*r/{
73         x
74         s/.*/&ReadOnly /
75         x
76     }
77
78     # Integer type, exclusive with default 'String' type.
79     /^-[aAlturx]*i/{
80         x
81         s/.*/&Integer /
82         x
83         b array
84     }
85
86     # String type. handling.
87     /^-[aAtrx]*l/{
88         x
89         s/.*/&LowerCase /
90         x
91     }
92     /^-[aAtrx]*u/{
93         x
94         s/.*/&UpperCase /
95         x
96     }
97     x
98     s/.*/&String /
99     x
100
101     : array
102     # For arrays, we remove the initialisation since I dont know yet
103     # how to print it for doxygen to understand.
104     /^-[Ailturx]*a/{
105         x
106         s/.*/&Array /
107         x
108         b deletevalue
109     }
110     /^-[ailturx]*A/{
111         x
112         s/.*/&AssociativeArray /
113         x
114         b deletevalue
115     }
116
117     :declareprint
118     # Remove the declare option, x, then G will concat the exchange
119     # buffer (the 'type' string) and the regular buffer (the var
120     # possibly followed by an init value). The rest is quite easy to
121     # understand.
122     s/-[^ ]\+ \+//
123     x
124     G
125     s/\n//
126     s/=/ = /
127     s/$/;/
128     p
129     x
130     b end
131 }
132
133 /^ *export \+[_a-zA-Z]/{
134     s/=/ = /
135     s/\([^;]\) *$/\1;/
136     s/^ *export \+/Exported String /
137     p
138     b end
139 }
140
141
142 # Delete non doxygen-related lines content, but not the line
143 # themselves.
144 /^\(\s*\)## \|^\1##$/!{
145      s/^.*$//p
146 }
147 b end
148
149 # For arrays, to avoid duplication.
150 : deletevalue
151 s/\(-[^ ]\+ \+[^=]\+\)=.*/\1/
152 b declareprint
153
154 :end
155 # Make all ## lines doxygen-able.
156 s/^\s*##\( \|$\)/\/\/!\1/p