From d70b03609059ac8984d4de78de2d66ed32bb3157 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Thu, 9 Jul 2009 12:23:54 +0200 Subject: [PATCH] #206: Refuse to overwrite an existing master document in sphinx-quickstart. --- CHANGES | 3 +++ sphinx/quickstart.py | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/CHANGES b/CHANGES index 9da56a621..6c6da9acc 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ Release 0.6.3 (in development) ============================== +* #206: Refuse to overwrite an existing master document in + sphinx-quickstart. + * #208: Use MS-sanctioned locale settings, determined by the ``language`` config option, in the HTML help builder. diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py index 575a96839..4a3c453d9 100644 --- a/sphinx/quickstart.py +++ b/sphinx/quickstart.py @@ -592,6 +592,17 @@ of the documents. Normally, this is "index", but if your "index" document is a custom template, you can also set this to another filename.''' do_prompt(d, 'master', 'Name of your master document (without suffix)', 'index') + + while path.isfile(path.join(d['path'], d['master']+d['suffix'])) or \ + path.isfile(path.join(d['path'], 'source', d['master']+d['suffix'])): + print + print bold('Error: the master file %s has already been found in the ' + 'selected root path.' % (d['master']+d['suffix'])) + print 'sphinx-quickstart will not overwrite the existing file.' + print + do_prompt(d, 'master', 'Please enter a new file name, or rename the ' + 'existing file and press Enter', d['master']) + print ''' Please indicate if you want to use one of the following Sphinx extensions:''' do_prompt(d, 'ext_autodoc', 'autodoc: automatically insert docstrings '