mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
autosummary: make information messages prettier
This commit is contained in:
parent
4f2525874d
commit
d307369122
@ -412,11 +412,10 @@ def process_generate_options(app):
|
|||||||
from sphinx.ext.autosummary.generate import generate_autosummary_docs
|
from sphinx.ext.autosummary.generate import generate_autosummary_docs
|
||||||
|
|
||||||
ext = app.config.source_suffix
|
ext = app.config.source_suffix
|
||||||
genfiles = [path.join(app.srcdir, genfile +
|
genfiles = [genfile + (not genfile.endswith(ext) and ext or '')
|
||||||
(not genfile.endswith(ext) and ext or ''))
|
|
||||||
for genfile in genfiles]
|
for genfile in genfiles]
|
||||||
generate_autosummary_docs(genfiles, warn=app.warn, info=app.info,
|
generate_autosummary_docs(genfiles, warn=app.warn, info=app.info,
|
||||||
suffix=ext)
|
suffix=ext, base_path=app.srcdir)
|
||||||
|
|
||||||
|
|
||||||
def setup(app):
|
def setup(app):
|
||||||
|
@ -52,7 +52,7 @@ def _simple_info(msg):
|
|||||||
print msg
|
print msg
|
||||||
|
|
||||||
def _simple_warn(msg):
|
def _simple_warn(msg):
|
||||||
print >>sys.stderr, 'WARNING: ' + msg
|
print >> sys.stderr, 'WARNING: ' + msg
|
||||||
|
|
||||||
# -- Generating output ---------------------------------------------------------
|
# -- Generating output ---------------------------------------------------------
|
||||||
|
|
||||||
@ -60,10 +60,17 @@ def _simple_warn(msg):
|
|||||||
env = Environment(loader=PackageLoader('sphinx.ext.autosummary', 'templates'))
|
env = Environment(loader=PackageLoader('sphinx.ext.autosummary', 'templates'))
|
||||||
|
|
||||||
def generate_autosummary_docs(sources, output_dir=None, suffix='.rst',
|
def generate_autosummary_docs(sources, output_dir=None, suffix='.rst',
|
||||||
warn=_simple_warn, info=_simple_info):
|
warn=_simple_warn, info=_simple_info,
|
||||||
info('generating autosummary for: %s' % ', '.join(sources))
|
base_path=None):
|
||||||
|
|
||||||
|
info('[autosummary] generating autosummary for: %s' %
|
||||||
|
', '.join(sorted(sources)))
|
||||||
|
|
||||||
if output_dir:
|
if output_dir:
|
||||||
info('writing to %s' % output_dir)
|
info('[autosummary] writing to %s' % output_dir)
|
||||||
|
|
||||||
|
if base_path is not None:
|
||||||
|
sources = [os.path.join(base_path, filename) for filename in sources]
|
||||||
|
|
||||||
# read
|
# read
|
||||||
names = {}
|
names = {}
|
||||||
@ -81,7 +88,7 @@ def generate_autosummary_docs(sources, output_dir=None, suffix='.rst',
|
|||||||
try:
|
try:
|
||||||
obj, name = import_by_name(name)
|
obj, name = import_by_name(name)
|
||||||
except ImportError, e:
|
except ImportError, e:
|
||||||
warn('failed to import %r: %s' % (name, e))
|
warn('[autosummary] failed to import %r: %s' % (name, e))
|
||||||
continue
|
continue
|
||||||
|
|
||||||
fn = os.path.join(path, name + suffix)
|
fn = os.path.join(path, name + suffix)
|
||||||
|
Loading…
Reference in New Issue
Block a user