From 76db7375752a575fdb6d8a473ec8bad8d3748fd6 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Thu, 20 Oct 2016 16:31:30 +0300 Subject: [PATCH 1/2] Add new option to allow override pdflatex binary Any pdflatex-compatible binary could be used instead. For example, xelatex (as requested in rtfd/readthedocs.org#1556). --- readthedocs_build/config/config.py | 9 +++++++++ readthedocs_build/config/test_config.py | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/readthedocs_build/config/config.py b/readthedocs_build/config/config.py index 7d695a0..aa5d1c2 100644 --- a/readthedocs_build/config/config.py +++ b/readthedocs_build/config/config.py @@ -155,6 +155,8 @@ def validate(self): self.validate_requirements_file() self.validate_conf_file() + self.validate_pdflatex() + def validate_output_base(self): assert 'output_base' in self.env_config, ( '"output_base" required in "env_config"') @@ -291,6 +293,13 @@ def validate_conda(self): self['conda'] = conda + def validate_pdflatex(self): + if 'pdflatex' not in self.raw_config: + self['pdflatex'] = validate_string('pdflatex') + else: + with self.catch_validation_error('pdflatex'): + self['pdflatex'] = validate_string(self.raw_config['pdflatex']) + def validate_requirements_file(self): if 'requirements_file' not in self.raw_config: return None diff --git a/readthedocs_build/config/test_config.py b/readthedocs_build/config/test_config.py index 5fc04f6..52d392b 100644 --- a/readthedocs_build/config/test_config.py +++ b/readthedocs_build/config/test_config.py @@ -204,6 +204,25 @@ def it_uses_validate_string(validate_string): validate_string.assert_any_call('tests') +def describe_validate_pdflatex(): + def it_defaults_to_pdflatex(): + build = get_build_config({'python': {}}) + build.validate_pdflatex() + assert build['pdflatex'] == 'pdflatex' + + def it_validates_is_a_string(): + build = get_build_config({'pdflatex': ['invalid']}) + with raises(InvalidConfig) as excinfo: + build.validate_pdflatex() + assert excinfo.value.key == 'pdflatex' + assert excinfo.value.code == INVALID_STRING + + def it_gets_set_correctly(): + build = get_build_config({'pdflatex': 'xelatex'}) + build.validate_pdflatex() + assert build['pdflatex'] == 'xelatex' + + def describe_validate_use_system_site_packages(): def it_defaults_to_false(): build = get_build_config({'python': {}}) From 62ad5b31fe99c9fdf19048cb00b42effaa738a01 Mon Sep 17 00:00:00 2001 From: Sergey B Kirpichev Date: Thu, 9 Feb 2017 12:01:17 +0400 Subject: [PATCH 2/2] Drop useless validate_string --- readthedocs_build/config/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readthedocs_build/config/config.py b/readthedocs_build/config/config.py index aa5d1c2..63c8e69 100644 --- a/readthedocs_build/config/config.py +++ b/readthedocs_build/config/config.py @@ -295,7 +295,7 @@ def validate_conda(self): def validate_pdflatex(self): if 'pdflatex' not in self.raw_config: - self['pdflatex'] = validate_string('pdflatex') + self['pdflatex'] = 'pdflatex' else: with self.catch_validation_error('pdflatex'): self['pdflatex'] = validate_string(self.raw_config['pdflatex'])