Repository navigation
Description
The PyGMT documentation is hosted in the gh-pages branch, with docs of each PyGMT release stored in subdirectories, and docs of the main branch in the dev subdirectory.
Currently, the documentation has no backups and we may lose all the documentation in some rare cases, e.g.,
- Accidentally delete the gh-pages branch when someone tries to clean up stale branches (happened once in the GMT repository Web documentation missing gmt#7338)
- Changes to the "Push the built HTML to gh-pages" step in the "Docs" workflow have uncaught flaws [That's why I'm hesitating to make any changes to improve the step, since it has been working well for a long time]
- "Push the built HTML to gh-pages" step in the "Docs" workflow fails and leads to partial uploads
- maybe more
Technically speaking, we can restore the PyGMT documentation since,
- we may have the gh-pages branch in our local copy (maybe not)
- we can create local environments and rebuild the docs for each PyGMT version [It takes a lot of efforts]
I think the easiest solution is to upload the documentation of each release as release assets. Then if we lose the documentation, we just need to:
- create a new gh-pages branch
- download the documentation for each release from the release page
- organize the documentation into subdirectories and add them to the gh-pages branch
- push the docs to the remote gh-pages branch
- manually trigger the "Docs" workflow once
Looking at the current gh-pages branch, there are more files/directories in addition to the version subdirectories, so the above steps are not enough to restore the gh-pages branch. Here are the additional files/directories:
.buildinfo: This file was added 6 years ago. At that time, files were pushed to the root directory instead of subdirectories in the gh-pages branch. In other words, this file should be deleted..nojekyll: Tell GitHub to not build this branch using Jekyll [Automatically created by the workflow]CNAME: Set up the docs domain (xref: https://docs.github.com/en/pages/configuring-a-custom-domain-for-your-github-pages-site/troubleshooting-custom-domains-and-github-pages#cname-errors) [It was manually added and maintained. I think we should create it automatically in the workflow]index.html: The index page, redirected to/latest/automatically [Again, this file should be automatically created in the workflow]latest: Symlink to the latest release [Automatically linked to the latest version only when making a release. So it's likely we have to create the symblink manually, but it's technically possible to determine the latest version usinggh release listcommand]dev: Contains the dev docs [Automatically created by the workflow]
It agreed, here are things we need to do:
- Create a workflow file to upload the documentation as release assets when making a release CI: Upload documentation HTML ZIP archive and PDF file as release assets #3814
- Upload the documentation of old versions to the release page [manually]
- Remove the
.buildinfofile Delete the .buildinfo file from gh-pages branch #3748 - Improve the step to ensure
.nojekyll/CNAME/index.htmlare created automatically CI: Update the doc deploy script to generate CNAME and index.html #3749 - See if we can have the
latestsymlink created automatically

Activity
seisman commentedon Jan 6, 2025
Ping @GenericMappingTools/pygmt-maintainers for comments.
weiji14 commentedon Jan 6, 2025
I just set a branch protection rule for
gh-pagesto prevent accidental deletion, and it should also disable force pushes.Step 1-3 is still a lot of work 😅 I do see the value of saving the HTML documentation (or a PDF copy, xref #1606) on GitHub or Zenodo for long term archival. But for restoring the
gh-pagesbranch, it might be easier to just mirror it on another git hosting site as we already have on https://www.dagshub.com/GenericMappingTools/pygmt/src/gh-pages, probably do it in a more systematic way.seisman commentedon Jan 7, 2025
We can't disable force pushes, since the doc deploy script always does force pushes:
pygmt/.github/workflows/ci_docs.yml
Line 199 in e0f8e84
Not that much work since we can use
gh release downloadto download the pre-uploaded docs.Good to know that at least we have a copy on DagsHub.
Anyway, it does no harm to upload the HTML documentation as a release asset, with a name like
pygmt-v0.14.0-docs.zip?seisman commentedon Jan 7, 2025
I've enabled force pushes so that the doc deploy script can update the gh-pages branch. The branch protection rule is still useful for preventing deletion.
seisman commentedon Jan 10, 2025
This can be done by the following commands:
The above commands create zip files with name
pygmt-<version>-docs.zipand the directory inside the ZIP files also have the same name.Then we can upload them as release assets using the command below (not tested yet):
Please let me know if you have any comments before I take actions.
seisman commentedon Jan 11, 2025
After thinking twice, maybe we should just name the zip files like
pygmt-docs.zipwithout the version string, similar to what we're doing to thebaseline-images.zip.Then the commands will be:
and
seisman commentedon Feb 8, 2025
In PR #3765, we started to build the PDF documentation, but the PDF file is not deployed anywhere. Now it's time to discuss how we'd like to deploy the HTML and PDF files.
Here is a summary of the current behaviors:
In this issue, I've proposed to create the HTML documentation ZIP archive and upload it as a release asset. We should do the same thing for the PDF file, too. Then, we can add links to the HTML ZIP and PDF files on the sidebar. As for the dev version, we can just copy the HTML ZIP archive and PDF files into the
devfolder.The expected behaviors are (bold marks the behavior changes):
#3794 is the POC PR implementing the proposed changes.
seisman commentedon Feb 19, 2025
I've manually uploaded the pygmt-docs.zip files for old versions using the above commands.
seisman commentedon Feb 19, 2025
After #3814 and #3794, we have PDF and HTML ZIP files deployed/uploaded.
For releases, the permanent links are:
https://github.com/GenericMappingTools/pygmt/releases/download/<version>/pygmt-docs.ziphttps://github.com/GenericMappingTools/pygmt/releases/download/<version>/pygmt-docs.pdfFor dev versions, the permanent links are:
We need to add these links to the website. There are two options:
Debating which one is better.