Opennet Firmware
 Alle Dateien Funktionen Variablen Gruppen Seiten
doxygen-bash.sed
gehe zur Dokumentation dieser Datei
1 #!/bin/sed -nf
2 /^## \+@fn/{
3  :step
4  /@param [^ ]\+ .*$/{
5  s/\(@fn [^(]*\)(\(.*\))\(.*\)\(@param \)\([^ \n]\+\(\.\.\.\)\?\)\([^\n]*\)$/\1(\2, \5)\3\4\5\7/
6  }
7  /[a-zA-Z0-9_]\+() {$/!{
8  N
9  b step
10  }
11  s/\(@fn[^(]\+\)(, /\1(/
12  s/\(@fn \([^(]\+\)(\)\([^)]*\)\().*\)\n\2() {/\1\3\4\n\2(\3) { }/
13  s/\(^\|\n\)## /\1\/\/! /g
14  p
15 }
16 /^declare /{
17  # The principle is quite easy. For every declare option, we add a
18  # keyword into the sed exchange buffer. Once everything is parsed,
19  # we add the variable identifier and maybe the variable default
20  # value, add that to the exchange buffer and print the result.
21 
22  # Reset exchange buffer
23  x
24  s/.*//
25  x
26  # Remove declare keyword, we wont need it anymore
27  s/^declare \+//
28  # Simple declaration case.
29  /^[^-]/{
30  x
31  s/.*/&String /
32  x
33  b declareprint
34  }
35  # Concat options. Some of them are ignored, such as -f.
36  :declare
37  s/^-\([aAilrtux]\+\) \+-\([aAilrtux]\+\) \+/-\1\2 /
38  t declare
39 
40  # Prepend Exported and ReadOnly attributes
41  /^-[aAiltur]*x/{
42  x
43  s/.*/&Exported /
44  x
45  }
46  /^-[aAiltux]*r/{
47  x
48  s/.*/&ReadOnly /
49  x
50  }
51 
52  # Integer type, exclusive with default 'String' type.
53  /^-[aAlturx]*i/{
54  x
55  s/.*/&Integer /
56  x
57  b array
58  }
59 
60  # String type. handling.
61  /^-[aAtrx]*l/{
62  x
63  s/.*/&LowerCase /
64  x
65  }
66  /^-[aAtrx]*u/{
67  x
68  s/.*/&UpperCase /
69  x
70  }
71  x
72  s/.*/&String /
73  x
74 
75  : array
76  # For arrays, we remove the initialisation since I dont know yet
77  # how to print it for doxygen to understand.
78  /^-[Ailturx]*a/{
79  x
80  s/.*/&Array /
81  x
82  b deletevalue
83  }
84  /^-[ailturx]*A/{
85  x
86  s/.*/&AssociativeArray /
87  x
88  b deletevalue
89  }
90 
91  :declareprint
92  # Remove the declare option, x, then G will concat the exchange
93  # buffer (the 'type' string) and the regular buffer (the var
94  # possibly followed by an init value). The rest is quite easy to
95  # understand.
96  s/-[^ ]\+ \+//
97  x
98  G
99  s/\n//
100  s/=/ = /
101  s/$/;/
102  p
103  x
104 }
105 b end
106 
107 # For arrays, to avoid duplication.
108 : deletevalue
109 s/\(-[^ ]\+ \+[^=]\+\)=.*/\1/
110 b declareprint
111 
112 :end
113 # Make all ## lines doxygen-able.
114 s/^## /\/\/! /p