コード例 #1
0
ファイル: config.py プロジェクト: flashpig/readthedocs.org
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)
コード例 #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)
コード例 #3
0
ファイル: config.py プロジェクト: MarcAir/readthedocs
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)
コード例 #4
0
ファイル: config.py プロジェクト: gmiddlecote/readthedocs.org
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)