|
6 | 6 | from __future__ import division, print_function, unicode_literals
|
7 | 7 |
|
8 | 8 | import os
|
9 |
| -import re |
10 | 9 | from contextlib import contextmanager
|
11 | 10 |
|
12 | 11 | import six
|
|
23 | 22 | validate_bool,
|
24 | 23 | validate_choice,
|
25 | 24 | validate_dict,
|
26 |
| - validate_directory, |
27 | 25 | validate_file,
|
28 | 26 | validate_list,
|
29 | 27 | validate_string,
|
|
44 | 42 |
|
45 | 43 | CONFIG_NOT_SUPPORTED = 'config-not-supported'
|
46 | 44 | VERSION_INVALID = 'version-invalid'
|
47 |
| -BASE_INVALID = 'base-invalid' |
48 |
| -BASE_NOT_A_DIR = 'base-not-a-directory' |
49 | 45 | CONFIG_SYNTAX_INVALID = 'config-syntax-invalid'
|
50 | 46 | CONFIG_REQUIRED = 'config-required'
|
51 |
| -NAME_REQUIRED = 'name-required' |
52 |
| -NAME_INVALID = 'name-invalid' |
53 | 47 | CONF_FILE_REQUIRED = 'conf-file-required'
|
54 | 48 | PYTHON_INVALID = 'python-invalid'
|
55 | 49 | SUBMODULES_INVALID = 'submodules-invalid'
|
@@ -252,12 +246,6 @@ class BuildConfigV1(BuildConfigBase):
|
252 | 246 |
|
253 | 247 | """Version 1 of the configuration file."""
|
254 | 248 |
|
255 |
| - BASE_INVALID_MESSAGE = 'Invalid value for base: {base}' |
256 |
| - BASE_NOT_A_DIR_MESSAGE = '"base" is not a directory: {base}' |
257 |
| - NAME_REQUIRED_MESSAGE = 'Missing key "name"' |
258 |
| - NAME_INVALID_MESSAGE = ( |
259 |
| - 'Invalid name "{name}". Valid values must match {name_re}' |
260 |
| - ) |
261 | 249 | CONF_FILE_REQUIRED_MESSAGE = 'Missing key "conf_file"'
|
262 | 250 | PYTHON_INVALID_MESSAGE = '"python" section must be a mapping.'
|
263 | 251 | PYTHON_EXTRA_REQUIREMENTS_INVALID_MESSAGE = (
|
@@ -295,63 +283,17 @@ def validate(self):
|
295 | 283 | ``readthedocs.yml`` config file if not set
|
296 | 284 | """
|
297 | 285 | # Validate env_config.
|
298 |
| - # TODO: this isn't used |
299 |
| - self._config['output_base'] = self.validate_output_base() |
300 |
| - |
301 | 286 | # Validate the build environment first
|
302 | 287 | # Must happen before `validate_python`!
|
303 | 288 | self._config['build'] = self.validate_build()
|
304 | 289 |
|
305 | 290 | # Validate raw_config. Order matters.
|
306 |
| - # TODO: this isn't used |
307 |
| - self._config['name'] = self.validate_name() |
308 |
| - # TODO: this isn't used |
309 |
| - self._config['base'] = self.validate_base() |
310 | 291 | self._config['python'] = self.validate_python()
|
311 | 292 | self._config['formats'] = self.validate_formats()
|
312 | 293 |
|
313 | 294 | self._config['conda'] = self.validate_conda()
|
314 | 295 | self._config['requirements_file'] = self.validate_requirements_file()
|
315 | 296 |
|
316 |
| - def validate_output_base(self): |
317 |
| - """Validates that ``output_base`` exists and set its absolute path.""" |
318 |
| - assert 'output_base' in self.env_config, ( |
319 |
| - '"output_base" required in "env_config"') |
320 |
| - output_base = os.path.abspath( |
321 |
| - os.path.join( |
322 |
| - self.env_config.get('output_base', self.base_path), |
323 |
| - ) |
324 |
| - ) |
325 |
| - return output_base |
326 |
| - |
327 |
| - def validate_name(self): |
328 |
| - """Validates that name exists.""" |
329 |
| - name = self.raw_config.get('name', None) |
330 |
| - if not name: |
331 |
| - name = self.env_config.get('name', None) |
332 |
| - if not name: |
333 |
| - self.error('name', self.NAME_REQUIRED_MESSAGE, code=NAME_REQUIRED) |
334 |
| - name_re = r'^[-_.0-9a-zA-Z]+$' |
335 |
| - if not re.match(name_re, name): |
336 |
| - self.error( |
337 |
| - 'name', |
338 |
| - self.NAME_INVALID_MESSAGE.format( |
339 |
| - name=name, |
340 |
| - name_re=name_re), |
341 |
| - code=NAME_INVALID) |
342 |
| - |
343 |
| - return name |
344 |
| - |
345 |
| - def validate_base(self): |
346 |
| - """Validates that path is a valid directory.""" |
347 |
| - if 'base' in self.raw_config: |
348 |
| - base = self.raw_config['base'] |
349 |
| - else: |
350 |
| - base = self.base_path |
351 |
| - with self.catch_validation_error('base'): |
352 |
| - base = validate_directory(base, self.base_path) |
353 |
| - return base |
354 |
| - |
355 | 297 | def validate_build(self):
|
356 | 298 | """
|
357 | 299 | Validate the build config settings.
|
@@ -525,21 +467,6 @@ def validate_formats(self):
|
525 | 467 |
|
526 | 468 | return formats
|
527 | 469 |
|
528 |
| - @property |
529 |
| - def name(self): |
530 |
| - """The project name.""" |
531 |
| - return self._config['name'] |
532 |
| - |
533 |
| - @property |
534 |
| - def base(self): |
535 |
| - """The base directory.""" |
536 |
| - return self._config['base'] |
537 |
| - |
538 |
| - @property |
539 |
| - def output_base(self): |
540 |
| - """The output base.""" |
541 |
| - return self._config['output_base'] |
542 |
| - |
543 | 470 | @property
|
544 | 471 | def formats(self):
|
545 | 472 | """The documentation formats to be built."""
|
|
0 commit comments