mirror of
https://github.com/mkdocs/mkdocs.git
synced 2026-03-27 09:58:31 +07:00
If the site_dir is within the docs_dir, display a warning not an error
This commit is contained in:
@@ -13,6 +13,12 @@ You can determine your currently installed version using `mkdocs --version`:
|
||||
$ mkdocs --version
|
||||
mkdocs, version 0.13.0
|
||||
|
||||
## Version 0.13.3 (2015-06-02)
|
||||
|
||||
* Bugfix: Reduce validation error from to a warning if the site_dir is within
|
||||
the docs_dir as this shouldn't cause any problems with building but will
|
||||
inconvenience users building multiple times. (#580)
|
||||
|
||||
## Version 0.13.2 (2015-05-30)
|
||||
|
||||
* Bugfix: Ensure all errors and warnings are logged before exiting. (#536)
|
||||
@@ -21,7 +27,7 @@ You can determine your currently installed version using `mkdocs --version`:
|
||||
## Version 0.13.1 (2015-05-27)
|
||||
|
||||
* Bugfix: Fix a problem with minimal configurations which only contain a list
|
||||
of paths in the pages config (#562)
|
||||
of paths in the pages config. (#562)
|
||||
|
||||
|
||||
## Version 0.13.0 (2015-05-26)
|
||||
|
||||
@@ -231,10 +231,18 @@ class SiteDir(Dir):
|
||||
# and eventually make a deep nested mess.
|
||||
if config['docs_dir'].startswith(config['site_dir']):
|
||||
raise ValidationError(
|
||||
"The 'docs_dir' can't be within the 'site_dir'.")
|
||||
("The 'docs_dir' should not be within the 'site_dir' as this "
|
||||
"can mean the source files are overwritten by the output or "
|
||||
"it will be deleted if --clean is passed to mkdocs build."
|
||||
"(site_dir: '{0}', docs_dir: '{1}')"
|
||||
).format(config['site_dir'], config['docs_dir']))
|
||||
elif config['site_dir'].startswith(config['docs_dir']):
|
||||
raise ValidationError(
|
||||
"The 'site_dir' can't be within the 'docs_dir'.")
|
||||
self.warnings.append(
|
||||
("The 'site_dir' should not be within the 'docs_dir' as this "
|
||||
"leads to the build directory being copied into itself and "
|
||||
"duplicate nested files in the 'site_dir'."
|
||||
"(site_dir: '{0}', docs_dir: '{1}')"
|
||||
).format(config['site_dir'], config['docs_dir']))
|
||||
|
||||
|
||||
class ThemeDir(Dir):
|
||||
|
||||
@@ -175,13 +175,10 @@ class SiteDirTest(unittest.TestCase):
|
||||
docs_dir = config_options.Dir()
|
||||
|
||||
test_configs = (
|
||||
{'docs_dir': 'docs', 'site_dir': j('docs', 'site')},
|
||||
{'docs_dir': j('site', 'docs'), 'site_dir': 'site'},
|
||||
{'docs_dir': 'docs', 'site_dir': '.'},
|
||||
{'docs_dir': '.', 'site_dir': 'site'},
|
||||
{'docs_dir': '.', 'site_dir': '.'},
|
||||
{'docs_dir': 'docs', 'site_dir': ''},
|
||||
{'docs_dir': '', 'site_dir': 'site'},
|
||||
{'docs_dir': '', 'site_dir': ''},
|
||||
{'docs_dir': j('..', 'mkdocs', 'docs'), 'site_dir': 'docs'},
|
||||
)
|
||||
@@ -194,6 +191,30 @@ class SiteDirTest(unittest.TestCase):
|
||||
self.assertRaises(config_options.ValidationError,
|
||||
option.post_validation, test_config, 'key')
|
||||
|
||||
def test_site_dir_in_docs_dir(self):
|
||||
|
||||
j = os.path.join
|
||||
|
||||
test_configs = (
|
||||
{'docs_dir': 'docs', 'site_dir': j('docs', 'site')},
|
||||
{'docs_dir': '.', 'site_dir': 'site'},
|
||||
{'docs_dir': '', 'site_dir': 'site'},
|
||||
)
|
||||
|
||||
for test_config in test_configs:
|
||||
|
||||
docs_dir = config_options.Dir()
|
||||
option = config_options.SiteDir()
|
||||
|
||||
test_config['docs_dir'] = docs_dir.validate(test_config['docs_dir'])
|
||||
test_config['site_dir'] = option.validate(test_config['site_dir'])
|
||||
|
||||
option.post_validation(test_config, 'key')
|
||||
self.assertEqual(len(option.warnings), 1)
|
||||
self.assertEqual(
|
||||
option.warnings[0][:50],
|
||||
"The 'site_dir' should not be within the 'docs_dir'")
|
||||
|
||||
|
||||
class ThemeTest(unittest.TestCase):
|
||||
|
||||
|
||||
@@ -175,13 +175,10 @@ class ConfigTests(unittest.TestCase):
|
||||
j = os.path.join
|
||||
|
||||
test_configs = (
|
||||
{'docs_dir': 'docs', 'site_dir': j('docs', 'site')},
|
||||
{'docs_dir': j('site', 'docs'), 'site_dir': 'site'},
|
||||
{'docs_dir': 'docs', 'site_dir': '.'},
|
||||
{'docs_dir': '.', 'site_dir': 'site'},
|
||||
{'docs_dir': '.', 'site_dir': '.'},
|
||||
{'docs_dir': 'docs', 'site_dir': ''},
|
||||
{'docs_dir': '', 'site_dir': 'site'},
|
||||
{'docs_dir': '', 'site_dir': ''},
|
||||
{'docs_dir': j('..', 'mkdocs', 'docs'), 'site_dir': 'docs'},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user