mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merged revisions 64714-64715,64720,64723 via svnmerge from
svn+ssh://pythondev@svn.python.org/doctools/branches/0.4.x ........ r64714 | georg.brandl | 2008-07-04 21:19:02 +0200 (Fri, 04 Jul 2008) | 3 lines Allow the usage of :noindex: in "automodule" directives, as documented. ........ r64715 | georg.brandl | 2008-07-04 21:30:22 +0200 (Fri, 04 Jul 2008) | 2 lines Fix the delete() docstring processor function. ........ r64720 | georg.brandl | 2008-07-05 12:04:41 +0200 (Sat, 05 Jul 2008) | 2 lines Fix warning for nonexisting images. ........ r64723 | georg.brandl | 2008-07-05 12:21:42 +0200 (Sat, 05 Jul 2008) | 2 lines Fix JS search in IE. ........
This commit is contained in:
@@ -138,7 +138,7 @@ class Builder(object):
|
||||
break
|
||||
else:
|
||||
self.warn('%s:%s: no matching candidate for image URI %r' %
|
||||
(node.source, node.lineno, node['uri']))
|
||||
(node.source, getattr(node, 'lineno', ''), node['uri']))
|
||||
continue
|
||||
node['uri'] = candidate
|
||||
else:
|
||||
|
||||
@@ -83,6 +83,7 @@ def module_directive(name, arguments, options, content, lineno,
|
||||
content_offset, block_text, state, state_machine):
|
||||
env = state.document.settings.env
|
||||
modname = arguments[0].strip()
|
||||
noindex = 'noindex' in options
|
||||
env.currmodule = modname
|
||||
env.note_module(modname, options.get('synopsis', ''),
|
||||
options.get('platform', ''),
|
||||
@@ -100,13 +101,15 @@ def module_directive(name, arguments, options, content, lineno,
|
||||
node += nodes.Text(options['platform'], options['platform'])
|
||||
ret.append(node)
|
||||
# the synopsis isn't printed; in fact, it is only used in the modindex currently
|
||||
env.note_index_entry('single', '%s (module)' % modname, 'module-' + modname,
|
||||
modname)
|
||||
if not noindex:
|
||||
env.note_index_entry('single', '%s (module)' % modname,
|
||||
'module-' + modname, modname)
|
||||
return ret
|
||||
|
||||
module_directive.arguments = (1, 0, 0)
|
||||
module_directive.options = {'platform': lambda x: x,
|
||||
'synopsis': lambda x: x,
|
||||
'noindex': directives.flag,
|
||||
'deprecated': directives.flag}
|
||||
directives.register_directive('module', module_directive)
|
||||
|
||||
|
||||
@@ -113,25 +113,33 @@ def cut_lines(pre, post=0, what=None):
|
||||
del lines[-post:]
|
||||
return process
|
||||
|
||||
def between(marker, what=None):
|
||||
def between(marker, what=None, keepempty=False):
|
||||
"""
|
||||
Return a listener that only keeps lines between the first two lines that
|
||||
match the *marker* regular expression. If *what* is a sequence of strings,
|
||||
only docstrings of a type in *what* will be processed.
|
||||
Return a listener that only keeps lines between lines that match the
|
||||
*marker* regular expression. If no line matches, the resulting docstring
|
||||
would be empty, so no change will be made unless *keepempty* is true.
|
||||
|
||||
If *what* is a sequence of strings, only docstrings of a type in *what* will
|
||||
be processed.
|
||||
"""
|
||||
marker_re = re.compile(marker)
|
||||
def process(app, what_, name, obj, options, lines):
|
||||
if what and what_ not in what:
|
||||
return
|
||||
seen = 0
|
||||
for i, line in enumerate(lines[:]):
|
||||
deleted = 0
|
||||
delete = True
|
||||
orig_lines = lines[:]
|
||||
for i, line in enumerate(orig_lines):
|
||||
if delete:
|
||||
lines.pop(i - deleted)
|
||||
deleted += 1
|
||||
if marker_re.match(line):
|
||||
if not seen:
|
||||
del lines[:i+1]
|
||||
seen = i+1
|
||||
else:
|
||||
del lines[i-seen:]
|
||||
break
|
||||
delete = not delete
|
||||
if delete:
|
||||
lines.pop(i - deleted)
|
||||
deleted += 1
|
||||
if not lines and not keepempty:
|
||||
lines[:] = orig_lines
|
||||
return process
|
||||
|
||||
|
||||
@@ -526,7 +534,10 @@ def _auto_directive(dirname, arguments, options, content, lineno,
|
||||
def auto_directive(*args, **kwds):
|
||||
return _auto_directive(*args, **kwds)
|
||||
|
||||
def auto_directive_withmembers(*args, **kwds):
|
||||
def automodule_directive(*args, **kwds):
|
||||
return _auto_directive(*args, **kwds)
|
||||
|
||||
def autoclass_directive(*args, **kwds):
|
||||
return _auto_directive(*args, **kwds)
|
||||
|
||||
|
||||
@@ -542,11 +553,11 @@ def setup(app):
|
||||
cls_options = {'members': members_option, 'undoc-members': directives.flag,
|
||||
'noindex': directives.flag, 'inherited-members': directives.flag,
|
||||
'show-inheritance': directives.flag}
|
||||
app.add_directive('automodule', auto_directive_withmembers,
|
||||
app.add_directive('automodule', automodule_directive,
|
||||
1, (1, 0, 1), **mod_options)
|
||||
app.add_directive('autoclass', auto_directive_withmembers,
|
||||
app.add_directive('autoclass', autoclass_directive,
|
||||
1, (1, 0, 1), **cls_options)
|
||||
app.add_directive('autoexception', auto_directive_withmembers,
|
||||
app.add_directive('autoexception', autoclass_directive,
|
||||
1, (1, 0, 1), **cls_options)
|
||||
app.add_directive('autofunction', auto_directive, 1, (1, 0, 1),
|
||||
noindex=directives.flag)
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT: '{{ pathto("", 1) }}',
|
||||
VERSION: '{{ release }}',
|
||||
COLLAPSE_MODINDEX: false,
|
||||
COLLAPSE_MODINDEX: false
|
||||
};
|
||||
</script>
|
||||
<script type="text/javascript" src="{{ pathto('_static/jquery.js', 1) }}"></script>
|
||||
|
||||
Reference in New Issue
Block a user