Skip to content

Commit fd6b27c

Browse files
committed
fixed problems in continous publishing
1 parent 28bcee7 commit fd6b27c

File tree

3 files changed

+28
-23
lines changed

3 files changed

+28
-23
lines changed

.github/workflows/continous_publishing_latest.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,15 @@ jobs:
4545
uses: actions/checkout@v2
4646
# Sphinx builds html and pdf (in the documentation it contains a link to the documentation website and the build pdf)
4747
# sphinx build sets environment variables
48+
# * SPHINX_BUILD_PDF: the file path of the pdf file build by sphinx
4849
# * DOCUMENT_NAME: official name for the documention configured in the sphinx configuration file conf.py
4950
# NOTE: all user configaration is done in the sphinx config so that this file can left unchanged
50-
- name: build documentation pdf and html (sets env.DOCUMENT_NAME)
51+
- name: build documentation pdf and html (sets env.SPHINX_BUILD_PDF env.DOCUMENT_NAME)
5152
uses: ammaraskar/[email protected]
5253
with:
5354
pre-build-command: "apt-get update -y && apt-get install -y graphviz git latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended"
5455
build-command: "make html latexpdf BUILDDIR=build"
5556
docs-folder: "."
56-
# Determine filename of pdf build by sphinx; sphinx uses strange algorithm to
57-
# derive filename; so we just find the .log file and change the extension to .pdf .
58-
# Note: we search for log file, because there is only one log file. But
59-
# there could be multiple pdf files in project. (eg. for an image)
60-
- name: determine filename of pdf build by sphinx (sets env.SPHINX_BUILD_PDF)
61-
run: |
62-
WEBSITE_SUBDIR="latest"
63-
logfile=$(echo build/latex/*.log)
64-
pdffile=${logfile%.log}.pdf
65-
printf "::set-env name=SPHINX_BUILD_PDF::$pdffile\n"
6657
# Publish website on github pages
6758
- name: get env.GITHUB_PAGES_WEBSITE_URL and env.WEBSITE_SUBDIR
6859
run: |

.github/workflows/continous_publishing_stable.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
uses: actions/checkout@v2
1515
# Sphinx builds html and pdf documentation
1616
# sphinx build sets environment variables
17+
# * SPHINX_BUILD_PDF: the file path of the pdf file build by sphinx
1718
# * DOCUMENT_NAME: official name for the documention configured in the sphinx configuration file conf.py
1819
# NOTE: all user configaration is done in the sphinx config so that this file can left unchanged
1920
- name: build documentation pdf and html
@@ -22,16 +23,6 @@ jobs:
2223
pre-build-command: "apt-get update -y && apt-get install -y graphviz git latexmk texlive-latex-recommended texlive-latex-extra texlive-fonts-recommended"
2324
build-command: "make html latexpdf BUILDDIR=build"
2425
docs-folder: "."
25-
# Determine filename of pdf build by sphinx; sphinx uses strange algorithm to
26-
# derive filename; so we just find the .log file and change the extension to .pdf .
27-
# Note: we search for log file, because there is only one log file. But
28-
# there could be multiple pdf files in project. (eg. for an image)
29-
- name: determine filename of pdf build by sphinx (sets env.SPHINX_BUILD_PDF)
30-
run: |
31-
WEBSITE_SUBDIR="latest"
32-
logfile=$(echo build/latex/*.log)
33-
pdffile=${logfile%.log}.pdf
34-
printf "::set-env name=SPHINX_BUILD_PDF::$pdffile\n"
3526
# Publish website on github pages
3627
- name: get env.GITHUB_PAGES_WEBSITE_URL and env.WEBSITE_SUBDIR
3728
run: |

source/continuous_publishing.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@
8282

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

85-
if githubenv: handle.close()
86-
8785
pdfdocumenturl="https://github.com/{0}/{1}/releases/download/{2}/{3}.pdf".format(github_user_or_organisation,
8886
github_repo_name,release_name,document_name)
8987

@@ -117,6 +115,31 @@
117115
rst_epilog=""
118116
rst_epilog = rst_epilog + url_and_versions
119117

118+
# -- get the filename of the build pdf (SPHINX_BUILD_PDF) ----------
119+
120+
# NOTE: SPHINX_BUILD_PDF is exported to be used in github actions workflow
121+
122+
123+
def slugify(value, allow_unicode=False):
124+
"""
125+
Convert to ASCII if 'allow_unicode' is False. Convert spaces to hyphens.
126+
Remove characters that aren't alphanumerics, underscores, or hyphens.
127+
Convert to lowercase. Also strip leading and trailing whitespace.
128+
"""
129+
import unicodedata
130+
import re
131+
value = str(value)
132+
if allow_unicode:
133+
value = unicodedata.normalize('NFKC', value)
134+
else:
135+
value = unicodedata.normalize('NFKD', value).encode('ascii', 'ignore').decode('ascii')
136+
value = re.sub(r'[^\w\s-]', '', value.lower()).strip()
137+
return re.sub(r'[\s]+', '', value)
138+
139+
140+
output_pdf="build/latex/" + slugify(project) + ".pdf"
141+
handle.write("SPHINX_BUILD_PDF=" + output_pdf + "\n")
142+
if githubenv: handle.close()
120143

121144

122145

0 commit comments

Comments
 (0)