def get_build_config(config, env_config=None, source_file='readthedocs.yml',
                     source_position=0):
    config['name'] = 'test'
    config['type'] = 'sphinx'
    ret_config = BuildConfig(
        {'output_base': ''},
        config,
        source_file=source_file,
        source_position=source_position)
    ret_config.validate()
    return ret_config
Esempio n. 2
0
def load_yaml_config(version):
    """
    Load a configuration from `readthedocs.yml` file.

    This uses the configuration logic from `readthedocs-build`,
    which will keep parsing consistent between projects.
    """

    checkout_path = version.project.checkout_path(version.slug)
    try:
        config = load_config(
            path=checkout_path,
            env_config={
                'output_base': '',
                'type': 'sphinx',
                'name': version.slug,
            },
        )[0]
    except InvalidConfig:  # This is a subclass of ConfigError, so has to come first
        raise
    except ConfigError:
        config = BuildConfig(
            env_config={},
            raw_config={},
            source_file='empty',
            source_position=0,
        )
    return ConfigWrapper(version=version, yaml_config=config)
Esempio n. 3
0
 def inner(path=None, env_config=None):
     env_config_defaults = {
         'output_base': '',
         'name': '1',
         'type': 'sphinx',
     }
     if env_config is not None:
         env_config_defaults.update(env_config)
     yaml_config = ProjectConfig([
         BuildConfig(env_config_defaults,
                     config,
                     source_file='readthedocs.yml',
                     source_position=0)
     ])
     yaml_config.validate()
     return yaml_config
Esempio n. 4
0
def load_yaml_config(version):
    """
    Load a configuration from `readthedocs.yml` file.

    This uses the configuration logic from `readthedocs-build`, which will keep
    parsing consistent between projects.
    """
    checkout_path = version.project.checkout_path(version.slug)

    # Get build image to set up the python version validation. Pass in the
    # build image python limitations to the loaded config so that the versions
    # can be rejected at validation

    img_name = version.project.container_image or DOCKER_IMAGE
    env_config = {
        'build': {
            'image': img_name,
        }
    }
    img_settings = DOCKER_IMAGE_SETTINGS.get(img_name, None)
    if img_settings:
        env_config.update(img_settings)
        env_config['DOCKER_IMAGE_SETTINGS'] = img_settings

    try:
        sphinx_env_config = env_config.copy()
        sphinx_env_config.update({
            'output_base': '',
            'type': 'sphinx',
            'name': version.slug,
        })
        config = load_config(
            path=checkout_path,
            env_config=sphinx_env_config,
        )[0]
    except InvalidConfig:
        # This is a subclass of ConfigError, so has to come first
        raise
    except ConfigError:
        config = BuildConfig(
            env_config=env_config,
            raw_config={},
            source_file='empty',
            source_position=0,
        )
    return ConfigWrapper(version=version, yaml_config=config)