(ctx, check, format_links)
Validates README files.

    If `check` is specified, only the check will be validated, if check value is 'changed' will only apply to changed
    checks, an 'all' or empty `check` value will validate all README files.
Validates README files.
Validates README files .
def readmes(ctx, check, format_links):
    """Validates README files.

    If `check` is specified, only the check will be validated, if check value is 'changed' will only apply to changed
    checks, an 'all' or empty `check` value will validate all README files.
    """

    repo = ctx.obj['repo_name']

    files_failed = {}
    readme_counter = set()

    integrations = process_checks_option(check, source='integrations', extend_changed=True)
    format_link_script_path = None
    if format_links:
        format_link_dir = TemporaryDirectory()

        with chdir(format_link_dir.name):
            format_link_script_path = os.path.join(format_link_dir.name, "format_link.py")
            create_file("format_link.py")
            download_file(DOCS_LINK_FORMAT_URL, format_link_script_path)

    for integration in integrations:
        display_queue = []
        readme_path = get_readme_file(integration)

        # Validate the README itself
        validate_readme(integration, repo, display_queue, files_failed, readme_counter)

        if display_queue:
            annotate_display_queue(readme_path, display_queue)
            echo_info(f'{integration}:')
            for func, message in display_queue:
                func(message)

        if format_links and format_link_script_path:
            echo_info("Formatting links in {}".format(os.path.basename(readme_path)))
            try:
                run_command(["python", format_link_script_path, "-f", readme_path])
            except Exception as e:
                echo_failure("Unable to format file: {}".format(str(e)), indent=True)

    num_files = len(readme_counter)
    files_failed = len(files_failed)
    files_passed = num_files - files_failed

    if files_failed:
        click.echo()
        echo_failure(f'Files with errors: {files_failed}')

    if files_passed:
        if files_failed:
            echo_success(f'Files valid: {files_passed}')
        else:
            echo_success(f'All {len(readme_counter)} READMEs are valid!')

    if files_failed:
        abort()
def readmes ( ctx , check , format_links ) : repo = ctx . obj [ 'repo_name' ] files_failed = { } readme_counter = set ( ) integrations = process_checks_option ( check , source = 'integrations' , extend_changed = True ) format_link_script_path = None if format_links : format_link_dir = TemporaryDirectory ( ) with chdir ( format_link_dir . name ) : format_link_script_path = os . path . join ( format_link_dir . name , "format_link.py" ) create_file ( "format_link.py" ) download_file ( DOCS_LINK_FORMAT_URL , format_link_script_path ) for integration in integrations : display_queue = [ ] readme_path = get_readme_file ( integration ) # Validate the README itself validate_readme ( integration , repo , display_queue , files_failed , readme_counter ) if display_queue : annotate_display_queue ( readme_path , display_queue ) echo_info ( f'{integration}:' ) for func , message in display_queue : func ( message ) if format_links and format_link_script_path : echo_info ( "Formatting links in {}" . format ( os . path . basename ( readme_path ) ) ) try : run_command ( [ "python" , format_link_script_path , "-f" , readme_path ] ) except Exception as e : echo_failure ( "Unable to format file: {}" . format ( str ( e ) ) , indent = True ) num_files = len ( readme_counter ) files_failed = len ( files_failed ) files_passed = num_files - files_failed if files_failed : click . echo ( ) echo_failure ( f'Files with errors: {files_failed}' ) if files_passed : if files_failed : echo_success ( f'Files valid: {files_passed}' ) else : echo_success ( f'All {len(readme_counter)} READMEs are valid!' ) if files_failed : abort ( )