|
|
@ -53,14 +53,30 @@ class Document: |
|
|
|
self.doc_path = doc_path |
|
|
|
self.doc_path = doc_path |
|
|
|
self.valid = True |
|
|
|
self.valid = True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: actually read document settings |
|
|
|
|
|
|
|
self.settings = { |
|
|
|
|
|
|
|
'multiversion': False, |
|
|
|
|
|
|
|
'default_version': 'main' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
def build(self): |
|
|
|
def build(self): |
|
|
|
#venv_path = os.getenv('VIRTUAL_ENV') |
|
|
|
multiversion_build = self.settings['multiversion'] |
|
|
|
|
|
|
|
|
|
|
|
cmd = [] |
|
|
|
cmd = [] |
|
|
|
|
|
|
|
|
|
|
|
# update source files from git |
|
|
|
# update source files from git |
|
|
|
cmd.append(['git', 'pull']) |
|
|
|
cmd.append(['git', 'pull']) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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']) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# build the HTML version |
|
|
|
|
|
|
|
cmd.append(['make', 'html_versions', 'BUILDDIR=../build']) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# TODO: build PDF(s) version(s) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else: |
|
|
|
# build the HTML version |
|
|
|
# build the HTML version |
|
|
|
cmd.append(['make', 'html', 'BUILDDIR=../build']) |
|
|
|
cmd.append(['make', 'html', 'BUILDDIR=../build']) |
|
|
|
|
|
|
|
|
|
|
@ -70,6 +86,13 @@ class Document: |
|
|
|
# Copy the generated PDF file to the HTML directory, so that it is accessible for download by users |
|
|
|
# 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']) |
|
|
|
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) |
|
|
|
|
|
|
|
cmd.append(['rm', '-rf', self.doc_path + '/dist']) |
|
|
|
|
|
|
|
if multiversion_build: |
|
|
|
|
|
|
|
cmd.append(['mv', self.doc_path + '/build/html_versions/', self.doc_path + '/dist/']) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
cmd.append(['mv', self.doc_path + '/build/html/', self.doc_path + '/dist/']) |
|
|
|
|
|
|
|
|
|
|
|
task = ProcessTask(cmd, cwd = self.doc_path + "/repo") |
|
|
|
task = ProcessTask(cmd, cwd = self.doc_path + "/repo") |
|
|
|
task.start() |
|
|
|
task.start() |
|
|
|
|
|
|
|
|
|
|
@ -91,9 +114,15 @@ class Document: |
|
|
|
os.rmdir(origin_root) |
|
|
|
os.rmdir(origin_root) |
|
|
|
|
|
|
|
|
|
|
|
def get_url(self): |
|
|
|
def get_url(self): |
|
|
|
|
|
|
|
if self.settings['multiversion']: |
|
|
|
|
|
|
|
return "/doc/" + self.encoded_origin + "/" + sanitize_name(self.doc_name)+'/'+sanitize_name(self.branch) + "/" + self.settings['default_version'] + "/index.html" |
|
|
|
|
|
|
|
else: |
|
|
|
return "/doc/" + self.encoded_origin + "/" + sanitize_name(self.doc_name)+'/'+sanitize_name(self.branch) + "/index.html" |
|
|
|
return "/doc/" + self.encoded_origin + "/" + sanitize_name(self.doc_name)+'/'+sanitize_name(self.branch) + "/index.html" |
|
|
|
|
|
|
|
|
|
|
|
def get_pdf_url(self): |
|
|
|
def get_pdf_url(self): |
|
|
|
|
|
|
|
if self.settings['multiversion']: |
|
|
|
|
|
|
|
return "/doc/" + self.encoded_origin + "/" + sanitize_name(self.doc_name)+'/'+sanitize_name(self.branch) + "/" + self.settings['default_version'] + "/" + self.doc_name + ".pdf" |
|
|
|
|
|
|
|
else: |
|
|
|
return "/doc/" + self.encoded_origin + "/" + sanitize_name(self.doc_name)+'/'+sanitize_name(self.branch) + "/" + self.doc_name + ".pdf" |
|
|
|
return "/doc/" + self.encoded_origin + "/" + sanitize_name(self.doc_name)+'/'+sanitize_name(self.branch) + "/" + self.doc_name + ".pdf" |
|
|
|
|
|
|
|
|
|
|
|
def get_api_key(self): |
|
|
|
def get_api_key(self): |
|
|
|