Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rhertzog opened this issue Jan 13, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@rhertzog
Copy link

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.

@rhertzog rhertzog added the bug Something isn't working label Jan 13, 2024
Copy link

welcome bot commented Jan 13, 2024

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 🎉

@rhertzog
Copy link
Author

It looks like a breaking change in Sphinx 7.2.x:
sphinx-doc/sphinx@8e730ae
sphinx-doc/sphinx#11608 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant