From f4988dfa177fc7c11b824908b13263f200d4fd85 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Fri, 22 Oct 2010 11:42:56 +0200 Subject: [PATCH 1/4] #523: fixes for qthelp index. --- sphinx/builders/qthelp.py | 4 +-- sphinx/environment.py | 60 ++++++++++++++++++++------------------- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/sphinx/builders/qthelp.py b/sphinx/builders/qthelp.py index f1beab984..1c4908254 100644 --- a/sphinx/builders/qthelp.py +++ b/sphinx/builders/qthelp.py @@ -23,7 +23,7 @@ from sphinx.builders.html import StandaloneHTMLBuilder _idpattern = re.compile( - r'(?P.+) (\((?P<id>[\w\.]+)( (?P<descr>\w+))?\))$') + r'(?P<title>.+) (\((class in )?(?P<id>[\w\.]+)( (?P<descr>\w+))?\))$') # Qt Help Collection Project (.qhcp). @@ -135,7 +135,7 @@ class QtHelpBuilder(StandaloneHTMLBuilder): # keywords keywords = [] - index = self.env.create_index(self) + index = self.env.create_index(self, group_entries=False) for (key, group) in index: for title, (refs, subitems) in group: keywords.extend(self.build_keywords(title, refs, subitems)) diff --git a/sphinx/environment.py b/sphinx/environment.py index 77b43d6ef..5cf737ec0 100644 --- a/sphinx/environment.py +++ b/sphinx/environment.py @@ -1419,7 +1419,8 @@ class BuildEnvironment: return rewrite_needed - def create_index(self, builder, _fixre=re.compile(r'(.*) ([(][^()]*[)])')): + def create_index(self, builder, group_entries=True, + _fixre=re.compile(r'(.*) ([(][^()]*[)])')): """Create the real index from the collected index entries.""" new = {} @@ -1484,34 +1485,35 @@ class BuildEnvironment: newlist = new.items() newlist.sort(key=keyfunc) - # fixup entries: transform - # func() (in module foo) - # func() (in module bar) - # into - # func() - # (in module foo) - # (in module bar) - oldkey = '' - oldsubitems = None - i = 0 - while i < len(newlist): - key, (targets, subitems) = newlist[i] - # cannot move if it has subitems; structure gets too complex - if not subitems: - m = _fixre.match(key) - if m: - if oldkey == m.group(1): - # prefixes match: add entry as subitem of the - # previous entry - oldsubitems.setdefault(m.group(2), [[], {}])[0].\ - extend(targets) - del newlist[i] - continue - oldkey = m.group(1) - else: - oldkey = key - oldsubitems = subitems - i += 1 + if group_entries: + # fixup entries: transform + # func() (in module foo) + # func() (in module bar) + # into + # func() + # (in module foo) + # (in module bar) + oldkey = '' + oldsubitems = None + i = 0 + while i < len(newlist): + key, (targets, subitems) = newlist[i] + # cannot move if it has subitems; structure gets too complex + if not subitems: + m = _fixre.match(key) + if m: + if oldkey == m.group(1): + # prefixes match: add entry as subitem of the + # previous entry + oldsubitems.setdefault(m.group(2), [[], {}])[0].\ + extend(targets) + del newlist[i] + continue + oldkey = m.group(1) + else: + oldkey = key + oldsubitems = subitems + i += 1 # group the entries by letter def keyfunc2((k, v), letters=string.ascii_uppercase + '_'): From aee3d7618ae3f3c2346ccb097c7efad591e967f4 Mon Sep 17 00:00:00 2001 From: Georg Brandl <georg@python.org> Date: Fri, 22 Oct 2010 11:54:05 +0200 Subject: [PATCH 2/4] #522: in Windows batchfile, do not print success message when sphinx-build fails. --- sphinx/quickstart.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/sphinx/quickstart.py b/sphinx/quickstart.py index 884caca75..97376d861 100644 --- a/sphinx/quickstart.py +++ b/sphinx/quickstart.py @@ -495,6 +495,7 @@ if "%%1" == "clean" ( if "%%1" == "html" ( \t%%SPHINXBUILD%% -b html %%ALLSPHINXOPTS%% %%BUILDDIR%%/html +\tif errorlevel 1 exit /b 1 \techo. \techo.Build finished. The HTML pages are in %%BUILDDIR%%/html. \tgoto end @@ -502,6 +503,7 @@ if "%%1" == "html" ( if "%%1" == "dirhtml" ( \t%%SPHINXBUILD%% -b dirhtml %%ALLSPHINXOPTS%% %%BUILDDIR%%/dirhtml +\tif errorlevel 1 exit /b 1 \techo. \techo.Build finished. The HTML pages are in %%BUILDDIR%%/dirhtml. \tgoto end @@ -509,6 +511,7 @@ if "%%1" == "dirhtml" ( if "%%1" == "singlehtml" ( \t%%SPHINXBUILD%% -b singlehtml %%ALLSPHINXOPTS%% %%BUILDDIR%%/singlehtml +\tif errorlevel 1 exit /b 1 \techo. \techo.Build finished. The HTML pages are in %%BUILDDIR%%/singlehtml. \tgoto end @@ -516,6 +519,7 @@ if "%%1" == "singlehtml" ( if "%%1" == "pickle" ( \t%%SPHINXBUILD%% -b pickle %%ALLSPHINXOPTS%% %%BUILDDIR%%/pickle +\tif errorlevel 1 exit /b 1 \techo. \techo.Build finished; now you can process the pickle files. \tgoto end @@ -523,6 +527,7 @@ if "%%1" == "pickle" ( if "%%1" == "json" ( \t%%SPHINXBUILD%% -b json %%ALLSPHINXOPTS%% %%BUILDDIR%%/json +\tif errorlevel 1 exit /b 1 \techo. \techo.Build finished; now you can process the JSON files. \tgoto end @@ -530,6 +535,7 @@ if "%%1" == "json" ( if "%%1" == "htmlhelp" ( \t%%SPHINXBUILD%% -b htmlhelp %%ALLSPHINXOPTS%% %%BUILDDIR%%/htmlhelp +\tif errorlevel 1 exit /b 1 \techo. \techo.Build finished; now you can run HTML Help Workshop with the ^ .hhp project file in %%BUILDDIR%%/htmlhelp. @@ -538,6 +544,7 @@ if "%%1" == "htmlhelp" ( if "%%1" == "qthelp" ( \t%%SPHINXBUILD%% -b qthelp %%ALLSPHINXOPTS%% %%BUILDDIR%%/qthelp +\tif errorlevel 1 exit /b 1 \techo. \techo.Build finished; now you can run "qcollectiongenerator" with the ^ .qhcp project file in %%BUILDDIR%%/qthelp, like this: @@ -549,6 +556,7 @@ if "%%1" == "qthelp" ( if "%%1" == "devhelp" ( \t%%SPHINXBUILD%% -b devhelp %%ALLSPHINXOPTS%% %%BUILDDIR%%/devhelp +\tif errorlevel 1 exit /b 1 \techo. \techo.Build finished. \tgoto end @@ -556,6 +564,7 @@ if "%%1" == "devhelp" ( if "%%1" == "epub" ( \t%%SPHINXBUILD%% -b epub %%ALLSPHINXOPTS%% %%BUILDDIR%%/epub +\tif errorlevel 1 exit /b 1 \techo. \techo.Build finished. The epub file is in %%BUILDDIR%%/epub. \tgoto end @@ -563,6 +572,7 @@ if "%%1" == "epub" ( if "%%1" == "latex" ( \t%%SPHINXBUILD%% -b latex %%ALLSPHINXOPTS%% %%BUILDDIR%%/latex +\tif errorlevel 1 exit /b 1 \techo. \techo.Build finished; the LaTeX files are in %%BUILDDIR%%/latex. \tgoto end @@ -570,6 +580,7 @@ if "%%1" == "latex" ( if "%%1" == "text" ( \t%%SPHINXBUILD%% -b text %%ALLSPHINXOPTS%% %%BUILDDIR%%/text +\tif errorlevel 1 exit /b 1 \techo. \techo.Build finished. The text files are in %%BUILDDIR%%/text. \tgoto end @@ -577,6 +588,7 @@ if "%%1" == "text" ( if "%%1" == "man" ( \t%%SPHINXBUILD%% -b man %%ALLSPHINXOPTS%% %%BUILDDIR%%/man +\tif errorlevel 1 exit /b 1 \techo. \techo.Build finished. The manual pages are in %%BUILDDIR%%/man. \tgoto end @@ -584,6 +596,7 @@ if "%%1" == "man" ( if "%%1" == "changes" ( \t%%SPHINXBUILD%% -b changes %%ALLSPHINXOPTS%% %%BUILDDIR%%/changes +\tif errorlevel 1 exit /b 1 \techo. \techo.The overview file is in %%BUILDDIR%%/changes. \tgoto end @@ -591,6 +604,7 @@ if "%%1" == "changes" ( if "%%1" == "linkcheck" ( \t%%SPHINXBUILD%% -b linkcheck %%ALLSPHINXOPTS%% %%BUILDDIR%%/linkcheck +\tif errorlevel 1 exit /b 1 \techo. \techo.Link check complete; look for any errors in the above output ^ or in %%BUILDDIR%%/linkcheck/output.txt. @@ -599,6 +613,7 @@ or in %%BUILDDIR%%/linkcheck/output.txt. if "%%1" == "doctest" ( \t%%SPHINXBUILD%% -b doctest %%ALLSPHINXOPTS%% %%BUILDDIR%%/doctest +\tif errorlevel 1 exit /b 1 \techo. \techo.Testing of doctests in the sources finished, look at the ^ results in %%BUILDDIR%%/doctest/output.txt. From 5d2e8ac1c9724e1254b4ffcd86f531cef7276b55 Mon Sep 17 00:00:00 2001 From: Georg Brandl <georg@python.org> Date: Fri, 22 Oct 2010 11:59:16 +0200 Subject: [PATCH 3/4] #530: set font size of \paragraph to \small. --- sphinx/texinputs/sphinx.sty | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty index cee4dc566..0d37e02c6 100644 --- a/sphinx/texinputs/sphinx.sty +++ b/sphinx/texinputs/sphinx.sty @@ -209,7 +209,7 @@ {\py@TitleColor\thesubsection}{0.5em}{\py@TitleColor}{\py@NormalColor} \titleformat{\subsubsection}{\py@HeaderFamily}% {\py@TitleColor\thesubsubsection}{0.5em}{\py@TitleColor}{\py@NormalColor} -\titleformat{\paragraph}{\large\py@HeaderFamily}% +\titleformat{\paragraph}{\small\py@HeaderFamily}% {\py@TitleColor}{0em}{\py@TitleColor}{\py@NormalColor} % {fulllineitems} is the main environment for object descriptions. From 644e157fa5c1226d64916446ca03c8d36f28ae40 Mon Sep 17 00:00:00 2001 From: Georg Brandl <georg@python.org> Date: Fri, 22 Oct 2010 12:10:11 +0200 Subject: [PATCH 4/4] #535: Fix LaTeX output generated for line blocks by porting implementation from new docutils code. --- CHANGES | 10 ++++++++-- sphinx/texinputs/sphinx.sty | 19 +++++++++++++++++++ sphinx/writers/latex.py | 32 ++++++++++---------------------- tests/root/markup.txt | 10 ++++++++++ 4 files changed, 47 insertions(+), 24 deletions(-) diff --git a/CHANGES b/CHANGES index f0e6759fa..8196b09f6 100644 --- a/CHANGES +++ b/CHANGES @@ -1,8 +1,14 @@ -Release 1.0.4 (Sep 17, 2010) -============================ +Release 1.0.5 (in development) +============================== + +* #535: Fix LaTeX output generated for line blocks. * #544: Allow ``.pyw`` as a source file extension. + +Release 1.0.4 (Sep 17, 2010) +============================ + * #524: Open intersphinx inventories in binary mode on Windows, since version 2 contains zlib-compressed data. diff --git a/sphinx/texinputs/sphinx.sty b/sphinx/texinputs/sphinx.sty index 0d37e02c6..bc8df37b8 100644 --- a/sphinx/texinputs/sphinx.sty +++ b/sphinx/texinputs/sphinx.sty @@ -16,6 +16,7 @@ \RequirePackage{amsmath} % for \text \RequirePackage{makeidx} \RequirePackage{framed} +\RequirePackage{ifthen} \RequirePackage{color} % For highlighted code. \RequirePackage{fancyvrb} @@ -462,3 +463,21 @@ {#2}% node content }% close "span" } + +\providecommand*{\DUprovidelength}[2]{ + \ifthenelse{\isundefined{#1}}{\newlength{#1}\setlength{#1}{#2}}{} +} + +\DUprovidelength{\DUlineblockindent}{2.5em} +\ifthenelse{\isundefined{\DUlineblock}}{ + \newenvironment{DUlineblock}[1]{% + \list{}{\setlength{\partopsep}{\parskip} + \addtolength{\partopsep}{\baselineskip} + \setlength{\topsep}{0pt} + \setlength{\itemsep}{0.15\baselineskip} + \setlength{\parsep}{0pt} + \setlength{\leftmargin}{#1}} + \raggedright + } + {\endlist} +}{} \ No newline at end of file diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index ee30b4ebc..38f449940 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1230,31 +1230,19 @@ class LaTeXTranslator(nodes.NodeVisitor): visit_doctest_block = visit_literal_block depart_doctest_block = depart_literal_block - def visit_line_block(self, node): - """line-block: - * whitespace (including linebreaks) is significant - * inline markup is supported. - * serif typeface - """ - self.body.append('\n{\\raggedright{}') - self.literal_whitespace += 1 - def depart_line_block(self, node): - self.literal_whitespace -= 1 - # remove the last \\ - del self.body[-1] - self.body.append('}\n') - def visit_line(self, node): - self._line_start = len(self.body) + self.body.append('\item[] ') def depart_line(self, node): - if self._line_start == len(self.body): - # no output in this line -- add a nonbreaking space, else the - # \\ command will give an error - self.body.append('~') - if self.table is not None: - self.body.append('\\newline\n') + self.body.append('\n') + + def visit_line_block(self, node): + if isinstance(node.parent, nodes.line_block): + self.body.append('\\item[]\n' + '\\begin{DUlineblock}{\\DUlineblockindent}\n') else: - self.body.append('\\\\\n') + self.body.append('\n\\begin{DUlineblock}{0em}\n') + def depart_line_block(self, node): + self.body.append('\\end{DUlineblock}\n') def visit_block_quote(self, node): # If the block quote contains a single object and that object diff --git a/tests/root/markup.txt b/tests/root/markup.txt index a72285ed7..da71cf860 100644 --- a/tests/root/markup.txt +++ b/tests/root/markup.txt @@ -34,6 +34,16 @@ Option list: -h help --help also help +Line block: + +| line1 +| line2 +| line3 +| line4 +| line5 +| line6 +| line7 + Body directives ^^^^^^^^^^^^^^^