1
1
#! /bin/sed -nf
2
+ # #
3
+ # # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
4
+ # # Version 2, December 2004
5
+ # #
6
+ # # Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
7
+ # #
8
+ # # Everyone is permitted to copy and distribute verbatim or modified
9
+ # # copies of this license document, and changing it is allowed as long
10
+ # # as the name is changed.
11
+ # #
12
+ # # DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
13
+ # # TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
14
+ # #
15
+ # # 0. You just DO WHAT THE FUCK YOU WANT TO.
16
+ # #
17
+ # #
18
+ # # Project Home Page: http://github.com/Anvil/bash-doxygen/
19
+ # # Project Author: Damien Nadé <github@livna.org>
20
+ # #
21
+
2
22
/^ ## \+ @fn /{
3
23
: step
4
24
/@param [^ ] \+ . * $ /{
13
33
# Here, we-reinsert param names into the <funcname>()
14
34
s /\( @fn [^ (\n ] \+ \) (\( [^ (] * \)) \( . * \) \( @param \) \( [^ \n ] \+ \( \.\.\. \) \? \) \( [^ \n ] * \) $ /\1 (\2 , \5 )\3\4\5\7 /
15
35
}
16
- / * [a-zA -Z0-9_] \+ * ( ) * { * $ /! {
36
+ / * \( function \+ \) \? [a-z:.A -Z0-9_] \+ * ( ) * { * $ /! {
17
37
N
18
38
b step
19
39
}
40
+ # Remove optional 'function' keyword (and some extra spaces).
41
+ s / * \( function \+ \) \? \( [a-z:.A-Z0-9_] \+ * ( ) * {\) * $ /\2 /
42
+ # Here, we should have @fn (, param1, param2, param3), we remove
43
+ # the first extra ", ".
20
44
s /\( @fn[^ (] \+ \) ( , /\1 ( /
21
- s /\( @fn \( [^ (] \+ \) ( \) \( [^ )] * \) \( ) . * \) \n \2 ( ) { /\1\3\4 \n \2 (\3 ) { } /
45
+ # Remove the function body to avoid interference, and re-introduce
46
+ # list of parameters in the funcname(<here>).
47
+ s /\( @fn \( [^ (] \+ \) ( \) \( [^ )] * \) \( ) . * \) \n \2 ( ) * { /\1\3\4 \n \2 (\3 ) { } /
48
+ # Replace all '## ' by '//! ' at beginning-of-line.
49
+ s /\( ^ \| \n \) ##\n /\1 \/\/ !\n /g
22
50
s /\( ^ \| \n \) ## /\1 \/\/ ! /g
23
51
p
52
+ b end
24
53
}
54
+
25
55
/^ declare /{
26
56
# The principle is quite easy. For every declare option, we add a
27
57
# keyword into the sed exchange buffer. Once everything is parsed,
110
140
s /$ /; /
111
141
p
112
142
x
143
+ b end
144
+ }
145
+
146
+ /^ * export \+ [_a-zA-Z] /{
147
+ s /= / = /
148
+ s /\( [^ ;] \) * $ /\1 ; /
149
+ s /^ * export \+ /Exported String /
150
+ p
151
+ b end
152
+ }
153
+
154
+
155
+ # Delete non doxygen-related lines content, but not the line
156
+ # themselves.
157
+ /^ ## \| ^ ##$ /! {
158
+ s /^ . * $ //p
113
159
}
114
160
b end
115
161
@@ -120,4 +166,4 @@ b declareprint
120
166
121
167
: end
122
168
# Make all ## lines doxygen-able.
123
- s /^ ## /\/\/ ! /p
169
+ s /^ ##\( \| $ \) /\/\/ !\1 /p
0 commit comments