This commit is contained in:
Armin Ronacher 2011-09-23 00:49:08 +02:00
commit 2a021f1cf9
10 changed files with 91 additions and 29 deletions

27
CHANGES
View File

@ -36,6 +36,7 @@ Features added
multiple terms per definition.
- #478: Added :rst:dir:`py:decorator` directive to describe decorators.
- C++ domain now supports array definitions.
- C++ domain now supports doc fields (``:param x:`` inside directives).
- Section headings in :rst:dir:`only` directives are now correctly
handled.
- Added ``emphasize-lines`` option to source code directives.
@ -111,6 +112,32 @@ Features added
Release 1.0.8 (in development)
==============================
* #720: Add dummy visitors for graphviz nodes for text and man.
* #704: Fix image file duplication bug.
* #677: Fix parsing of multiple signatures in C++ domain.
* #637: Ignore Emacs lock files when looking for source files.
* #544: Allow .pyw extension for importable modules in autodoc.
* #700: Use ``$(MAKE)`` in quickstart-generated Makefiles.
* #734: Make sidebar search box width consistent in browsers.
* #644: Fix spacing of centered figures in HTML output.
* #767: Safely encode SphinxError messages when printing them to
sys.stderr.
* #611: Fix LaTeX output error with a document with no sections but
a link target.
* Correctly treat built-in method descriptors as methods in autodoc.
* #706: Stop monkeypatching the Python textwrap module.
* #657: viewcode now works correctly with source files that have
non-ASCII encoding.

View File

@ -34,6 +34,9 @@ to reStructuredText/Sphinx from other documentation systems.
* Marcin Wojdyr has written a script to convert Docbook to reST with Sphinx
markup; it is at `Google Code <http://code.google.com/p/db2rst/>`_.
* To convert different markups, `Pandoc <http://johnmacfarlane.net/pandoc/>`_ is
a very helpful tool.
Use with other systems
----------------------

View File

@ -162,17 +162,19 @@ class StandaloneHTMLBuilder(Builder):
old_config_hash = old_tags_hash = ''
try:
fp = open(path.join(self.outdir, '.buildinfo'))
version = fp.readline()
if version.rstrip() != '# Sphinx build info version 1':
raise ValueError
fp.readline() # skip commentary
cfg, old_config_hash = fp.readline().strip().split(': ')
if cfg != 'config':
raise ValueError
tag, old_tags_hash = fp.readline().strip().split(': ')
if tag != 'tags':
raise ValueError
fp.close()
try:
version = fp.readline()
if version.rstrip() != '# Sphinx build info version 1':
raise ValueError
fp.readline() # skip commentary
cfg, old_config_hash = fp.readline().strip().split(': ')
if cfg != 'config':
raise ValueError
tag, old_tags_hash = fp.readline().strip().split(': ')
if tag != 'tags':
raise ValueError
finally:
fp.close()
except ValueError:
self.warn('unsupported build info format in %r, building all' %
path.join(self.outdir, '.buildinfo'))

View File

@ -21,6 +21,7 @@ from sphinx.domains import Domain, ObjType
from sphinx.directives import ObjectDescription
from sphinx.util.nodes import make_refnode
from sphinx.util.compat import Directive
from sphinx.util.docfields import Field, GroupedField
_identifier_re = re.compile(r'(~?\b[a-zA-Z_][a-zA-Z0-9_]*)\b')
@ -124,7 +125,7 @@ class DefExpr(object):
return False
try:
for key, value in self.__dict__.iteritems():
if value != getattr(other, value):
if value != getattr(other, key):
return False
except AttributeError:
return False
@ -894,6 +895,17 @@ class DefinitionParser(object):
class CPPObject(ObjectDescription):
"""Description of a C++ language object."""
doc_field_types = [
GroupedField('parameter', label=l_('Parameters'),
names=('param', 'parameter', 'arg', 'argument'),
can_collapse=True),
GroupedField('exceptions', label=l_('Throws'), rolename='cpp:class',
names=('throws', 'throw', 'exception'),
can_collapse=True),
Field('returnvalue', label=l_('Returns'), has_arg=False,
names=('returns', 'return')),
]
def attach_name(self, node, name):
owner, name = name.split_owner()
varname = unicode(name)
@ -1196,7 +1208,7 @@ class CPPDomain(Domain):
node.line)
return None
parent = node['cpp:parent']
parent = node.get('cpp:parent', None)
rv = _create_refnode(expr)
if rv is not None or parent is None:

