Allow custom bibliographies
This commit is contained in:
parent
1c474883be
commit
82b5b93128
4 changed files with 14 additions and 2 deletions
|
@ -8,7 +8,9 @@ import os
|
|||
|
||||
def build(config):
|
||||
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:
|
||||
output_html(doc, os.path.abspath(config.output_dir))
|
||||
if 'pdf' in config.output_formats:
|
||||
|
|
|
@ -21,7 +21,7 @@ def output_html(html, out_dir):
|
|||
f.write(html)
|
||||
|
||||
|
||||
def build_document(files_content, bibliography):
|
||||
def build_document(files_content, bibliography=None):
|
||||
args = [
|
||||
'-s',
|
||||
]
|
||||
|
|
|
@ -26,8 +26,17 @@ def test_output(config):
|
|||
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):
|
||||
check_required_keys(config)
|
||||
test_output(config)
|
||||
validate_bibliography(config)
|
||||
|
||||
|
||||
|
|
|
@ -3,3 +3,4 @@ output_formats:
|
|||
- html
|
||||
- pdf
|
||||
output_dir: out/
|
||||
bibliography: bib.yaml
|
||||
|
|
Reference in a new issue