summaryrefslogtreecommitdiff
path: root/sphinx/apidoc.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/apidoc.py')
-rw-r--r--sphinx/apidoc.py23
1 files changed, 18 insertions, 5 deletions
diff --git a/sphinx/apidoc.py b/sphinx/apidoc.py
index 6891aec1c..58724fd5a 100644
--- a/sphinx/apidoc.py
+++ b/sphinx/apidoc.py
@@ -11,7 +11,7 @@
Copyright 2008 Société des arts technologiques (SAT),
http://www.sat.qc.ca/
- :copyright: Copyright 2007-2015 by the Sphinx team, see AUTHORS.
+ :copyright: Copyright 2007-2016 by the Sphinx team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from __future__ import print_function
@@ -20,6 +20,7 @@ import os
import sys
import optparse
from os import path
+from six import binary_type
from sphinx.util.osutil import walk
from sphinx import __display_version__
@@ -238,7 +239,7 @@ def recurse_tree(rootpath, excludes, opts):
def normalize_excludes(rootpath, excludes):
"""Normalize the excluded directory list."""
- return [path.normpath(path.abspath(exclude)) for exclude in excludes]
+ return [path.abspath(exclude) for exclude in excludes]
def is_excluded(root, excludes):
@@ -247,7 +248,6 @@ def is_excluded(root, excludes):
Note: by having trailing slashes, we avoid common prefix issues, like
e.g. an exlude "foo" also accidentally excluding "foobar".
"""
- root = path.normpath(root)
for exclude in excludes:
if root == exclude:
return True
@@ -328,7 +328,7 @@ Note: By default this script will not overwrite already created files.""")
if not opts.destdir:
parser.error('An output directory is required.')
if opts.header is None:
- opts.header = path.normpath(rootpath).split(path.sep)[-1]
+ opts.header = path.abspath(rootpath).split(path.sep)[-1]
if opts.suffix.startswith('.'):
opts.suffix = opts.suffix[1:]
if not path.isdir(rootpath):
@@ -337,7 +337,7 @@ Note: By default this script will not overwrite already created files.""")
if not path.isdir(opts.destdir):
if not opts.dryrun:
os.makedirs(opts.destdir)
- rootpath = path.normpath(path.abspath(rootpath))
+ rootpath = path.abspath(rootpath)
excludes = normalize_excludes(rootpath, excludes)
modules = recurse_tree(rootpath, excludes, opts)
if opts.full:
@@ -370,7 +370,20 @@ Note: By default this script will not overwrite already created files.""")
mastertoctree = text,
language = 'en',
)
+ if isinstance(opts.header, binary_type):
+ d['project'] = d['project'].decode('utf-8')
+ if isinstance(opts.author, binary_type):
+ d['author'] = d['author'].decode('utf-8')
+ if isinstance(opts.version, binary_type):
+ d['version'] = d['version'].decode('utf-8')
+ if isinstance(opts.release, binary_type):
+ d['release'] = d['release'].decode('utf-8')
+
if not opts.dryrun:
qs.generate(d, silent=True, overwrite=opts.force)
elif not opts.notoc:
create_modules_toc_file(modules, opts)
+
+# So program can be started with "python -m sphinx.apidoc ..."
+if __name__ == "__main__":
+ main()