A basic doxygen filter (originaly written in GNU sed) allowing you to add inline-documentation to your bash shell scripts.
-
All lines starting with a
##(without any leading blanks) are provided to doxygen. You can use all doxygen command you want in those lines. (see doxygen documentation). -
Some top level declarations will be recognized if you use the
declareprimitive:declare -afor arraysdeclare -Afor associative arraysdeclare -ifor integers- Any other top-level
declarestatement will consider variable is a string. - Those additionnal declaration attributes can be combined with -A/-a/-i/:
declare -lwill mark the variable as LowerCasedeclare -uwill mark the variable as UpperCasedeclare -xwill mark the variable as Exporteddeclare -rwill mark the variable as ReadOnly
- Additionnaly, declaring a variable with an
exportstatement will also be recognized and the variable will be marked as an Exported String.
-
Functions declaration will be recognized if all these conditions are met:
- a
## @fnline is found above the function declaration, - the function is declared either with or without the non-posix
functionkeyword, but always with(). - the body-opening
{char is on the same line than thefuncname()instruction.
- a
- If you do not have a Doxygen configuration file (usually named
Doxyfile), you can generate one by simply running
doxygen -g. - Edit the Doxyfile to map shell files to C parser:
EXTENSION_MAPPING = sh=C - Set your shell script file names pattern as Doxygen inputs, like
e.g.:
FILE_PATTERNS = *.sh - Mention doxygen-bash.sed in either the
INTPUT_FILTERor theFILTER_PATTERNdirective of your Doxyfile. If doxygen-bash.sed is in your $PATH, then you can just invoke it as is, else usesed -n -f /path/to/doxygen-bash.sed --.
Yes.
Q. Does it actually work ?
A. The bash-argsparse
project uses this filter. Check
the result. Click on the
links. See by yourself.
Q. Is it rock-solid ?
A. No.
Q. Do you accept patches ?
A. Definitely.
Q. Why is the project named bash-doxygen while the filter is named
doxygen-bash ?
A. Yeah, haha. Seriously.
Q. Can i include the doxygen-bash.sed file in my own tarball ?
A. See the COPYING file.
Q. Dude. sed ? Seriously ?
A. Are you.. Jealous ?
Q. ... ?
A. Don't you dare !