This repository contains the Github Action for the render-docs command line tool. The purpose of it is to create markdown documentation from doxygen compatible code comments in C and C++ code.
The benefit of maintaining API documentation along with the code itself is that you get inline documentation tooltips by IDEs that support that plus the chance of documentation getting out of sync is lower as code maintainers have it in front of their eyes when making changes.
The tool uses a fork of moxygen to parse the XML output generated by doxygen.
Rendering the documentation as part of the CI pipeline ensures always up-to-date documentation.
This Github workflow can be imported into your own workflow via uses property:
arduino/render-docs-github-action/.github/workflows/render-docs.yml
The minimal arguments that it needs are source-path and target-path.
Here is a minimal workflow to render documentation in your own repository:
name: Render Documentation
on:
push:
branches:
- main
paths:
- ".github/workflows/render-documentation.ya?ml"
- "examples/**"
- "src/**"
pull_request:
branches:
- main
paths:
- ".github/workflows/render-documentation.ya?ml"
- "examples/**"
- "src/**"
workflow_dispatch:
jobs:
render-docs:
permissions:
contents: write
uses: arduino/render-docs-github-action/.github/workflows/render-docs.yml@main
with:
source-path: './src'
target-path: './docs/api.md'
commit: ${{ github.event_name != 'pull_request' }} # Only commit changes if not a PRYou can also run the tool as a Github action, rather than a reusable workflow:
jobs:
render-docs:
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: arduino/render-docs-github-action@main
with:
source-path: './src'
target-path: './docs/api.md'Please note that this workflow only triggers when files are modified that match the given paths: pattern. This can be useful to avoid unnecessary workflow runs.
Also the workflow needs to be granted write permissions to commit the rendered documentation file. This is unless the commit option is set to false. To grand write permissions you can either enable this in the settings for the repository for any workflow that uses the default Github token, or, as shown here using:
permissions:
contents: write
The workflow has a couple of inputs that allows to configure the behaviour:
source-pathThe source path where the action should look for code documentation in .h files.target-pathThe target path of the markdown file e.g. ./docs/api.mdexclude-patternUse this when certain files or folder inside the source folder should not be processed.include-cppIt's good practice to do the class and function declarations in the .h file and thus also add the documentation there. However, if you happen to have code documentation also in .cpp files enabling this option will process those files too.show-access-modifiersIf set to true, the access modifiers will be rendered in the documentation.access-levelAllows to specify which class members to filter out in the documentation. If you specifyprivateall members will show up in the documentation. If you set it toprotectedonly the private members will be filtered out. When set topubliconly public members will be processed.fail-on-warningsThe command prints documentation issues such as missing documentation. This option makes the action fail when such issues are found. This allows to achieve 100% documentation coverage.commitDefines whether the rendered markdown files should be committed to the repository automatically.commit-messageDefines the commit message to be used whencommitis set to true.committer-nameUsername to use as the author of the commit. Defaults to "github-actions[bot]".committer-emailEmail address to use as the author of the commit. Defaults to the email for "github-actions[bot]".debugEnable this option to get additional output from the tool. This allows to debug in case you get unexpected output from the command.
If you encounter any issue, please open a bug report here.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
For questions, comments, or feedback on this package, please create an issue on this repository.