Skip to content

Commit

Permalink
fixed problems in continous publishing
Browse files Browse the repository at this point in the history
  • Loading branch information
harcokuppens committed May 21, 2021
1 parent 28bcee7 commit fd6b27c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
13 changes: 2 additions & 11 deletions .github/workflows/continous_publishing_latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,24 +45,15 @@ jobs:
uses: actions/checkout@v2
# Sphinx builds html and pdf (in the documentation it contains a link to the documentation website and the build pdf)
# sphinx build sets environment variables
# * SPHINX_BUILD_PDF: the file path of the pdf file build by sphinx
# * DOCUMENT_NAME: official name for the documention configured in the sphinx configuration file conf.py
# NOTE: all user configaration is done in the sphinx config so that this file can left unchanged
- name: build documentation pdf and html (sets env.DOCUMENT_NAME)
- name: build documentation pdf and html (sets env.SPHINX_BUILD_PDF env.DOCUMENT_NAME)
uses: ammaraskar/sphinx-action@0.4
with:
pre-build-command: "apt-get update -y && apt-get install -y graphviz git latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended"
build-command: "make html latexpdf BUILDDIR=build"
docs-folder: "."
# Determine filename of pdf build by sphinx; sphinx uses strange algorithm to
# derive filename; so we just find the .log file and change the extension to .pdf .
# Note: we search for log file, because there is only one log file. But
# there could be multiple pdf files in project. (eg. for an image)
- name: determine filename of pdf build by sphinx (sets env.SPHINX_BUILD_PDF)
run: |
WEBSITE_SUBDIR="latest"
logfile=$(echo build/latex/*.log)
pdffile=${logfile%.log}.pdf
printf "::set-env name=SPHINX_BUILD_PDF::$pdffile\n"
# Publish website on github pages
- name: get env.GITHUB_PAGES_WEBSITE_URL and env.WEBSITE_SUBDIR
run: |
Expand Down
11 changes: 1 addition & 10 deletions .github/workflows/continous_publishing_stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
uses: actions/checkout@v2
# Sphinx builds html and pdf documentation
# sphinx build sets environment variables
# * SPHINX_BUILD_PDF: the file path of the pdf file build by sphinx
# * DOCUMENT_NAME: official name for the documention configured in the sphinx configuration file conf.py
# NOTE: all user configaration is done in the sphinx config so that this file can left unchanged
- name: build documentation pdf and html
Expand All @@ -22,16 +23,6 @@ jobs:
pre-build-command: "apt-get update -y && apt-get install -y graphviz git latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended"
build-command: "make html latexpdf BUILDDIR=build"
docs-folder: "."
# Determine filename of pdf build by sphinx; sphinx uses strange algorithm to
# derive filename; so we just find the .log file and change the extension to .pdf .
# Note: we search for log file, because there is only one log file. But
# there could be multiple pdf files in project. (eg. for an image)
- name: determine filename of pdf build by sphinx (sets env.SPHINX_BUILD_PDF)
run: |
WEBSITE_SUBDIR="latest"
logfile=$(echo build/latex/*.log)
pdffile=${logfile%.log}.pdf
printf "::set-env name=SPHINX_BUILD_PDF::$pdffile\n"
# Publish website on github pages
- name: get env.GITHUB_PAGES_WEBSITE_URL and env.WEBSITE_SUBDIR
run: |
Expand Down
27 changes: 25 additions & 2 deletions source/continuous_publishing.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@

handle.write("DOCUMENT_NAME=" + document_name + "\n")

if githubenv: handle.close()

pdfdocumenturl="https://github.com/{0}/{1}/releases/download/{2}/{3}.pdf".format(github_user_or_organisation,
github_repo_name,release_name,document_name)

Expand Down Expand Up @@ -117,6 +115,31 @@
rst_epilog=""
rst_epilog = rst_epilog + url_and_versions

# -- get the filename of the build pdf (SPHINX_BUILD_PDF) ----------

# NOTE: SPHINX_BUILD_PDF is exported to be used in github actions workflow


def slugify(value, allow_unicode=False):
"""
Convert to ASCII if 'allow_unicode' is False. Convert spaces to hyphens.
Remove characters that aren't alphanumerics, underscores, or hyphens.
Convert to lowercase. Also strip leading and trailing whitespace.
"""
import unicodedata
import re
value = str(value)
if allow_unicode:
value = unicodedata.normalize('NFKC', value)
else:
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii')
value = re.sub(r'[^\w\s-]', '', value.lower()).strip()
return re.sub(r'[\s]+', '', value)


output_pdf="build/latex/" + slugify(project) + ".pdf"
handle.write("SPHINX_BUILD_PDF=" + output_pdf + "\n")
if githubenv: handle.close()



Expand Down

0 comments on commit fd6b27c

Please sign in to comment.