diff options
author | Shirou WAKAYAMA <shirou.faw@gmail.com> | 2015-03-12 22:52:05 +0900 |
---|---|---|
committer | shimizukawa <shimizukawa@gmail.com> | 2015-03-14 10:51:59 +0900 |
commit | 6a922877bf582757b0249d1ea28ff765adf02982 (patch) | |
tree | 1e15bb0dd681fd06821ee548ee42d813e9bc449e /sphinx/quickstart.py | |
parent | 8f26544dc53dba3622050bb37e937d1ce0597c6c (diff) | |
download | sphinx-git-6a922877bf582757b0249d1ea28ff765adf02982.tar.gz |
allows some files/dirs in quickstart destination dir.
* add _static, _templates, source and master file with suffix.
* add check about files under 'source' along with 'sep' is specified or not.
Diffstat (limited to 'sphinx/quickstart.py')
-rw-r--r-- | sphinx/quickstart.py | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py index 64bbfc34e..fa83a3509 100644 --- a/sphinx/quickstart.py +++ b/sphinx/quickstart.py @@ -1403,6 +1403,32 @@ For more information, visit <http://sphinx-doc.org/>. """ +def valid_dir(d): + dir = d['path'] + if not path.exists(dir): + return True + if not path.isdir(dir): + return False + + invalid_dirs = ['Makefile', 'make.bat'] + if set(invalid_dirs) & set(os.listdir(dir)): + return False + + master = d['master'] + suffix = d['suffix'] + source = ['_static', '_templates', 'conf.py', master+suffix] + if d['sep']: + dir = os.path.join('source', dir) + if not path.exists(dir): + return True + if not path.isdir(dir): + return False + if set(source) & set(os.listdir(dir)): + return False + + return True + + class MyFormatter(optparse.IndentedHelpFormatter): def format_usage(self, usage): return usage @@ -1512,11 +1538,10 @@ def main(argv=sys.argv): if 'no_batchfile' in d: d['batchfile'] = False - if path.exists(d['path']) and ( - not path.isdir(d['path']) or os.listdir(d['path'])): + if not valid_dir(d): print() - print(bold('Error: specified path is not a directory, or not a' - ' empty directory.')) + print(bold('Error: specified path is not a directory, or sphinx' + ' files already exist.')) print('sphinx-quickstart only generate into a empty directory.' ' Please specify a new root path.') return |