Sphinx documentation on GitHub Pages

  • Tutorial
GitHub Pages is such a cool schizophrenic thing that can a) display a page created using the built-in editor, b) generate a Jekyll blog and c) display html files on an arbitrary domain.
In the last image, she is interested in us for posting documentation written using Sphinx .

Technically, in any case, a branch is created gh-pages( except ) from which the content is displayed.
So, the project is one repository, the documentation for it is another, it makes no sense to mix them.
In masterthe documentation repository, we store the sources in the ReStructuredText format and configuration files along with the change history. INgh-pagesnot only is the story meaningless, but logically this branch also exists in parallel master. I proceeded from such premises by creating the following script.

#!/bin/sh
shopt -s extglob dotglob
CURR_DIR="$(pwd)"
TMP_DIR="$CURR_DIR"-gh-pages
sh build.sh
rm -rf "$TMP_DIR"
cp -r . "$TMP_DIR"
cd "$TMP_DIR"
git branch -D gh-pages
git checkout --orphan gh-pages
rm -rf !(.git|.gitignore)
cp -r "$CURR_DIR"/_build/html/* .
touch .nojekyll
echo "droidparts.org" > CNAME
git add -A
git commit -m "published"
git push origin :gh-pages
git push origin gh-pages
rm -rf "$TMP_DIR"

( link )

Procedure:
  1. Run the script that collects the documentation.
  2. Copy the repository to a temporary folder, go to it.
  3. Delete gh-pages, create it again. The parameter --orphanis responsible for the fact that the branch will be created without a parent commit. Those. without reference to master, as required. Also clear the folder.
  4. We copy the files generated in the first step.
  5. We add .nojekyllso that GitHub Pages does not allow Jekyll to underline folders with underline.
  6. We create a file CNAMEwith a domain from which everything will be given. Naturally, you also need to configure DNS .
  7. Finally, commit, delete gh-pagesfrom the server, do push.

As a bonus seeing a bug where GitHub reports the number of the count ahead & behind , and when trying to compare reports that ... . Or should it be?

Also popular now: