Repository: matplotlib/matplotlib
File: lib/matplotlib/sphinxext/plot_directive.py (Python)

Code before:
        entry = entry.strip()
        if len(entry) >= 2:
            mult = entry[:-1]
            srcset[float(mult)] = entry
        else:
            raise ExtensionError(f'srcset argument {entry!r} is invalid.')
    return srcset


def check_output_base_name(env, output_base):
    docname = env.docname

    if '.' in output_base or '/' in output_base:
        raise PlotError(
            f"The image-basename '{output_base}' is invalid. "
            f"It must not contain dots or slashes.")

    for d in env.mpl_plot_image_basenames:
        if output_base in env.mpl_plot_image_basenames[d]:
            if d == docname:
                raise PlotError(
                    f"The image-basename "
                    f"{output_base}' is used multiple times.")
            raise PlotError(f"The image-basename "
                            f"'{output_base}' is used multiple times "
                            f"(it is also used in {env.doc2path(d)}).")

    env.mpl_plot_image_basenames[docname].add(output_base)


def render_figures(code, code_path, output_dir, output_base, context,
                   function_name, config, context_reset=False,
                   close_figs=False,
                   code_includes=None):
    """
    Run a pyplot script and save the images in *output_dir*.

    Save the images under *output_dir* with file names derived from
    *output_base*
    """

    if function_name is not None:
        output_base = f'{output_base}_{function_name}'
    formats = get_plot_formats(config)

    # Try to determine if all images already exist

    is_doctest, code_pieces = _split_code_at_show(code, function_name)
    # Look for single-figure output files first
    img = ImageFile(output_base, output_dir)
    for format, dpi in formats:

Review comment (suggestion):
```suggestion
            raise PlotError(f"The image-basename {output_base!r} is used multiple"
                            f"times (it is also used in {env.doc2path(d)}).")
```

Code after:
    for entry in entries:
        entry = entry.strip()
        if len(entry) >= 2:
            mult = entry[:-1]
            srcset[float(mult)] = entry
        else:
            raise ExtensionError(f'srcset argument {entry!r} is invalid.')
    return srcset


def check_output_base_name(env, output_base):
    docname = env.docname

    if '.' in output_base or '/' in output_base or '\\' in output_base:
        raise PlotError(
            f"The filename-prefix '{output_base}' is invalid. "
            f"It must not contain dots or slashes.")

    for d in env.mpl_plot_image_basenames:
        if output_base in env.mpl_plot_image_basenames[d]:
            if d == docname:
                raise PlotError(
                    f"The filename-prefix {output_base!r} is used multiple times.")
            raise PlotError(f"The filename-prefix {output_base!r} is used multiple"
                            f"times (it is also used in {env.doc2path(d)}).")

    env.mpl_plot_image_basenames[docname].add(output_base)


def render_figures(code, code_path, output_dir, output_base, context,
                   function_name, config, context_reset=False,
                   close_figs=False,
                   code_includes=None):
    """
    Run a pyplot script and save the images in *output_dir*.

    Save the images under *output_dir* with file names derived from
    *output_base*
    """

    if function_name is not None:
        output_base = f'{output_base}_{function_name}'
    formats = get_plot_formats(config)

    # Try to determine if all images already exist

    is_doctest, code_pieces = _split_code_at_show(code, function_name)
    # Look for single-figure output files first
    img = ImageFile(output_base, output_dir)
    for format, dpi in formats:
        if context or out_of_date(code_path, img.filename(format),