GitHub offers hosting documentation on GitHub Pages. This can be done once for each GitHub user, for each GitHub organization, for each GitHub project.
If the process for building the autodocs is already in place (as is the case for libyui), it is just a matter of generating them, moving them to the right place, and deploying them to the project's GitHub Pages.
GitHub pages use a special branch named gh-pages
. Put an index.html
or an index.md
file to a directory, commit it to that branch, and you'll get a page on the project's GitHub page. The URL is something like https://username.github.io/projectname/...
plus of course the directory hierarchy where the index.html
or index.md
file is.
To generate and publish the C++ class documentation for the libyui base library in my fork, I did:
- Clone the repo and go to the checkout:
git clone -o mine [email protected]:shundhammer/libyui.git
cd libyui
- Create a fresh empty branch named
gh-pages
(the exact branch name is important!):
git branch | grep -q "gh-pages" && git branch -D gh-pages
git branch gh-pages
git checkout gh-pages
- Generate the autodocs:
make -C libyui -f Makefile.repo doc
The autodocs are now in ./libyui/build/doc/html
.
- Move the freshly generated autodocs to the desired directory and add them to the
gh-pages
branch:
rm -rf api-doc
mv libyui/build/doc/html api-doc
git add api-doc/**
git commit -am "Generated API doc"
git push -f mine gh-pages:gh-pages
-
Check the result at https://shundhammer.github.io/libyui/api-doc/
or in the GitHub source code browser at https://github.com/shundhammer/libyui/tree/gh-pages .
This was implemented as a GitHub action with libyui/libyui#26: We already had a docker image from which to build libyui, so it was just a matter to add a new GitHub action that executes the above steps:
Some GitHub authentication token might be required to have push permissions in the actions.
Amazingly enough, no additional credentials were required to push to the gh-pages
branch; but the Git committer needs to be identified with git config
.
Disk Space / Download Size
@lslezak raised concerns that the autodocs might be quite large and thus inflate the sources when cloning the repo. This is a valid point.
We checked, and it turned out that even though the generated HTML and PNGs (for the class diagrams) consume 21 MB, in the
.git
directory it's compressed to only 4 MB (to a total of 29 MB at the time of this writing). And since we don't keep a history of the changes in the autodocs (we delete the existing gh-pages branch first, create a new one and force-push it), this does not accumulate over time.