Issue #569 resolved

When copying html_static_path over theme it overwrites whole directories

Ilkka Hakkari avatarIlkka Hakkari created an issue

Sphinx has config variable html_static_path which is a list of directories and files which should be overwriting the ones in the theme static directory.

I had files in theme/static/img/foo.jpg and wanted to add more files there from source/_static/img/bar.jpg so that the resulting _static dir would have all files. But that didn't happen. Instead the theme/static/img dir was completely overwritten with my source/_static/img dir.

I searched thru the code and found this:

Sphinx-1.0.5-py2.6.egg/sphinx/util/__init__.py:
158         else:
159             target = path.join(targetdir, path.basename(source))
160             if path.exists(target):
161                 shutil.rmtree(target)
162             shutil.copytree(source, target)

I can try to create a patch for this, if the current behavior is not by design and actually a bug.

I think the correct behavior should be to only handle files in the whole directory tree.

Comments (2)

  1. Georg Brandl

    The problem is that if the previous directory is not removed, old static files that have been removed from the source will linger around in the build directory. I'm therefore tempted to call this behavior by design.

    If the theme wants to supply overridable images, it should get a theme option that specifies the file path of the image.

  2. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.