Unexpected template and source code files deployed to site_dir #807
Comments
Good spot. I don't think this is actually a problem, so it is a low priority issue but we should try to resolve it. The tricky thing to realise is, how do we determine which assets should and shouldn't be copied from a theme? |
This is a problem under some specific (but not very unusual) conditions, e.g.:
The gratuitous
|
Okay, wow. That is an unfortunate set of coincidences. In that case, yes it is a problem. A simple fix to never copy Python files from a theme's source would probably do the job. |
All media files (non markdown and template files) are copied using the mkdocs.utils.copy_media_files function. We can easily add a line to have it also exclude python files, but I'm thinking we only want to exclude python files from the theme dir, not from the docs_dir. After all, a user could have a python source file they want to host for some reason (presumably with a download link pointing to it in their docs). However, in the code, copying the themes and copying the media files in the docs_dir is not really differentiated. We could add an |
Yeah, ideally we would refactor this a bit and make it smarter. Maybe we create a class that represents a media directory, then a subclass of it could represent a theme - initially that would just exclude Python files, but later it might do more. ... but I am just thinking "out loud", so I've not thought that through fully. |
Right. My thoughts as well. We could do a quick fix ( |
I confirm that it can even be worse than masking the |
It occurs to me that we could require themes to actually be in a subdirectory of the directory which contains the So a theme would look like this:
Of course, to do that, all the existing themes would need to be updated and the change would be backward incompatible. However, if such a change were to be made, it should be done now before more third party themes are developed. Note that this would not effect the |
Or maybe at least check that the target directory is not already in the python path and display a warning about that? |
Hmm, interesting. I just noticed that the OP also reported that the template files ( |
Fixes mkdocs#807. Used the fnmatch lib which supports Unix shell-style wildcard patterns (not regex). This allows patterns like `'.*py'`, `'.*'`, etc. A list of excluded patterns are passed to `mkdocs.utils.copy_media_files`. The pattern `'.*'` is included by default and not overidable.
Fixes mkdocs#807. Used the fnmatch lib which supports Unix shell-style wildcard patterns (not regex). This allows patterns like `'.*py'`, `'.*'`, etc. A list of excluded patterns are passed to `mkdocs.utils.copy_media_files`. The pattern `'.*'` is included by default and not overidable.
I don't think anyone has the time for working on the the refactor mentioned above anytime soon. Therefore, I pushed a quick fix to #880 which implements the Note that the issue with template (HTML) files being copied was introduced in d5f95f2 as a fix for #691. The problem is that that fix should only apply to files in the |
This avoids conflicts with the `html` Python standard library package due to mkdocs/mkdocs#807 in older MkDocs versions. But mostly, it's more clear, anyway.
After upgrading to 0.15.0, the following files get deployed to the
site_dir
after build:From the
gh-pages
branch, you can see the last clean commit is:https://github.com/mkdocs/mkdocs/tree/6b7615eee095c8ccd47a106ca29f2f12314d86f5
The most recent commit has the above files included:
https://github.com/mkdocs/mkdocs/tree/ffe467ab2352ec3a0f690024bd908b7dea0443fc
The text was updated successfully, but these errors were encountered: