|
7 | 7 |
|
8 | 8 | import copy
|
9 | 9 | import os
|
10 |
| -import re |
11 | 10 | from contextlib import contextmanager
|
12 | 11 |
|
13 | 12 | import six
|
|
33 | 32 | validate_bool,
|
34 | 33 | validate_choice,
|
35 | 34 | validate_dict,
|
36 |
| - validate_directory, |
37 | 35 | validate_file,
|
38 | 36 | validate_list,
|
39 | 37 | validate_string,
|
|
58 | 56 |
|
59 | 57 | CONFIG_NOT_SUPPORTED = 'config-not-supported'
|
60 | 58 | VERSION_INVALID = 'version-invalid'
|
61 |
| -BASE_INVALID = 'base-invalid' |
62 |
| -BASE_NOT_A_DIR = 'base-not-a-directory' |
63 | 59 | CONFIG_SYNTAX_INVALID = 'config-syntax-invalid'
|
64 | 60 | CONFIG_REQUIRED = 'config-required'
|
65 |
| -NAME_REQUIRED = 'name-required' |
66 |
| -NAME_INVALID = 'name-invalid' |
67 | 61 | CONF_FILE_REQUIRED = 'conf-file-required'
|
68 | 62 | PYTHON_INVALID = 'python-invalid'
|
69 | 63 | SUBMODULES_INVALID = 'submodules-invalid'
|
@@ -275,12 +269,6 @@ class BuildConfigV1(BuildConfigBase):
|
275 | 269 |
|
276 | 270 | """Version 1 of the configuration file."""
|
277 | 271 |
|
278 |
| - BASE_INVALID_MESSAGE = 'Invalid value for base: {base}' |
279 |
| - BASE_NOT_A_DIR_MESSAGE = '"base" is not a directory: {base}' |
280 |
| - NAME_REQUIRED_MESSAGE = 'Missing key "name"' |
281 |
| - NAME_INVALID_MESSAGE = ( |
282 |
| - 'Invalid name "{name}". Valid values must match {name_re}' |
283 |
| - ) |
284 | 272 | CONF_FILE_REQUIRED_MESSAGE = 'Missing key "conf_file"'
|
285 | 273 | PYTHON_INVALID_MESSAGE = '"python" section must be a mapping.'
|
286 | 274 | PYTHON_EXTRA_REQUIREMENTS_INVALID_MESSAGE = (
|
@@ -318,63 +306,17 @@ def validate(self):
|
318 | 306 | ``readthedocs.yml`` config file if not set
|
319 | 307 | """
|
320 | 308 | # Validate env_config.
|
321 |
| - # TODO: this isn't used |
322 |
| - self._config['output_base'] = self.validate_output_base() |
323 |
| - |
324 | 309 | # Validate the build environment first
|
325 | 310 | # Must happen before `validate_python`!
|
326 | 311 | self._config['build'] = self.validate_build()
|
327 | 312 |
|
328 | 313 | # Validate raw_config. Order matters.
|
329 |
| - # TODO: this isn't used |
330 |
| - self._config['name'] = self.validate_name() |
331 |
| - # TODO: this isn't used |
332 |
| - self._config['base'] = self.validate_base() |
333 | 314 | self._config['python'] = self.validate_python()
|
334 | 315 | self._config['formats'] = self.validate_formats()
|
335 | 316 |
|
336 | 317 | self._config['conda'] = self.validate_conda()
|
337 | 318 | self._config['requirements_file'] = self.validate_requirements_file()
|
338 | 319 |
|
339 |
| - def validate_output_base(self): |
340 |
| - """Validates that ``output_base`` exists and set its absolute path.""" |
341 |
| - assert 'output_base' in self.env_config, ( |
342 |
| - '"output_base" required in "env_config"') |
343 |
| - output_base = os.path.abspath( |
344 |
| - os.path.join( |
345 |
| - self.env_config.get('output_base', self.base_path), |
346 |
| - ) |
347 |
| - ) |
348 |
| - return output_base |
349 |
| - |
350 |
| - def validate_name(self): |
351 |
| - """Validates that name exists.""" |
352 |
| - name = self.raw_config.get('name', None) |
353 |
| - if not name: |
354 |
| - name = self.env_config.get('name', None) |
355 |
| - if not name: |
356 |
| - self.error('name', self.NAME_REQUIRED_MESSAGE, code=NAME_REQUIRED) |
357 |
| - name_re = r'^[-_.0-9a-zA-Z]+$' |
358 |
| - if not re.match(name_re, name): |
359 |
| - self.error( |
360 |
| - 'name', |
361 |
| - self.NAME_INVALID_MESSAGE.format( |
362 |
| - name=name, |
363 |
| - name_re=name_re), |
364 |
| - code=NAME_INVALID) |
365 |
| - |
366 |
| - return name |
367 |
| - |
368 |
| - def validate_base(self): |
369 |
| - """Validates that path is a valid directory.""" |
370 |
| - if 'base' in self.raw_config: |
371 |
| - base = self.raw_config['base'] |
372 |
| - else: |
373 |
| - base = self.base_path |
374 |
| - with self.catch_validation_error('base'): |
375 |
| - base = validate_directory(base, self.base_path) |
376 |
| - return base |
377 |
| - |
378 | 320 | def validate_build(self):
|
379 | 321 | """
|
380 | 322 | Validate the build config settings.
|
@@ -417,12 +359,6 @@ def validate_build(self):
|
417 | 359 | self.env_config.update(
|
418 | 360 | DOCKER_IMAGE_SETTINGS[build['image']]
|
419 | 361 | )
|
420 |
| - # Update docker settings from user config |
421 |
| - if 'DOCKER_IMAGE_SETTINGS' in self.env_config and \ |
422 |
| - build['image'] in self.env_config['DOCKER_IMAGE_SETTINGS']: |
423 |
| - self.env_config.update( |
424 |
| - self.env_config['DOCKER_IMAGE_SETTINGS'][build['image']] |
425 |
| - ) |
426 | 362 |
|
427 | 363 | # Allow to override specific project
|
428 | 364 | config_image = self.defaults.get('build_image')
|
@@ -556,21 +492,6 @@ def validate_formats(self):
|
556 | 492 |
|
557 | 493 | return formats
|
558 | 494 |
|
559 |
| - @property |
560 |
| - def name(self): |
561 |
| - """The project name.""" |
562 |
| - return self._config['name'] |
563 |
| - |
564 |
| - @property |
565 |
| - def base(self): |
566 |
| - """The base directory.""" |
567 |
| - return self._config['base'] |
568 |
| - |
569 |
| - @property |
570 |
| - def output_base(self): |
571 |
| - """The output base.""" |
572 |
| - return self._config['output_base'] |
573 |
| - |
574 | 495 | @property
|
575 | 496 | def formats(self):
|
576 | 497 | """The documentation formats to be built."""
|
|
0 commit comments