mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Allow build without conf.py using -C command line switch.
This commit is contained in:
parent
7e67cabc88
commit
d7dfb64c0e
3
CHANGES
3
CHANGES
@ -145,6 +145,9 @@ New features added
|
||||
- Added a command-line switch ``-A``: it can be used to supply
|
||||
additional values into the HTML templates.
|
||||
|
||||
- Added a command-line switch ``-C``: if it is given, no configuration
|
||||
file ``conf.py`` is required.
|
||||
|
||||
- Added a distutils command `build_sphinx`: When Sphinx is installed,
|
||||
you can call ``python setup.py build_sphinx`` for projects that have
|
||||
Sphinx documentation, which will build the docs and place them in
|
||||
|
@ -105,6 +105,11 @@ The :program:`sphinx-build` script has several more options:
|
||||
|
||||
.. versionadded:: 0.3
|
||||
|
||||
**-C**
|
||||
Don't look for a configuration file; only take options via the ``-D`` option.
|
||||
|
||||
.. versionadded:: 0.5
|
||||
|
||||
**-D** *setting=value*
|
||||
Override a configuration value set in the :file:`conf.py` file. (The value
|
||||
must be a string value.)
|
||||
|
@ -37,6 +37,7 @@ Options: -b <builder> -- builder to use; default is html
|
||||
(default: outdir/.doctrees)
|
||||
-c <path> -- path where configuration file (conf.py) is located
|
||||
(default: same as sourcedir)
|
||||
-C -- use no config file at all, only -D options
|
||||
-D <setting=value> -- override a setting in configuration
|
||||
-A <name=value> -- pass a value into the templates, for HTML builder
|
||||
-N -- do not do colored output
|
||||
@ -55,13 +56,14 @@ def main(argv):
|
||||
nocolor()
|
||||
|
||||
try:
|
||||
opts, args = getopt.getopt(argv[1:], 'ab:d:c:D:A:NEqP')
|
||||
opts, args = getopt.getopt(argv[1:], 'ab:d:c:CD:A:NEqP')
|
||||
allopts = set(opt[0] for opt in opts)
|
||||
srcdir = confdir = path.abspath(args[0])
|
||||
if not path.isdir(srcdir):
|
||||
print >>sys.stderr, 'Error: Cannot find source directory.'
|
||||
return 1
|
||||
if not path.isfile(path.join(srcdir, 'conf.py')) and \
|
||||
'-c' not in (opt[0] for opt in opts):
|
||||
'-c' not in allopts and '-C' not in allopts:
|
||||
print >>sys.stderr, 'Error: Source directory doesn\'t contain conf.py file.'
|
||||
return 1
|
||||
outdir = path.abspath(args[1])
|
||||
@ -104,6 +106,8 @@ def main(argv):
|
||||
print >>sys.stderr, \
|
||||
'Error: Configuration directory doesn\'t contain conf.py file.'
|
||||
return 1
|
||||
elif opt == '-C':
|
||||
confdir = None
|
||||
elif opt == '-D':
|
||||
try:
|
||||
key, val = val.split('=')
|
||||
|
@ -94,13 +94,15 @@ class Config(object):
|
||||
def __init__(self, dirname, filename, overrides):
|
||||
self.overrides = overrides
|
||||
self.values = Config.config_values.copy()
|
||||
config = {'__file__': path.join(dirname, filename)}
|
||||
olddir = os.getcwd()
|
||||
try:
|
||||
os.chdir(dirname)
|
||||
execfile(config['__file__'], config)
|
||||
finally:
|
||||
os.chdir(olddir)
|
||||
config = {}
|
||||
if dirname is not None:
|
||||
config['__file__'] = path.join(dirname, filename)
|
||||
olddir = os.getcwd()
|
||||
try:
|
||||
os.chdir(dirname)
|
||||
execfile(config['__file__'], config)
|
||||
finally:
|
||||
os.chdir(olddir)
|
||||
self._raw_config = config
|
||||
# these two must be preinitialized because extensions can add their
|
||||
# own config values
|
||||
|
Loading…
Reference in New Issue
Block a user