diff --git a/docs/about/release-notes.md b/docs/about/release-notes.md index e3739110..6a040e05 100644 --- a/docs/about/release-notes.md +++ b/docs/about/release-notes.md @@ -229,8 +229,9 @@ authors should review how [search and themes] interact. [search config]: ../user-guide/configuration.md#search [search and themes]: ../user-guide/custom-themes.md#search_and_themes -### Other Changes and Additions to Development Version +### Other Changes and Additions to Version 1.0 +* Empty `extra_css` and `extra_javascript` settings no longer raise a warning. * Add highlight.js configuration settings to built-in themes (#1284). * Close search modal when result is selected (#1527). * Add a level attribute to AnchorLinks (#1272). @@ -404,7 +405,7 @@ and user created and third-party templates should be updated as outlined below: In previous versions of MkDocs, if the `extra_css` or `extra_javascript` config settings were empty, MkDocs would scan the `docs_dir` and auto-populate each setting with all of the CSS and JavaScript files found. On version 0.16 this -behavior was deprecated and a warning was issued. In 1.0 any unlisted CSS and +behavior was deprecated and a warning was issued. In 0.17 any unlisted CSS and JavaScript files will not be included in the HTML templates, however, a warning will be issued. In other words, they will still be copied to the `site-dir`, but they will not have any effect on the theme if they are not explicitly listed. diff --git a/mkdocs/config/config_options.py b/mkdocs/config/config_options.py index a631da7e..a4fd5c42 100644 --- a/mkdocs/config/config_options.py +++ b/mkdocs/config/config_options.py @@ -462,62 +462,6 @@ class Theme(BaseConfigOption): config[key_name] = theme.Theme(**theme_config) -class Extras(OptionallyRequired): - """ - Extras Config Option - - Validate the extra configs are a list and issue a warning for any files - found in the docs_dir which are not listed here. - - TODO: Delete this in a future release and use - `config_options.Type(list, default=[])` instead. - """ - - def __init__(self, file_match=None, **kwargs): - super(Extras, self).__init__(**kwargs) - self.file_match = file_match - - def run_validation(self, value): - if isinstance(value, list): - return value - else: - raise ValidationError( - "Expected a list, got {0}".format(type(value))) - - def walk_docs_dir(self, docs_dir): - if self.file_match is None: - raise StopIteration - - for (dirpath, dirs, filenames) in os.walk(docs_dir, followlinks=True): - dirs.sort() - for filename in sorted(filenames): - fullpath = os.path.join(dirpath, filename) - - # Some editors (namely Emacs) will create temporary symlinks - # for internal magic. We can just ignore these files. - if os.path.islink(fullpath): - local_fullpath = os.path.join(dirpath, os.readlink(fullpath)) - if not os.path.exists(local_fullpath): - continue - - relpath = os.path.normpath(os.path.relpath(fullpath, docs_dir)) - if self.file_match(relpath): - yield relpath - - def post_validation(self, config, key_name): - # Only issue warnings for missing files if the setting is empty - # as autopopulating only used to work if the setting was empty. - if not config[key_name]: - actual_files = list(self.walk_docs_dir(config['docs_dir'])) - if actual_files: - self.warnings.append(( - "Some files in your 'docs_dir' are not listed in the '{0}' " - "config setting and will be ignored by the theme. Add the " - "following files to the '{0}' config setting if you want " - "them to have an effect on the theme: ['{1}']" - ).format(key_name, "', '".join(actual_files))) - - class Nav(OptionallyRequired): """ Nav Config Option diff --git a/mkdocs/config/defaults.py b/mkdocs/config/defaults.py index 99600b3b..0ec7391b 100644 --- a/mkdocs/config/defaults.py +++ b/mkdocs/config/defaults.py @@ -81,9 +81,8 @@ DEFAULT_SCHEMA = ( # Specify which css or javascript files from the docs directory should be # additionally included in the site. - ('extra_css', config_options.Extras(file_match=utils.is_css_file, default=[])), - ('extra_javascript', config_options.Extras( - file_match=utils.is_javascript_file, default=[])), + ('extra_css', config_options.Type(list, default=[])), + ('extra_javascript', config_options.Type(list, default=[])), # Similar to the above, but each template (HTML or XML) will be build with # Jinja2 and the global context. diff --git a/mkdocs/utils/__init__.py b/mkdocs/utils/__init__.py index f94defe2..8ee33424 100644 --- a/mkdocs/utils/__init__.py +++ b/mkdocs/utils/__init__.py @@ -193,27 +193,6 @@ def is_markdown_file(path): return any(fnmatch.fnmatch(path.lower(), '*{0}'.format(x)) for x in markdown_extensions) -def is_css_file(path): - """ - Return True if the given file path is a CSS file. - """ - ext = os.path.splitext(path)[1].lower() - return ext in [ - '.css', - ] - - -def is_javascript_file(path): - """ - Return True if the given file path is a Javascript file. - """ - ext = os.path.splitext(path)[1].lower() - return ext in [ - '.js', - '.javascript' - ] - - def is_html_file(path): """ Return True if the given file path is an HTML file.