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

Files from _static are not copied automatically #1810

Closed
martin-ueding opened this issue Mar 25, 2015 · 15 comments · Fixed by #13236
Closed

Files from _static are not copied automatically #1810

martin-ueding opened this issue Mar 25, 2015 · 15 comments · Fixed by #13236

Comments

@martin-ueding
Copy link

I have a bunch of files in _static and in _themes/mu/static that do not get copied when I compile:

PYTHONPATH=. /usr/share/sphinx/scripts/python3/sphinx-build -q -b html -d _build/doctrees/en -c _config/en . _build/html/en

In my project, I generate a .css file from a .sass file with a makefile and then call the above. The new .css file from the _themes/mu/static is not copied. When I do a clean build, everything is copied, but the change detection that Sphinx Doc uses seems to be insufficient.

@szabolcsdombi
Copy link

Have you found the answer?

@martin-ueding
Copy link
Author

Not really, I just have a Makefile that then copies those files for me. Not really nice, but it seems to work.

@tk0miya
Copy link
Member

tk0miya commented Feb 11, 2017 via email

@szabolcsdombi
Copy link

szabolcsdombi commented Feb 11, 2017

added 2 lines to the conf.py

def setup(app):
    app.add_stylesheet('css/custom.css')

copy works fine with the css files

source/_static/css/custom.css is copied to the build/html/_static/css/custom.css

@tk0miya
Copy link
Member

tk0miya commented Feb 13, 2017

add_stylesheet() has same problem: #2090.

@ghost
Copy link

ghost commented Aug 21, 2017

any resolution on this?

@tk0miya tk0miya added this to the 2.0 milestone Jan 31, 2018
@tk0miya tk0miya modified the milestones: 2.0.0, 2.1.0 Feb 8, 2019
@tk0miya tk0miya modified the milestones: 2.1.0, 3.0.0 May 31, 2019
@tk0miya tk0miya modified the milestones: 3.0.0, 3.1.0 Mar 14, 2020
@im-n1
Copy link

im-n1 commented Mar 26, 2020

Just ran into this. I consider this quite important. Here is my real world example.

Imagine you document an UI kit. For every component you document you create and example HTML which you include with iframe (.. raw:: directive) because you need a separated DOM for custom styles and JS. Then you place this HTML into a file under _static folder and you refer to it like <iframe src="_static/example.html"></iframe>. Now it's part of your documentation just like any other rst file.

Static files needs to be copied automatically (or at least a new CLI swith to turn this functionality on) in certain cases.

@tk0miya tk0miya modified the milestones: 3.1.0, 3.2.0 May 30, 2020
@tk0miya tk0miya modified the milestones: 3.2.0, 3.3.0 Aug 1, 2020
@tk0miya tk0miya modified the milestones: 3.3.0, 4.0.0 Oct 27, 2020
@tk0miya tk0miya modified the milestones: 4.0.0, 5.0.0 Apr 17, 2021
@basnijholt
Copy link

@im-n1, I ran into this issue too in python-adaptive/adaptive#329.

Did you find a workaround?

@pradyunsg
Copy link
Contributor

pradyunsg commented Oct 13, 2021

From https://github.com/executablebooks/sphinx-autobuild/#relevant-sphinx-bugs:

At the time of writing, the only known workaround is to instruct Sphinx to rebuild the relevant pages. This can be done by disabling incremental mode (with -a) or passing relevant filenames in addition to source and output directory in the CLI.

@tk0miya tk0miya modified the milestones: 5.0.0, 5.x Apr 3, 2022
@AA-Turner AA-Turner modified the milestones: 5.x, some future version May 23, 2022
@pradyunsg
Copy link
Contributor

@AA-Turner what change in Sphinx fixed this? I wanted to add a reference when closing the sphinx-autobuild issue, but couldn't figure out what the relevant issue is.

@AA-Turner
Copy link
Member

This didn't have a reproducer, but a cursory investigation indicates that copy_html_static_files should copy all of the files (except those with a leading .) from html_static_path to outdir/_static.

There may be something I'm missing?

A

@pradyunsg
Copy link
Contributor

pradyunsg commented Aug 12, 2023

This isn't static files from html_static_path, but rather from the theme.

A reproducer would be to:

  • build a Sphinx documentation as html
  • modify the HTML theme to have a red background in body
  • Build again
  • The rebuilt site doesn't have any rendering changes
  • Add a new page
  • Build again
  • The site's new page will be rendered with the new red background.

Sphinx has an assumption that the theme wouldn't be modified, which means what modifying the theme isn't reflected in the build results.

@pradyunsg
Copy link
Contributor

pradyunsg commented Aug 12, 2023

FWIW, this is relatively easy to hit during theme development with sphinx-autobuild which... as you'd expect, involves modifying theme files a lot. :)

@pradyunsg
Copy link
Contributor

Adding a cross-reference to #2090, which is somewhat related (albeit for stylesheets).

@Sieboldianus
Copy link

FWIW, this is relatively easy to hit during theme development with sphinx-autobuild which... as you'd expect, involves modifying theme files a lot. :)

Like me.. the solution currently is to delete the _build folder entirely after updating custom.css (e.g.) and then rebuilding manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants