📜 ⬆️ ⬇️

Sphinx documentation on GitHub Pages

GitHub Pages is such a cool schizophrenic thing that can a) show the 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 gh-pages branch ( except for ) is created, from which content is displayed.
So, a project is one repository, the documentation for it is another, it makes no sense to mix them.
In the master documentation repository, we store source files in the ReStructuredText format and configuration files along with the change history. In gh-pages not only is the story devoid of meaning, so also logically this thread exists parallel to master . I proceeded from such prerequisites 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 )

Sequencing:
  1. Run the script that collects the documentation.
  2. Copy the repository to a temporary folder, go to it.
  3. Remove the gh-pages , create it again. The --orphan parameter --orphan responsible for --orphan branch without a parent committee. Those. without binding to master , as required. Also clear the folder.
  4. Copy the files generated in the first step.
  5. Add .nojekyll so that GitHub Pages does not allow Jekyll to underlined folders.
  6. Create a CNAME file with a domain from which everything will be given. Naturally, you also need to configure the DNS .
  7. Finally, commit, delete gh-pages from the server, push it.

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

')

Source: https://habr.com/ru/post/180213/


All Articles