3 ## Licensed under Apache-2.0
5 ## Project Home Page: http://github.com/Anvil/bash-doxygen/
6 ## Project Author: Damien Nadé <github@livna.org>
14 # \2: already identified params
15 # \3: previous doc string
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/
23 / *\(function \+\)\?[a-z:.A-Z0-9_]\+ *() *{ *$/!{
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
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.
48 # Reset exchange buffer
52 # Remove declare keyword, we wont need it anymore
54 # Simple declaration case.
61 # Concat options. Some of them are ignored, such as -f.
63 s/^-\([aAilrtux]\+\) \+-\([aAilrtux]\+\) \+/-\1\2 /
66 # Prepend Exported and ReadOnly attributes
78 # Integer type, exclusive with default 'String' type.
86 # String type. handling.
102 # For arrays, we remove the initialisation since I dont know yet
103 # how to print it for doxygen to understand.
112 s/.*/&AssociativeArray /
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
133 /^ *export \+[_a-zA-Z]/{
136 s/^ *export \+/Exported String /
142 # Delete non doxygen-related lines content, but not the line
144 /^\(\s*\)## \|^\1##$/!{
149 # For arrays, to avoid duplication.
151 s/\(-[^ ]\+ \+[^=]\+\)=.*/\1/
155 # Make all ## lines doxygen-able.
156 s/^\s*##\( \|$\)/\/\/!\1/p