11#! /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+
222/^ ## \+ @fn /{
323 : step
424 /@param [^ ] \+ . * $ /{
1333 # Here, we-reinsert param names into the <funcname>()
1434 s /\( @fn [^ (\n ] \+ \) (\( [^ (] * \)) \( . * \) \( @param \) \( [^ \n ] \+ \( \.\.\. \) \? \) \( [^ \n ] * \) $ /\1 (\2 , \5 )\3\4\5\7 /
1535 }
16- / * [a-zA -Z0-9_] \+ * ( ) * { * $ /! {
36+ / * \( function \+ \) \? [a-z:.A -Z0-9_] \+ * ( ) * { * $ /! {
1737 N
1838 b step
1939 }
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 ", ".
2044 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
2250 s /\( ^ \| \n \) ## /\1 \/\/ ! /g
2351 p
52+ b end
2453}
54+
2555/^ declare /{
2656 # The principle is quite easy. For every declare option, we add a
2757 # keyword into the sed exchange buffer. Once everything is parsed,
110140 s /$ /; /
111141 p
112142 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
113159}
114160b end
115161
@@ -120,4 +166,4 @@ b declareprint
120166
121167: end
122168# Make all ## lines doxygen-able.
123- s /^ ## /\/\/ ! /p
169+ s /^ ##\( \| $ \) /\/\/ !\1 /p
0 commit comments