View File

@ -25,6 +25,7 @@ from docutils import nodes
from docutils.parsers.rst import directives
from sphinx.errors import SphinxError
from sphinx.locale import _
from sphinx.util.osutil import ensuredir, ENOENT, EPIPE, EINVAL
from sphinx.util.compat import Directive
@ -294,11 +295,26 @@ def texinfo_visit_graphviz(self, node):
render_dot_texinfo(self, node, node['code'], node['options'])
def text_visit_graphviz(self, node):
if 'alt' in node.attributes:
self.add_text(_('[graph: %s]') % node['alt'])
self.add_text(_('[graph]'))
def man_visit_graphviz(self, node):
if 'alt' in node.attributes:
self.body.append(_('[graph: %s]') % node['alt'] + '\n')
self.body.append(_('[graph]'))
raise nodes.SkipNode
def setup(app):
app.add_node(graphviz,
html=(html_visit_graphviz, None),
latex=(latex_visit_graphviz, None),
texinfo=(texinfo_visit_graphviz, None))
texinfo=(texinfo_visit_graphviz, None),
text=(text_visit_graphviz, None),
man=(man_visit_graphviz, None))
app.add_directive('graphviz', Graphviz)
app.add_directive('graph', GraphvizSimple)
app.add_directive('digraph', GraphvizSimple)

View File

@ -112,11 +112,11 @@ class FilenameUniqDict(dict):
return uniquename
def purge_doc(self, docname):
for filename, (docs, _) in self.items():
for filename, (docs, unique) in self.items():
docs.discard(docname)
if not docs:
del self[filename]
self._existing.discard(filename)
self._existing.discard(unique)
def __getstate__(self):
return self._existing

View File

@ -196,19 +196,21 @@ class LaTeXTranslator(nodes.NodeVisitor):
lang = babel.get_language()
if lang:
self.elements['classoptions'] += ',' + babel.get_language()
elif builder.config.language == 'ja':
self.elements['classoptions'] += ',dvipdfm'
# not elements of babel, but this should be above sphinx.sty.
# because pTeX (Japanese TeX) cannot handle this count.
self.elements['babel'] = r'\newcount\pdfoutput\pdfoutput=0'
# to make the pdf with correct encoded hyperref bookmarks
self.elements['preamble'] += \
r'\AtBeginDvi{\special{pdf:tounicode EUC-UCS2}}'
else:
self.builder.warn('no Babel option known for language %r' %
builder.config.language)
self.elements['shorthandoff'] = babel.get_shorthandoff()
self.elements['fncychap'] = '\\usepackage[Sonny]{fncychap}'
# pTeX (Japanese TeX) for support
if builder.config.language == 'ja':
self.elements['classoptions'] = ',dvipdfm'
# found elements of babel, but this should be above sphinx.sty.
# because pTeX (Japanese TeX) cannot handle this count.
self.elements['babel'] = r'\newcount\pdfoutput\pdfoutput=0'
# to make the pdf with correct encoded hyperref bookmarks
self.elements['preamble'] += \
r'\AtBeginDvi{\special{pdf:tounicode EUC-UCS2}}'
else:
self.elements['classoptions'] += ',english'
# allow the user to override them all

View File

@ -230,8 +230,8 @@ class ManualPageTranslator(BaseTranslator):
# overwritten -- don't emit a warning for images
def visit_image(self, node):
if 'alt' in node.attributes:
self.body.append('[image: %s]\n' % node['alt'])
self.body.append('[image]\n')
self.body.append(_('[image: %s]') % node['alt'] + '\n')
self.body.append(_('[image]') + '\n')
raise nodes.SkipNode
# overwritten -- don't visit inner marked up nodes

View File

@ -434,6 +434,8 @@ class TextTranslator(nodes.NodeVisitor):
raise nodes.SkipNode
def visit_image(self, node):
if 'alt' in node.attributes:
self.add_text(_('[image: %s]') % node['alt'])
self.add_text(_('[image]'))
raise nodes.SkipNode

View File

@ -169,6 +169,4 @@ CPP domain
.. cpp:class:: n::Array<T,d>
.. cpp:function:: T& operator[]( unsigned j )
.. cpp:function:: const T& operator[]( unsigned j ) const
const T& operator[]( unsigned j ) const