merge with trunk

This commit is contained in:
Georg Brandl
2010-02-17 10:49:53 +01:00
11 changed files with 3097 additions and 1694 deletions

View File

@@ -15,6 +15,8 @@ Release 1.0 (in development)
* Added ``html-collect-pages`` event.
* Sphinx now requires Jinja2 version 2.2 or greater.
* Added ``needs_sphinx`` config value and ``Sphinx.require_sphinx``
application API function.
@@ -103,6 +105,9 @@ Release 1.0 (in development)
Release 0.6.5 (in development)
==============================
* Make the ``start-after`` and ``end-before`` options to the
``literalinclude`` directive work correctly if not used together.
* #321: Fix link generation in the LaTeX builder.

View File

@@ -53,7 +53,8 @@ Documentation using the default theme
Documentation using a customized version of the default theme
-------------------------------------------------------------
* Advanced Generic Widgets: http://xoomer.virgilio.it/infinity77/AGW_Docs/index.html
* Advanced Generic Widgets:
http://xoomer.virgilio.it/infinity77/AGW_Docs/index.html
* Bazaar: http://doc.bazaar.canonical.com/en/
* Chaco: http://code.enthought.com/projects/chaco/docs/html/
* Djagios: http://djagios.org/
@@ -69,6 +70,7 @@ Documentation using a customized version of the default theme
* PyLit: http://pylit.berlios.de/
* Sage: http://sagemath.org/doc/
* SciPy: http://docs.scipy.org/doc/scipy/reference/
* simuPOP: http://simupop.sourceforge.net/manual_release/build/userGuide.html
* Sprox: http://sprox.org/
* TurboGears: http://turbogears.org/2.0/docs/
* Zope: http://docs.zope.org/zope2/index.html
@@ -84,7 +86,8 @@ Documentation using the sphinxdoc theme
* MyHDL: http://www.myhdl.org/doc/0.6/
* NetworkX: http://networkx.lanl.gov/
* Pysparse: http://pysparse.sourceforge.net/
* PyTango: http://www.tango-controls.org/static/PyTango/latest/doc/html/index.html
* PyTango:
http://www.tango-controls.org/static/PyTango/latest/doc/html/index.html
* Reteisi: http://docs.argolinux.org/reteisi/
* Satchmo: http://www.satchmoproject.com/docs/svn/
* Sphinx: http://sphinx.pocoo.org/
@@ -99,7 +102,10 @@ Documentation using another builtin theme
* Distribute: http://packages.python.org/distribute/ (nature)
* Jinja: http://jinja.pocoo.org/2/documentation/ (scrolls)
* pip: http://pip.openplans.org/ (nature)
* sqlparse: http://python-sqlparse.googlecode.com/svn/docs/api/index.html (agogo)
* Programmieren mit PyGTK und Glade (German):
http://www.florian-diesch.de/doc/python-und-glade/online/ (agogo)
* sqlparse: http://python-sqlparse.googlecode.com/svn/docs/api/index.html
(agogo)
Documentation using a custom theme/integrated in a site

View File

