Allow custom bibliographies

This commit is contained in:
Jake Howard 2017-03-29 19:32:15 +01:00
parent 1c474883be
commit 82b5b93128
4 changed files with 14 additions and 2 deletions

View file

@ -8,7 +8,9 @@ import os
def build(config): def build(config):
data = read_files(os.path.abspath(config.input)) data = read_files(os.path.abspath(config.input))
doc = build_document(data, os.path.join(WORKING_DIR, 'bib.yaml')) doc = build_document(data,
os.path.abspath(config.bibliography) if 'bibliography' in config else None
)
if 'html' in config.output_formats: if 'html' in config.output_formats:
output_html(doc, os.path.abspath(config.output_dir)) output_html(doc, os.path.abspath(config.output_dir))
if 'pdf' in config.output_formats: if 'pdf' in config.output_formats:

View file

@ -21,7 +21,7 @@ def output_html(html, out_dir):
f.write(html) f.write(html)
def build_document(files_content, bibliography): def build_document(files_content, bibliography=None):
args = [ args = [
'-s', '-s',
] ]

View file

@ -26,8 +26,17 @@ def test_output(config):
raise ConfigValidationException("Invalid output formats provided: '{}'".format(", ".join(invalid_formats))) raise ConfigValidationException("Invalid output formats provided: '{}'".format(", ".join(invalid_formats)))
def validate_bibliography(config):
if 'bibliography' not in config:
return
abs_bibliography = os.path.abspath(config.bibliography)
if not os.path.isfile(abs_bibliography):
raise ConfigValidationException("Invalid bibliography path: '{}'".format(abs_bibliography))
def validate_config(config): def validate_config(config):
check_required_keys(config) check_required_keys(config)
test_output(config) test_output(config)
validate_bibliography(config)

View file

@ -3,3 +3,4 @@ output_formats:
- html - html
- pdf - pdf
output_dir: out/ output_dir: out/
bibliography: bib.yaml