diff options
| author | Georg Brandl <georg@python.org> | 2009-09-03 18:25:54 +0200 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2009-09-03 18:25:54 +0200 |
| commit | c816d7defda99496824b8eabf66bc909e4b50f49 (patch) | |
| tree | 0f24e0fc1fad9e19af93f6ec84b0ee2a543a9919 /sphinx | |
| parent | adcb3f5072cf97df8329ca5f962d09d94345939c (diff) | |
| parent | 90feb78ace5ced952d80c7e14ed632521873032f (diff) | |
| download | sphinx-c816d7defda99496824b8eabf66bc909e4b50f49.tar.gz | |
merge with trunk
Diffstat (limited to 'sphinx')
| -rw-r--r-- | sphinx/builders/htmlhelp.py | 1 | ||||
| -rw-r--r-- | sphinx/directives/other.py | 5 | ||||
| -rw-r--r-- | sphinx/ext/graphviz.py | 7 | ||||
| -rw-r--r-- | sphinx/ext/todo.py | 11 | ||||
| -rw-r--r-- | sphinx/locale/it/LC_MESSAGES/sphinx.po | 2 | ||||
| -rw-r--r-- | sphinx/quickstart.py | 92 | ||||
| -rw-r--r-- | sphinx/util/__init__.py | 21 |
7 files changed, 73 insertions, 66 deletions
diff --git a/sphinx/builders/htmlhelp.py b/sphinx/builders/htmlhelp.py index ea47da55..58eaeca9 100644 --- a/sphinx/builders/htmlhelp.py +++ b/sphinx/builders/htmlhelp.py @@ -138,6 +138,7 @@ chm_locales = { 'ru': (0x419, 'cp1251'), 'sl': (0x424, 'iso8859_2'), 'uk_UA': (0x422, 'cp1251'), + 'zh_CN': (0x804, 'cp936'), 'zh_TW': (0x404, 'cp950'), } diff --git a/sphinx/directives/other.py b/sphinx/directives/other.py index ed42e3d2..225c1816 100644 --- a/sphinx/directives/other.py +++ b/sphinx/directives/other.py @@ -14,7 +14,8 @@ from docutils.parsers.rst import directives from sphinx import addnodes from sphinx.locale import pairindextypes -from sphinx.util import patfilter, ws_re, caption_ref_re, url_re, docname_join +from sphinx.util import patfilter, ws_re, url_re, docname_join, \ + explicit_title_re from sphinx.util.compat import Directive, directive_dwim, make_admonition @@ -55,7 +56,7 @@ class TocTree(Directive): continue if not glob: # look for explicit titles ("Some Title <document>") - m = caption_ref_re.match(entry) + m = explicit_title_re.match(entry) if m: ref = m.group(2) title = m.group(1) diff --git a/sphinx/ext/graphviz.py b/sphinx/ext/graphviz.py index a5a7c92a..1b6a03ee 100644 --- a/sphinx/ext/graphviz.py +++ b/sphinx/ext/graphviz.py @@ -50,8 +50,13 @@ class Graphviz(Directive): option_spec = {} def run(self): + dotcode = '\n'.join(self.content) + if not dotcode.strip(): + return [self.state_machine.reporter.warning( + 'Ignoring "graphviz" directive without content.', + line=self.lineno)] node = graphviz() - node['code'] = '\n'.join(self.content) + node['code'] = dotcode node['options'] = [] return [node] diff --git a/sphinx/ext/todo.py b/sphinx/ext/todo.py index 2bea562a..249fb361 100644 --- a/sphinx/ext/todo.py +++ b/sphinx/ext/todo.py @@ -14,6 +14,7 @@ from docutils import nodes +from sphinx.environment import NoUri from sphinx.util.compat import Directive, make_admonition class todo_node(nodes.Admonition, nodes.Element): pass @@ -104,9 +105,13 @@ def process_todo_nodes(app, doctree, fromdocname): newnode = nodes.reference('', '') innernode = nodes.emphasis(_('here'), _('here')) newnode['refdocname'] = todo_info['docname'] - newnode['refuri'] = app.builder.get_relative_uri( - fromdocname, todo_info['docname']) - newnode['refuri'] += '#' + todo_info['target']['refid'] + try: + newnode['refuri'] = app.builder.get_relative_uri( + fromdocname, todo_info['docname']) + newnode['refuri'] += '#' + todo_info['target']['refid'] + except NoUri: + # ignore if no URI can be determined, e.g. for LaTeX output + pass newnode.append(innernode) para += newnode para += nodes.Text('.)', '.)') diff --git a/sphinx/locale/it/LC_MESSAGES/sphinx.po b/sphinx/locale/it/LC_MESSAGES/sphinx.po index c72bda27..ec240872 100644 --- a/sphinx/locale/it/LC_MESSAGES/sphinx.po +++ b/sphinx/locale/it/LC_MESSAGES/sphinx.po @@ -460,7 +460,7 @@ msgstr "© Copyright %(copyright)s." #: sphinx/themes/basic/layout.html:193 #, python-format msgid "Last updated on %(last_updated)s." -msgstr "Ultimo Aggiornamento on %(last_updated)s." +msgstr "Ultimo aggiornamento %(last_updated)s." #: sphinx/themes/basic/layout.html:196 #, python-format diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py index 0df0979d..c2446924 100644 --- a/sphinx/quickstart.py +++ b/sphinx/quickstart.py @@ -262,11 +262,12 @@ MAKEFILE = '''\ SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = +BUILDDIR = %(rbuilddir)s # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d %(rbuilddir)s/doctrees $(PAPEROPT_$(PAPER)) \ +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) \ $(SPHINXOPTS) %(rsrcdir)s .PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes \ @@ -289,42 +290,42 @@ help: (if enabled)" clean: -\t-rm -rf %(rbuilddir)s/* +\t-rm -rf $(BUILDDIR)/* html: -\t$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) %(rbuilddir)s/html +\t$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html \t@echo -\t@echo "Build finished. The HTML pages are in %(rbuilddir)s/html." +\t@echo "Build finished. The HTML pages are in $(BUILDDIR)/html." dirhtml: -\t$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) %(rbuilddir)s/dirhtml +\t$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml \t@echo -\t@echo "Build finished. The HTML pages are in %(rbuilddir)s/dirhtml." +\t@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." pickle: -\t$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) %(rbuilddir)s/pickle +\t$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle \t@echo \t@echo "Build finished; now you can process the pickle files." json: -\t$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) %(rbuilddir)s/json +\t$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json \t@echo \t@echo "Build finished; now you can process the JSON files." htmlhelp: -\t$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) %(rbuilddir)s/htmlhelp +\t$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp \t@echo \t@echo "Build finished; now you can run HTML Help Workshop with the" \\ -\t ".hhp project file in %(rbuilddir)s/htmlhelp." +\t ".hhp project file in $(BUILDDIR)/htmlhelp." qthelp: -\t$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) %(rbuilddir)s/qthelp +\t$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp \t@echo \t@echo "Build finished; now you can run "qcollectiongenerator" with the" \\ -\t ".qhcp project file in %(rbuilddir)s/qthelp, like this:" -\t@echo "# qcollectiongenerator %(rbuilddir)s/qthelp/%(project_fn)s.qhcp" +\t ".qhcp project file in $(BUILDDIR)/qthelp, like this:" +\t@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/%(project_fn)s.qhcp" \t@echo "To view the help file:" -\t@echo "# assistant -collectionFile %(rbuilddir)s/qthelp/%(project_fn)s.qhc" +\t@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/%(project_fn)s.qhc" devhelp: \t$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) %(rbuilddir)s/devhelp @@ -337,9 +338,9 @@ $$HOME/.local/share/devhelp/%(project_fn)s" \t@echo "# devhelp" latex: -\t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) %(rbuilddir)s/latex +\t$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex \t@echo -\t@echo "Build finished; the LaTeX files are in %(rbuilddir)s/latex." +\t@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." \t@echo "Run \\`make all-pdf' or \\`make all-ps' in that directory to" \\ \t "run these through (pdf)latex." @@ -350,20 +351,20 @@ latexpdf: latex \t@echo "pdflatex finished; the PDF files are in %(rbuilddir)s/latex." changes: -\t$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) %(rbuilddir)s/changes +\t$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes \t@echo -\t@echo "The overview file is in %(rbuilddir)s/changes." +\t@echo "The overview file is in $(BUILDDIR)/changes." linkcheck: -\t$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) %(rbuilddir)s/linkcheck +\t$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck \t@echo \t@echo "Link check complete; look for any errors in the above output " \\ -\t "or in %(rbuilddir)s/linkcheck/output.txt." +\t "or in $(BUILDDIR)/linkcheck/output.txt." doctest: -\t$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) %(rbuilddir)s/doctest +\t$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest \t@echo "Testing of doctests in the sources finished, look at the " \\ -\t "results in %(rbuilddir)s/doctest/output.txt." +\t "results in $(BUILDDIR)/doctest/output.txt." ''' BATCHFILE = '''\ @@ -372,7 +373,8 @@ BATCHFILE = '''\ REM Command file for Sphinx documentation set SPHINXBUILD=sphinx-build -set ALLSPHINXOPTS=-d %(rbuilddir)s/doctrees %%SPHINXOPTS%% %(rsrcdir)s +set BUILDDIR=%(rbuilddir)s +set ALLSPHINXOPTS=-d %%BUILDDIR%%/doctrees %%SPHINXOPTS%% %(rsrcdir)s if NOT "%%PAPER%%" == "" ( \tset ALLSPHINXOPTS=-D latex_paper_size=%%PAPER%% %%ALLSPHINXOPTS%% ) @@ -397,55 +399,55 @@ if "%%1" == "help" ( ) if "%%1" == "clean" ( -\tfor /d %%%%i in (%(rbuilddir)s\*) do rmdir /q /s %%%%i -\tdel /q /s %(rbuilddir)s\* +\tfor /d %%%%i in (%%BUILDDIR%%\*) do rmdir /q /s %%%%i +\tdel /q /s %%BUILDDIR%%\* \tgoto end ) if "%%1" == "html" ( -\t%%SPHINXBUILD%% -b html %%ALLSPHINXOPTS%% %(rbuilddir)s/html +\t%%SPHINXBUILD%% -b html %%ALLSPHINXOPTS%% %%BUILDDIR%%/html \techo. -\techo.Build finished. The HTML pages are in %(rbuilddir)s/html. +\techo.Build finished. The HTML pages are in %%BUILDDIR%%/html. \tgoto end ) if "%%1" == "dirhtml" ( -\t%%SPHINXBUILD%% -b dirhtml %%ALLSPHINXOPTS%% %(rbuilddir)s/dirhtml +\t%%SPHINXBUILD%% -b dirhtml %%ALLSPHINXOPTS%% %%BUILDDIR%%/dirhtml \techo. -\techo.Build finished. The HTML pages are in %(rbuilddir)s/dirhtml. +\techo.Build finished. The HTML pages are in %%BUILDDIR%%/dirhtml. \tgoto end ) if "%%1" == "pickle" ( -\t%%SPHINXBUILD%% -b pickle %%ALLSPHINXOPTS%% %(rbuilddir)s/pickle +\t%%SPHINXBUILD%% -b pickle %%ALLSPHINXOPTS%% %%BUILDDIR%%/pickle \techo. \techo.Build finished; now you can process the pickle files. \tgoto end ) if "%%1" == "json" ( -\t%%SPHINXBUILD%% -b json %%ALLSPHINXOPTS%% %(rbuilddir)s/json +\t%%SPHINXBUILD%% -b json %%ALLSPHINXOPTS%% %%BUILDDIR%%/json \techo. \techo.Build finished; now you can process the JSON files. \tgoto end ) if "%%1" == "htmlhelp" ( -\t%%SPHINXBUILD%% -b htmlhelp %%ALLSPHINXOPTS%% %(rbuilddir)s/htmlhelp +\t%%SPHINXBUILD%% -b htmlhelp %%ALLSPHINXOPTS%% %%BUILDDIR%%/htmlhelp \techo. \techo.Build finished; now you can run HTML Help Workshop with the ^ -.hhp project file in %(rbuilddir)s/htmlhelp. +.hhp project file in %%BUILDDIR%%/htmlhelp. \tgoto end ) if "%%1" == "qthelp" ( -\t%%SPHINXBUILD%% -b qthelp %%ALLSPHINXOPTS%% %(rbuilddir)s/qthelp +\t%%SPHINXBUILD%% -b qthelp %%ALLSPHINXOPTS%% %%BUILDDIR%%/qthelp \techo. \techo.Build finished; now you can run "qcollectiongenerator" with the ^ -.qhcp project file in %(rbuilddir)s/qthelp, like this: -\techo.^> qcollectiongenerator %(rbuilddir)s\\qthelp\\%(project_fn)s.qhcp +.qhcp project file in %%BUILDDIR%%/qthelp, like this: +\techo.^> qcollectiongenerator %%BUILDDIR%%\\qthelp\\%(project_fn)s.qhcp \techo.To view the help file: -\techo.^> assistant -collectionFile %(rbuilddir)s\\qthelp\\%(project_fn)s.ghc +\techo.^> assistant -collectionFile %%BUILDDIR%%\\qthelp\\%(project_fn)s.ghc \tgoto end ) @@ -457,32 +459,32 @@ if "%%1" == "devhelp" ( ) if "%%1" == "latex" ( -\t%%SPHINXBUILD%% -b latex %%ALLSPHINXOPTS%% %(rbuilddir)s/latex +\t%%SPHINXBUILD%% -b latex %%ALLSPHINXOPTS%% %%BUILDDIR%%/latex \techo. -\techo.Build finished; the LaTeX files are in %(rbuilddir)s/latex. +\techo.Build finished; the LaTeX files are in %%BUILDDIR%%/latex. \tgoto end ) if "%%1" == "changes" ( -\t%%SPHINXBUILD%% -b changes %%ALLSPHINXOPTS%% %(rbuilddir)s/changes +\t%%SPHINXBUILD%% -b changes %%ALLSPHINXOPTS%% %%BUILDDIR%%/changes \techo. -\techo.The overview file is in %(rbuilddir)s/changes. +\techo.The overview file is in %%BUILDDIR%%/changes. \tgoto end ) if "%%1" == "linkcheck" ( -\t%%SPHINXBUILD%% -b linkcheck %%ALLSPHINXOPTS%% %(rbuilddir)s/linkcheck +\t%%SPHINXBUILD%% -b linkcheck %%ALLSPHINXOPTS%% %%BUILDDIR%%/linkcheck \techo. \techo.Link check complete; look for any errors in the above output ^ -or in %(rbuilddir)s/linkcheck/output.txt. +or in %%BUILDDIR%%/linkcheck/output.txt. \tgoto end ) if "%%1" == "doctest" ( -\t%%SPHINXBUILD%% -b doctest %%ALLSPHINXOPTS%% %(rbuilddir)s/doctest +\t%%SPHINXBUILD%% -b doctest %%ALLSPHINXOPTS%% %%BUILDDIR%%/doctest \techo. \techo.Testing of doctests in the sources finished, look at the ^ -results in %(rbuilddir)s/doctest/output.txt. +results in %%BUILDDIR%%/doctest/output.txt. \tgoto end ) diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py index 082ca888..05e72caf 100644 --- a/sphinx/util/__init__.py +++ b/sphinx/util/__init__.py @@ -28,7 +28,8 @@ import sphinx # Generally useful regular expressions. ws_re = re.compile(r'\s+') -caption_ref_re = re.compile(r'^([^<]+?)\s*<(.+)>$') +explicit_title_re = re.compile('^(.+?)\s*<(.*?)>$') +caption_ref_re = explicit_title_re # b/w compat alias url_re = re.compile(r'(?P<schema>.+)://.*') # SEP separates path elements in the canonical file names @@ -437,21 +438,13 @@ def copy_static_entry(source, target, builder, context={}): shutil.copytree(source, target) + def split_explicit_title(text): """Split role content into title and target, if given.""" - brace = text.find('<') - if brace != -1: - m = caption_ref_re.match(text) - if m: - target = m.group(2) - title = m.group(1) - else: - # fallback: everything after '<' is the target - target = text[brace+1:] - title = text[:brace] - return True, title, target - else: - return False, text, text + match = explicit_title_re.match(text) + if match: + return True, m.group(1), m.group(2) + return False, text, text from docutils import nodes |
