Skip to main content

GitHub Pages Import

As part of gunicorn, me and Benoit Chesneau have been starting to look at how to host documentation. There’s the obvious method of using GitHub’s post-update hooks to trigger doc builds and rsync to a webserver, but we ended up wanting to try out github’s hosting to make the whole interface a bit more robust.

GitHub Pages is a pretty awesome service that GitHub provides for hosting project documentation. The only thing is that it requires a gh-pages branch that is the site’s document root. This means that keeping documentation sources in the branch with code is a bit difficult. And it really turns into a head scratcher for things like Sphinx that want to access documentation sources and code sources at the same time.

Then I stumbled across an interesting looking package called github-tools that looked almost like what I wanted. It was a tad complicated and more involved than I wanted but it gave me an idear. Why not just write a script that can copy a directory to the gh-pages branch of the repository. This saves me from even having to think about the branch and everything becomes magical.

This is what ghp-import was written for.

Big Fat Warning

This will DESTROY your gh-pages branch. If you love it, you’ll want to take backups before playing with this. This script assumes that gh-pages is 100% derivative. You should never edit files in your gh-pages branch by hand if you’re using this script because you will lose your work.

Usage

Usage: ghp-import [OPTIONS] DIRECTORY

Options:
  -m MESG     The commit message to use on the target branch.
  -p          Push the branch to origin/{branch} after committing.
  -r REMOTE   The name of the remote to push to. [origin]
  -b BRANCH   Name of the branch to write to. [gh-pages]
  -h, --help  show this help message and exit

Its pretty simple. Inside your repository just run ghp-import $DOCS_DIR where $DOCS_DIR is the path to the built documentation. This will write a commit to your gh-pages branch with the current documents in it.

If you specify -p it will also attempt to push the gh-pages branch to GitHub. By default it’ll just run git push origin gh-pages. You can specify a different remote using the -r flag.

You can specify a different branch with -b. This is useful for user and organization page, which are served from the master branch.

License

ghp-import is distributed under the Tumbolia Public License. See the LICENSE file for more information.

Release files for ghp-import 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ghp-import 0.2.0
File Size Uploaded
ghp-import-0.2.0.tar.gz 4.6 kB Details

Release files / ghp-import-0.2.0.tar.gz

Download URL ghp-import-0.2.0.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
95d60aa28ae09683a87fc3e1fc7ae71fae0861395637f7ae34c2e6b92ba47166
BLAKE2b-256 checksum
How to use checksums
5c061068d3dc75ed78de68374eb651979ceda12e88f54e1e4a5609cc328704a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

2.1.0

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

1 release file

1.1.0

1 release file

1.0.1

1 release file

1.0.0

1 release file

0.6.0

1 release file

0.5.5

1 release file

0.5.4

1 release file

0.5.3

1 release file

0.5.2

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.2

0.4.1

1 release file

0.4.0

1 release file

0.3.2

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.4

1 release file

0.2.3

1 release file

0.2.2

1 release file

0.2.1

1 release file

This release

0.2.0 This release

1 release file

0.1.8

1 release file

0.1.7

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page