Georg Brandl avatar Georg Brandl committed 7542598

#206: Refuse to overwrite an existing master document in sphinx-quickstart.

Comments (0)

Files changed (2)

 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.
 

sphinx/quickstart.py

 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 '
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.