@@ -40,7 +40,7 @@ A development egg can be found `here
<http://bitbucket.org/birkenfeld/sphinx/get/tip.gz#egg=Sphinx-dev>`_.
'''
requires = ['Pygments>=0.8', 'Jinja2>=2.1', 'docutils>=0.4']
requires = ['Pygments>=0.8', 'Jinja2>=2.2', 'docutils>=0.4']
if sys.version_info < (2, 4):
print 'ERROR: Sphinx requires at least Python 2.4 to run.'

View File

@@ -159,9 +159,9 @@ class LiteralInclude(Directive):
use = not startafter
res = []
for line in lines:
if not use and startafter in line:
if not use and startafter and startafter in line:
use = True
elif use and endbefore in line:
elif use and endbefore and endbefore in line:
use = False
break
elif use:

View File

@@ -106,14 +106,15 @@ def process_todo_nodes(app, doctree, fromdocname):
for todo_info in env.todo_all_todos:
para = nodes.paragraph(classes=['todo-source'])
filename = env.doc2path(todo_info['docname'], base=None)
description = (
_('(The original entry is located in %s, line %d and '
'can be found ') % (filename, todo_info['lineno']))
para += nodes.Text(description, description)
description = _('(The <<original entry>> is located in '
' %s, line %d.)') % (filename, todo_info['lineno'])
desc1 = description[:description.find('<<')]
desc2 = description[description.find('>>')+2:]
para += nodes.Text(desc1, desc1)
# Create a reference
newnode = nodes.reference('', '')
innernode = nodes.emphasis(_('here'), _('here'))
innernode = nodes.emphasis(_('original entry'), _('original entry'))
newnode['refdocname'] = todo_info['docname']
try:
newnode['refuri'] = app.builder.get_relative_uri(
@@ -124,7 +125,7 @@ def process_todo_nodes(app, doctree, fromdocname):
pass
newnode.append(innernode)
para += newnode
para += nodes.Text('.)', '.)')
para += nodes.Text(desc2, desc2)
# (Recursively) resolve references in the todo content
todo_entry = todo_info['todo']

View File

@@ -298,8 +298,8 @@ if __name__ == '__main__':
import time, pprint
x0 = time.time()
#ma = ModuleAnalyzer.for_file(__file__.rstrip('c'), 'sphinx.builders.html')
ma = ModuleAnalyzer.for_file('sphinx/builders/html.py',
'sphinx.builders.html')
ma = ModuleAnalyzer.for_file('sphinx/environment.py',
'sphinx.environment')
ma.tokenize()
x1 = time.time()
ma.parse()

File diff suppressed because it is too large Load Diff

View File

@@ -29,9 +29,16 @@ class ParseError(Exception):
cdef class Parser:
cdef public grammar, stack, rootnode, used_names
cdef _grammar_dfas, _grammar_labels, _grammar_keywords, _grammar_tokens
cdef _grammar_number2symbol
cdef public object grammar
cdef public object rootnode
cdef public list stack
cdef public set used_names
cdef int _grammar_start
cdef list _grammar_labels
cdef dict _grammar_dfas
cdef dict _grammar_keywords
cdef dict _grammar_tokens
cdef dict _grammar_number2symbol
def __init__(self, grammar, convert=None):
self.grammar = grammar
@@ -42,10 +49,11 @@ cdef class Parser:
self._grammar_keywords = grammar.keywords
self._grammar_tokens = grammar.tokens
self._grammar_number2symbol = grammar.number2symbol
self._grammar_start = grammar.start
def setup(self, start=None):
if start is None:
start = self.grammar.start
start = self._grammar_start
# Each stack entry is a tuple: (dfa, state, node).
# A node is a tuple: (type, value, context, children),
# where children is a list of nodes or None, and context may be None.
@@ -55,7 +63,7 @@ cdef class Parser:
self.rootnode = None
self.used_names = set() # Aliased to self.rootnode.used_names in pop()
def addtoken(self, type, value, context):
def addtoken(self, int type, value, context):
"""Add a token; return True iff this is the end of the program."""
cdef int ilabel, i, t, state, newstate
# Map from token to label
@@ -104,22 +112,21 @@ cdef class Parser:
# No success finding a transition
raise ParseError("bad input", type, value, context)
cdef int classify(self, type, value, context):
cdef int classify(self, int type, value, context):
"""Turn a token into a label. (Internal)"""
if type == NAME:
# Keep a listing of all used names
self.used_names.add(value)
# Check for reserved words
ilabel = self._grammar_keywords.get(value)
if ilabel is not None:
return ilabel
ilabel = self._grammar_tokens.get(type)
if ilabel is None:
if value in self._grammar_keywords:
return self._grammar_keywords[value]
if type not in self._grammar_tokens:
raise ParseError("bad token", type, value, context)
return ilabel
return self._grammar_tokens[type]
cdef void shift(self, type, value, newstate, context):
"""Shift a token. (Internal)"""
cdef tuple node
dfa, state, node = self.stack[-1]
newnode = (type, value, context, None)
newnode = self.convert(newnode)
@@ -146,7 +153,7 @@ cdef class Parser:
self.rootnode = newnode
self.rootnode.used_names = self.used_names
cdef convert(self, raw_node):
cdef convert(self, tuple raw_node):
type, value, context, children = raw_node
if children or type in self._grammar_number2symbol:
# If there's exactly one child, return that child instead of

View File

@@ -41,14 +41,18 @@ class BuildDoc(Command):
self.conf_file_name = 'conf.py'
self.builder = 'html'
def _guess_source_dir(self):
for guess in ('doc', 'docs'):
if not os.path.isdir(guess):
continue
for root, dirnames, filenames in os.walk(guess):
if 'conf.py' in filenames:
return root
def finalize_options(self):
if self.source_dir is None:
if os.path.isdir('doc'):
for root, dirnames, filenames in os.walk('doc'):
if 'conf.py' in filenames:
self.source_dir = root
self.announce('Using source directory %s' % root)
break
self.source_dir = self._guess_source_dir()
self.announce('Using source directory %s' % self.source_dir)
self.ensure_dirname('source_dir')
self.source_dir = os.path.abspath(self.source_dir)

View File

@@ -13,6 +13,8 @@
{%- endblock %}
{%- set reldelim1 = reldelim1 is not defined and ' &raquo;' or reldelim1 %}
{%- set reldelim2 = reldelim2 is not defined and ' |' or reldelim2 %}
{%- set render_sidebar = (not embedded) and (not theme_nosidebar|tobool) and
(not sidebars == []) %}
{%- macro relbar() %}
<div class="related">
@@ -36,7 +38,7 @@
{%- endmacro %}
{%- macro sidebar() %}
{%- if not embedded %}{% if not theme_nosidebar|tobool %}
{%- if render_sidebar %}
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
{%- block sidebarlogo %}
@@ -46,7 +48,7 @@
</a></p>
{%- endif %}
{%- endblock %}
{%- if sidebars %}
{%- if sidebars != None %}
{#- new style sidebar: explicitly include/exclude templates #}
{%- for sidebartemplate in sidebars %}
{%- include sidebartemplate %}
@@ -71,7 +73,7 @@
{%- endif %}
</div>
</div>
{%- endif %}{% endif %}
{%- endif %}
{%- endmacro %}
<html xmlns="http://www.w3.org/1999/xhtml">
@@ -150,15 +152,15 @@
<div class="document">
{%- block document %}
<div class="documentwrapper">
{%- if not embedded %}{% if not theme_nosidebar|tobool %}
{%- if render_sidebar %}
<div class="bodywrapper">
{%- endif %}{% endif %}
{%- endif %}
<div class="body">
{% block body %} {% endblock %}
</div>
{%- if not embedded %}{% if not theme_nosidebar|tobool %}
{%- if render_sidebar %}
</div>
{%- endif %}{% endif %}
{%- endif %}
</div>
{%- endblock %}

View File

@@ -49,6 +49,12 @@ Literalinclude options
:prepend: START CODE
:append: END CODE
.. literalinclude:: literal.inc
:start-after: utf-8
.. literalinclude:: literal.inc
:end-before: class Foo
.. cssclass:: inc-tab3
.. literalinclude:: tabs.inc
:tab-width: 3