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