element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Code Exchange
  • Technologies
  • More
Code Exchange
Blog GitHub: automate project documentation with DoxyGen, and publish online after pushing commits
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Code Exchange to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 15 Jul 2024 11:46 AM Date Created
  • Views 2683 views
  • Likes 6 likes
  • Comments 6 comments
  • doxygen
  • github.io
  • github
  • teseo_c++
Related
Recommended

GitHub: automate project documentation with DoxyGen, and publish online after pushing commits

Jan Cumps
Jan Cumps
15 Jul 2024

The title says it all. You can generate project documentation from the comments in the source files. I'm using doxygen for that. What I tried today (and succeeded in), is to make a GitHub action that:

  • kicks off a process on one of its job servers that automatically generates the documentation
  • kicks of a second process to deploy that on github.io

image

Prerequisite at this point, is that you know how to configure your project for doxygen. And that you know how to write good comments that make for good documentation. Here's a link to one of my ./Doxygen configuration files, if you need inspiration. Take care that you have such a file checked into your project's github repository.

Then create a new GitHub action. You can that by creating a .yaml file in the .github/workflow subdir of your project and push that, or you can open your GitHub repo online, and navigate to Actions -> wew workflow -> set up a workflow yourself. The latter option has the advantage that you get some code support and validation. I named my file .github/workflows/doxygen-gh-pages.yml.

I set up 3 actions, that all will run on GitHub hosted servers:

  1. checkout the code
  2. generate the documentation with a nice GitHub market place plugin.
  3. publish to github.io

Here's the full content

# Sample workflow for building and deploying a Doxygen site to GitHub Pages
name: Deploy Doxygen with GitHub Pages dependencies preinstalled

on:
  # Runs on pushes targeting the default branch
  push:
    branches: ["main"]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
  group: "pages"
  cancel-in-progress: false

jobs:
  # Build job
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Setup Pages
        uses: actions/configure-pages@v5
      - name: Run Doxygen
        uses: mattnotmitt/doxygen-action@v1.9.5
        with:
          # working-directory: '${{github.workspace}}/Kerbal/doxygen'
          doxyfile-path: 'Doxyfile'
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: doc_generated/html

  # Deployment job
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4

The nice thing is that you don't have to store any credentials. They are dynamically generated by GitHub. As repository manager, you control what can be in that .yaml file. And you can thus control what is allowed, and what actions run.

Here is a part of the run logs:

Checkout and doxygen html documents generation

image

Then deploy to github.io:

image

I created this for my Pico GPS library. The documentation is online: https://jancumps.github.io/pico_gps_teseo/

Next:  GitHub: automate Raspberry Pico project build verification with GitHub Actions 
Link to 
all posts. 

  • Sign in to reply
  • Jan Cumps
    Jan Cumps 5 months ago

    The GitHub doxygen-action task has a number of versions. Each version matches a DoxyGen document generator version.
    Since a few weeks, the author created an "edge" version. That one will always install the latest DoxyGen version available.

          - name: Run Doxygen
            uses: mattnotmitt/doxygen-action@edge
            with:
              # working-directory: '${{github.workspace}}/Kerbal/doxygen'
              doxyfile-path: 'Doxyfile'

    At the time of writing, it 'll use DoxyGen 1.13.2

    The author has added a funny message:

    image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • shabaz
    shabaz over 1 year ago in reply to Jan Cumps

    Although I have seen it in open source projects, I've never had to do doxygen comments in any code I've written (and I've not seen it being used in orgs, but maybe I'm mistaken and I just happened to work on projects that did not use it).

    To me it does make it harder to follow directly from the source. I saw online that there is some way with Visual Code to write a rule to darken the doxygen stuff, so that it's not as visible when looking at code, but that doesn't seem a good workaround. 

    I also worked with an Aussie firm that I thought were C++ purists, all their code (I worked through hundreds of their files) had a template header, but all their developers wrote just normal comments where needed, and often the class definition was self-explanatory through descriptive member function names etc, with just the occasional comment. Similarly, their source files had just normal comments where needed, and rarely more than a couple of lines in one go (but they had a lot of printed comments for logs!). They usually just one line of comments where needed. But then on the other hand, I believe they did supply some Word documentation too, so there's that. 

    Another neat way of seeing what their code did, was that they supplied a ton of log files. One could go through that as an approximate reference, and see what the code did during execution. Their code had a ton of logging (of different modules). Most of the projects I've seen have had a lot of logging flexibility (selectable modules/types, and selectable levels within that). All lines containing the module, date/timestamp, often handles/addresses of objects and various other detail too.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 1 year ago

    A side effect of doxygen style commenting (I always forget that until I start writing "for documentation" comments:

    It gets harder to read the actual source code, to grasp what a class looks like.

    Before (ignore the colour coding differences - one is from e12 blog, other from VSCode): 

    image

    After:

    image

    What do you think? Is it worth it?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 1 year ago in reply to cstanton

    Getting the original post moved was easy. I got the source code, and pasted it in a new blog.

    With the comments, I can't do that. I used printscreens because that's the only way I know that maintains the conversation flow.

    It doesn't help to integrate them in this post main content, because they were preparation for the next blog, where I structured that same info:  GitHub: automate Raspberry Pico project build verification with GitHub Actions 

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • cstanton
    cstanton over 1 year ago in reply to Jan Cumps

    Hey Jan Cumps , if the intention is for this to be beneficial to search engines, these comments by yourself would be better as text in the blog post rather than a commented image, sorry if that wasn't clear. If we wanted to directly convert the forum thread into a blog post, that can be done, I believe the perceived value was to have the amendments inserted into the blog post itself.

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube