mirror of
https://github.com/vale981/sphinx-versions
synced 2025-03-04 17:21:38 -05:00
Generate PDF if filename is given
This commit is contained in:
parent
948ce35899
commit
2cf874d668
3 changed files with 20 additions and 3 deletions
|
@ -203,7 +203,8 @@ def build_options(func):
|
|||
help='Whitelist branches that match the pattern. Can be specified more than once.')(func)
|
||||
func = click.option('-W', '--whitelist-tags', multiple=True,
|
||||
help='Whitelist tags that match the pattern. Can be specified more than once.')(func)
|
||||
|
||||
func = click.option('-P', '--pdf-file',
|
||||
help='Name of the generated PDF file.')(func)
|
||||
return func
|
||||
|
||||
|
||||
|
@ -316,4 +317,3 @@ def build(config, rel_source, destination, **options):
|
|||
|
||||
# Store versions in state for push().
|
||||
config['versions'] = versions
|
||||
|
||||
|
|
|
@ -46,6 +46,9 @@ class Config(object):
|
|||
# Integers.
|
||||
self.verbose = 0
|
||||
|
||||
# Custom.
|
||||
self.pdf_file = None # Name of the pdf
|
||||
|
||||
def __contains__(self, item):
|
||||
"""Implement 'key in Config'.
|
||||
|
||||
|
|
|
@ -5,9 +5,10 @@ import logging
|
|||
import multiprocessing
|
||||
import os
|
||||
import sys
|
||||
from shutil import copyfile
|
||||
|
||||
from sphinx import application, locale
|
||||
from sphinx.cmd.build import build_main
|
||||
from sphinx.cmd.build import build_main, make_main
|
||||
from sphinx.builders.html import StandaloneHTMLBuilder
|
||||
from sphinx.config import Config as SphinxConfig
|
||||
from sphinx.errors import SphinxError
|
||||
|
@ -205,7 +206,20 @@ def _build(argv, config, versions, current_name, is_root):
|
|||
if config.overflow:
|
||||
argv += config.overflow
|
||||
|
||||
# Build pdf if required
|
||||
if config.pdf_file:
|
||||
args = list(argv)
|
||||
args.insert(0,"latexpdf") # Builder type
|
||||
args.insert(0,"ignore") # Will be ignored
|
||||
args = map(unicode, args)
|
||||
result = make_main(args)
|
||||
# Copy to _static dir of src
|
||||
copyfile(argv[1] + unicode("/latex/" + config.pdf_file), argv[0] + unicode("/_static/" + config.pdf_file))
|
||||
|
||||
# Build.
|
||||
args = list(argv)
|
||||
args[1] += u"/html"
|
||||
argv = tuple(args)
|
||||
result = build_main(argv)
|
||||
if result != 0:
|
||||
raise SphinxError
|
||||
|
|
Loading…
Add table
Reference in a new issue