Style-sheets aren't copied with the html builder, when doing incremental builds.
http://sphinx-doc.org/latest/extdev/appapi.html#sphinx.application.Sphinx.add_stylesheet
Please describe more detail.
If it was happened when you just update css file after previous make html command, it is current behavior of sphinx. For now, Sphinx doesn't follow timestamps of extra css/js and user custom theme files.
I think this is the issue you describe, it will copy the file correctly for a clean build, but after making some edits - make html wont update to file at the build destination.
OK, I think it's a feature request.
In my short investigation:
Sphinx.add_javascript() has same issue.env.note_dependency() to register them to dependencies.As quick-hack, adding the css and javascript files as dependencies of master_doc.
Maybe it works. (I know it causes waste rebuilding)
Can someone deny or acknowledge that a Sphinx builder, given a set of lines in conf.py
def setup(app)
app.add_stylesheet('styles.css')
Will _never_ copy the files when doing an HTML build?
For anyone struggling with it: I have fixed it by putting styles.css into _static directory and then adding an html_static_path line:
html_static_path = ['_static']
def setup(app):
app.add_stylesheet('styles.css')
I am sorry for spamming the issues of the project with it, but I don't think docs ever mention these two together anywhere, so hard to pin point why it does not work.
The API doc says:
The filename must be relative to the HTML static path , or a full URI with scheme.
http://www.sphinx-doc.org/en/master/extdev/appapi.html#sphinx.application.Sphinx.add_js_file
I think this comment describes it.
I got bitten by this when developing an extension/plugin.
I was doing in the extension's setup:
def setup(app)
app.config.html_static_path.append(glr_path_static())
app.add_stylesheet('gallery.css')
But it was never copying it. I figured, maybe conf.pywill override it, since it includes html_static_path = ['_static'] by default.
And yes, if you add it later on, it does get picked up:
def setup(app)
app.connect('builder-inited', lambda app: app.config.html_static_path.append(glr_path_static()))
app.add_stylesheet('gallery.css')
@maartenbreddels Sphinx does not expect that extensions overrides user configuration.
In addition, your case is not related with this issue. Even with your code, Sphinx does not detect the change of the css file.
@KDMortimer It seems your question is not related with this issue. So please post this question to sphinx-users list; https://groups.google.com/forum/#!forum/sphinx-users .
Thanks,
I have the same problem. If I change only static content and do an incremental build the static content is not copied. Here's a workaround:
Create a handler in conf.py that reports index.rst as outdated. You might need to change index to something else if you don't have an index.rst. It can be any document name without the .rst:
def env_get_outdated(app, env, added, changed, removed):
return ['index']
Then add the handler in setup():
def setup(app):
app.connect('env-get-outdated', env_get_outdated)
After that incremental builds will always rebuild index.rst and the copy will always be done.
Most helpful comment
I have the same problem. If I change only static content and do an incremental build the static content is not copied. Here's a workaround:
Create a handler in
conf.pythat reportsindex.rstas outdated. You might need to changeindexto something else if you don't have anindex.rst. It can be any document name without the.rst:Then add the handler in
setup():After that incremental builds will always rebuild
index.rstand the copy will always be done.