| 1 | # Look for function headers. |
| 2 | /\* Function: /,/^{/!d |
| 3 | |
| 4 | # Remove cruft. |
| 5 | /^static int/d |
| 6 | /^{/d |
| 7 | /^ \*\//d |
| 8 | s/(char.*)//g |
| 9 | |
| 10 | # Hold comment lines, deleting them from pattern space for now. |
| 11 | /.\*/{ |
| 12 | s/^..// |
| 13 | s/^ // |
| 14 | H |
| 15 | d |
| 16 | } |
| 17 | |
| 18 | # When we see the function name, merge hold space, in the process |
| 19 | # generating proper texinfo @cindex, @item and @example formatting. |
| 20 | # As a bonus, the `Function' field is moved to the @item line. |
| 21 | # We use repeated `x' commands instead of the simpler `i' to avoid |
| 22 | # requiring a `d' (which would render this script non-composable). |
| 23 | /^gtp_/{ |
| 24 | s/\(.*\)/@cindex \1 GTP command\n@item \1/ |
| 25 | x |
| 26 | s/^\(.\)Function: *\(.*\)\(Arguments:\)/: \2@example\1\3/ |
| 27 | s/\n *\(.*.@example\)/ \1/g |
| 28 | s/$/\n@end example/ |
| 29 | H |
| 30 | s/.*// |
| 31 | x |
| 32 | s/\n//2 |
| 33 | } |
| 34 | |
| 35 | # gtp-commands.sed ends here |