|
|
|
@ -57,7 +57,8 @@ class Document:
|
|
|
|
|
# Init default values |
|
|
|
|
self.settings = { |
|
|
|
|
'multiversion': False, |
|
|
|
|
'default_version': '' |
|
|
|
|
'default_version': '', # Only used if multiversion is True |
|
|
|
|
'build_pdf': False, # for multiversion, this can be set to an array of strings indicating each branch or tag for which we want to build the PDF |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
# Read settings.json (if it exists) |
|
|
|
@ -79,24 +80,40 @@ class Document:
|
|
|
|
|
|
|
|
|
|
if multiversion_build: |
|
|
|
|
# also fetch all branches and tags, so that sphinx-multiversion knows what versions exist and can pull them |
|
|
|
|
cmd.append(['bash', '-c', 'for BRANCH in $(git branch -a | grep remotes | grep -v HEAD | grep -v master); do git branch --track "${BRANCH#remotes/origin/}" "${BRANCH}" || echo "(ignored)"; done']) |
|
|
|
|
cmd.append(['git', 'fetch', '--all']) |
|
|
|
|
cmd.append(['bash', '-c', 'for BRANCH in $(git branch -a | grep remotes | grep -v HEAD | grep -v master); do git branch --track "${BRANCH#remotes/origin/}" "${BRANCH}" || git branch -f "${BRANCH#remotes/origin/}" -t "${BRANCH}"; done']) |
|
|
|
|
|
|
|
|
|
# build the HTML version |
|
|
|
|
cmd.append(['make', 'html_versions', 'BUILDDIR=../build']) |
|
|
|
|
|
|
|
|
|
# TODO: build PDF(s) version(s) |
|
|
|
|
if type(self.settings['build_pdf']) is list: |
|
|
|
|
for pdf_branch_name in self.settings['build_pdf']: |
|
|
|
|
# Extract the source files to a temporary directory |
|
|
|
|
cmd.append(['rm', '-rf', self.doc_path + '/tmp_source']) |
|
|
|
|
cmd.append(['mkdir', self.doc_path + '/tmp_source']) |
|
|
|
|
cmd.append(['bash', '-c', 'git archive "'+pdf_branch_name+'" | tar -x -C "' + self.doc_path + '/tmp_source"']) |
|
|
|
|
|
|
|
|
|
# Build the PDF |
|
|
|
|
cmd.append(['bash', '-c', 'cd "' + self.doc_path + '/tmp_source" && make pdf']) |
|
|
|
|
|
|
|
|
|
# Copy the generated PDF file to the HTML directory, so that it is accessible for download by users |
|
|
|
|
cmd.append(['cp', self.doc_path + '/tmp_source/build/weasyprint/vheliotech.pdf', self.doc_path + '/build/html_versions/' + pdf_branch_name + '/' + self.doc_name + '.pdf']) |
|
|
|
|
|
|
|
|
|
# Clean up |
|
|
|
|
cmd.append(['rm', '-rf', self.doc_path + '/tmp_source']) |
|
|
|
|
|
|
|
|
|
else: |
|
|
|
|
# build the HTML version |
|
|
|
|
cmd.append(['make', 'html', 'BUILDDIR=../build']) |
|
|
|
|
|
|
|
|
|
# build the PDF version |
|
|
|
|
cmd.append(['make', 'pdf', 'BUILDDIR=../build']) |
|
|
|
|
if self.settings['build_pdf']: |
|
|
|
|
# build the PDF version |
|
|
|
|
cmd.append(['make', 'pdf', 'BUILDDIR=../build']) |
|
|
|
|
|
|
|
|
|
# Copy the generated PDF file to the HTML directory, so that it is accessible for download by users |
|
|
|
|
cmd.append(['cp', self.doc_path + '/build/weasyprint/vheliotech.pdf', self.doc_path + '/build/html/' + self.doc_name + '.pdf']) |
|
|
|
|
# Copy the generated PDF file to the HTML directory, so that it is accessible for download by users |
|
|
|
|
cmd.append(['cp', self.doc_path + '/build/weasyprint/vheliotech.pdf', self.doc_path + '/build/html/' + self.doc_name + '.pdf']) |
|
|
|
|
|
|
|
|
|
# Now that the build is successfull, move it to the deployment directory (replacing any existing content) |
|
|
|
|
# Now that the build is successful, move it to the deployment directory (replacing any existing content) |
|
|
|
|
cmd.append(['rm', '-rf', self.doc_path + '/dist']) |
|
|
|
|
if multiversion_build: |
|
|
|
|
cmd.append(['mv', self.doc_path + '/build/html_versions/', self.doc_path + '/dist/']) |
|
|
|
|