Search code examples
bashdoxygen

Doxygen print bash file contents


I have a project with bash, python, and C files where I would like to simply print the contents of the bash file in the doxygen documentation.

I am using Doxygen 1.9.4 and my Doxyfile has the following modified settings:

JAVADOC_AUTOBRIEF      = YES
PYTHON_DOCSTRING       = NO
OPTIMIZE_OUTPUT_JAVA   = YES
EXTENSION_MAPPING      = sh=C
EXTRACT_ALL            = YES
SORT_BRIEF_DOCS        = YES
INPUT                  = .
FILTER_PATTERNS        =  *.sh="sh_filter"
FILE_PATTERNS          += *.sh

The sh_filter file has the following contents

#!/bin/bash

echo "\verbatim"
echo "$(cat $1)"
echo "\endverbatim"

After running doxygen, there is nothing that appears in the file reference for the bash file that is within the working directory.

How can I get the file contents to be printed verbatim?


Solution

  • A bit long for a comment. The construction as requested is quite unusual as normally the purpose is to document routines / variables / classes / namespaces etc and support this with code. In this case the requirement is to just show the contents of the file. The bests solution I found is to create the filter like:

    #!/bin/bash
    
    echo "/** \file"
    echo "\details \verbinclude $1 */"
    echo "$(cat $1)"
    

    and have the following added to the doxygen settings file:

    EXTENSION_MAPPING      = sh=C
    INPUT                  = .
    FILTER_PATTERNS        =  *.sh="./sh_filter"
    FILE_PATTERNS += *.sh
    EXAMPLE_PATH = .
    

    (where the different paths are depending on the local situation)