Ejemplo n.º 1
0
def generate_min_dependency_substitutions(app):
    """Generate min dependency substitutions for docs."""
    from sklearn._build_utils.min_dependencies import dependent_packages

    output = StringIO()

    for package, (version, _) in dependent_packages.items():
        package = package.capitalize()
        output.write(f'.. |{package}MinVersion| replace:: {version}')
        output.write('\n')

    output = output.getvalue()

    with (Path('.') / 'min_dependency_substitutions.rst').open('w') as f:
        f.write(output)
Ejemplo n.º 2
0
def generate_min_dependency_table(app):
    """Generate min dependency table for docs."""
    from sklearn._build_utils.min_dependencies import dependent_packages

    # get length of header
    package_header_len = max(len(package)
                             for package in dependent_packages) + 4
    version_header_len = len('Minimum Version') + 4
    tags_header_len = max(
        len(tags) for _, tags in dependent_packages.values()) + 4

    output = StringIO()
    output.write(' '.join([
        '=' * package_header_len, '=' * version_header_len,
        '=' * tags_header_len
    ]))
    output.write('\n')
    dependency_title = "Dependency"
    version_title = "Minimum Version"
    tags_title = "Purpose"

    output.write(f'{dependency_title:<{package_header_len}} '
                 f'{version_title:<{version_header_len}} '
                 f'{tags_title}\n')

    output.write(' '.join([
        '=' * package_header_len, '=' * version_header_len,
        '=' * tags_header_len
    ]))
    output.write('\n')

    for package, (version, tags) in dependent_packages.items():
        output.write(f'{package:<{package_header_len}} '
                     f'{version:<{version_header_len}} '
                     f'{tags}\n')

    output.write(' '.join([
        '=' * package_header_len, '=' * version_header_len,
        '=' * tags_header_len
    ]))
    output.write('\n')
    output = output.getvalue()

    with (Path('.') / 'min_dependency_table.rst').open('w') as f:
        f.write(output)