diff --git a/docs/user-guide/configuration.md b/docs/user-guide/configuration.md index 76652fe0..40f45196 100644 --- a/docs/user-guide/configuration.md +++ b/docs/user-guide/configuration.md @@ -181,8 +181,8 @@ up. Lets you set the directory containing the documentation source markdown files. This can either be a relative directory, in which case it is resolved relative -to the directory containing you configuration file, or it can be an absolute -directory path. +to the directory containing your configuration file, or it can be an absolute +directory path from the root of your local file system. **default**: `'docs'` @@ -190,8 +190,8 @@ directory path. Lets you set the directory where the output HTML and other files are created. This can either be a relative directory, in which case it is resolved relative -to the directory containing you configuration file, or it can be an absolute -directory path. +to the directory containing your configuration file, or it can be an absolute +directory path from the root of your local file system. **default**: `'site'` diff --git a/mkdocs/config/config_options.py b/mkdocs/config/config_options.py index 7fa3ac6f..d5e656fd 100644 --- a/mkdocs/config/config_options.py +++ b/mkdocs/config/config_options.py @@ -253,14 +253,14 @@ class SiteDir(Dir): # Validate that the docs_dir and site_dir don't contain the # other as this will lead to copying back and forth on each # and eventually make a deep nested mess. - if (config['docs_dir'] + os.sep).startswith(config['site_dir'] + os.sep): + if (config['docs_dir'] + os.sep).startswith(config['site_dir'].rstrip(os.sep) + os.sep): raise ValidationError( ("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'] + os.sep).startswith(config['docs_dir'] + os.sep): + elif (config['site_dir'] + os.sep).startswith(config['docs_dir'].rstrip(os.sep) + os.sep): raise ValidationError( ("The 'site_dir' should not be within the 'docs_dir' as this " "leads to the build directory being copied into itself and " diff --git a/mkdocs/tests/config/config_options_tests.py b/mkdocs/tests/config/config_options_tests.py index b4f12734..041dd21b 100644 --- a/mkdocs/tests/config/config_options_tests.py +++ b/mkdocs/tests/config/config_options_tests.py @@ -228,6 +228,7 @@ class SiteDirTest(unittest.TestCase): {'docs_dir': 'docs', 'site_dir': ''}, {'docs_dir': '', 'site_dir': ''}, {'docs_dir': j('..', parent_dir, 'docs'), 'site_dir': 'docs'}, + {'docs_dir': 'docs', 'site_dir': '/'} ) for test_config in test_configs: @@ -242,6 +243,7 @@ class SiteDirTest(unittest.TestCase): {'docs_dir': 'docs', 'site_dir': j('docs', 'site')}, {'docs_dir': '.', 'site_dir': 'site'}, {'docs_dir': '', 'site_dir': 'site'}, + {'docs_dir': '/', 'site_dir': 'site'}, ) for test_config in test_configs: