Skip to content

URL to copy-button.svg is incorrect because DOCUMENTATION_OPTIONS.URL_ROOT is undefined #214

Open
@rhertzog

Description

@rhertzog

Describe the bug

When I build some documentation with sphinx-copybutton 0.4.0 and Sphinx 7.2.6 with a simple "make html" invocation, and when I open the webpage in my local browser, I don't get to see the copy-button.svg icon, instead I see the associated alt text.

When I lookup the HTML, the path to the image is undefined_static/copy-button.svg which obviously doesn't work.

This is a consequence that the generated HTML doesn't define the DOCUMENTATION_OPTIONS.URL_ROOT variable. I have this in head:

<script src="../../../_static/documentation_options.js?v=7f41d439"></script>

And documentation_options.js looks like this:

const DOCUMENTATION_OPTIONS = {
    VERSION: '',
    LANGUAGE: 'en',
    COLLAPSE_INDEX: false,
    BUILDER: 'html',
    FILE_SUFFIX: '.html',
    LINK_SUFFIX: '.html',
    HAS_SOURCE: false,
    SOURCELINK_SUFFIX: '.txt',
    NAVIGATION_WITH_KEYS: false,
    SHOW_SEARCH_SUMMARY: true,
    ENABLE_SEARCH_SHORTCUTS: true,
};

Reproduce the bug

make html
firefox _build/html/index.html

I'm not quite sure what's responsible of generating this URL_ROOT variable... but it looks like that Sphinx is not doing it automatically, maybe some other extensions needs to be enabled? In my doc, the configuration is pretty minimal:

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
    'sphinx.ext.todo',
    'sphinx_copybutton',
]
todo_include_todos = True

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store',
                    '**/_template.rst']


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages.  See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = []

html_copy_source = False

# Disable Python highlighting for literal blocks
highlight_language = "none"

List your environment

Debian unstable with python3-sphinx 7.2.6-3 and python3-sphinx-copybutton 0.4.0-4. The documentation uses the alabaster theme version 0.7.12-1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions