From 8c7e288129ab1d591efbe6de20ac02548335d83d Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 5 Jun 2010 18:27:43 +0200 Subject: [PATCH 1/8] #440: Remove usage of a Python >= 2.5 API in the ``literalinclude`` directive. CodecInfo is not a namedtuple, so accessing attributes on 2.4 fails. --- CHANGES | 3 +++ sphinx/directives/code.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 2adf4a3fa..1ec8f8e75 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ Release 0.6.7 (in development) ============================== +* #440: Remove usage of a Python >= 2.5 API in the ``literalinclude`` + directive. + Release 0.6.6 (May 25, 2010) ============================ diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py index b4375a98c..50ebcfde4 100644 --- a/sphinx/directives/code.py +++ b/sphinx/directives/code.py @@ -118,7 +118,7 @@ class LiteralInclude(Directive): codec_info = codecs.lookup(encoding) try: f = codecs.StreamReaderWriter(open(fn, 'U'), - codec_info.streamreader, codec_info.streamwriter, 'strict') + codec_info[2], codec_info[3], 'strict') lines = f.readlines() f.close() except (IOError, OSError): From b50e09e33e1d387255bcc1b97aa08c560f8691a7 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 5 Jun 2010 18:30:43 +0200 Subject: [PATCH 2/8] Fix a bug that prevented some references being generated in the LaTeX builder. --- CHANGES | 3 +++ sphinx/writers/latex.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/CHANGES b/CHANGES index 1ec8f8e75..7aba6d5dc 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,9 @@ Release 0.6.7 (in development) * #440: Remove usage of a Python >= 2.5 API in the ``literalinclude`` directive. +* Fix a bug that prevented some references being generated in the + LaTeX builder. + Release 0.6.6 (May 25, 2010) ============================ diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 438820570..d8818f017 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -1043,6 +1043,8 @@ class LaTeXTranslator(nodes.NodeVisitor): def visit_reference(self, node): uri = node.get('refuri', '') + if not uri and node.get('refid'): + uri = '%' + self.curfilestack[-1] + '#' + node['refid'] if self.in_title or not uri: self.context.append('') elif uri.startswith('mailto:') or uri.startswith('http:') or \ From 8d6aa310fe22817040304a91340ed20f5c18aa05 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 5 Jun 2010 18:31:37 +0200 Subject: [PATCH 3/8] Explain absolute paths in toctree. --- doc/concepts.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/concepts.rst b/doc/concepts.rst index d9979d3fc..93593f7dc 100644 --- a/doc/concepts.rst +++ b/doc/concepts.rst @@ -34,9 +34,10 @@ tables of contents. The ``toctree`` directive is the central element. This directive inserts a "TOC tree" at the current location, using the individual TOCs (including "sub-TOC trees") of the documents given in the - directive body (whose path is relative to the document the directive occurs - in). A numeric ``maxdepth`` option may be given to indicate the depth of the - tree; by default, all levels are included. [#]_ + directive body. Relative document names (not beginning with a slash) are + relative to the document the directive occurs in, absolute names are relative + to the source directory. A numeric ``maxdepth`` option may be given to + indicate the depth of the tree; by default, all levels are included. [#]_ Consider this example (taken from the Python docs' library reference index):: From 2a8b6f44c77ab48f390c84c4f0fbf1cd48c1ef52 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 5 Jun 2010 18:33:04 +0200 Subject: [PATCH 4/8] #428: Add some missing CSS styles for standard docutils classes. --- CHANGES | 2 ++ sphinx/themes/basic/static/basic.css | 46 ++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/CHANGES b/CHANGES index 7aba6d5dc..0a034651e 100644 --- a/CHANGES +++ b/CHANGES @@ -7,6 +7,8 @@ Release 0.6.7 (in development) * Fix a bug that prevented some references being generated in the LaTeX builder. +* #428: Add some missing CSS styles for standard docutils classes. + Release 0.6.6 (May 25, 2010) ============================ diff --git a/sphinx/themes/basic/static/basic.css b/sphinx/themes/basic/static/basic.css index a04d6545b..9380118ef 100644 --- a/sphinx/themes/basic/static/basic.css +++ b/sphinx/themes/basic/static/basic.css @@ -189,6 +189,19 @@ p.rubric { font-weight: bold; } +.align-left { + text-align: left; +} + +.align-center { + clear: both; + text-align: center; +} + +.align-right { + text-align: right; +} + /* -- sidebars -------------------------------------------------------------- */ div.sidebar { @@ -272,8 +285,37 @@ th { padding-right: 5px; } +table.citation { + border-left: solid 1px gray; + margin-left: 1px; +} + +table.citation td { + border-bottom: none; +} + /* -- other body styles ----------------------------------------------------- */ +ol.arabic { + list-style: decimal; +} + +ol.loweralpha { + list-style: lower-alpha; +} + +ol.upperalpha { + list-style: upper-alpha; +} + +ol.lowerroman { + list-style: lower-roman; +} + +ol.upperroman { + list-style: upper-roman; +} + dl { margin-bottom: 15px; } @@ -344,6 +386,10 @@ dl.glossary dt { margin-left: 1.5em; } +.classifier { + font-style: oblique; +} + /* -- code displays --------------------------------------------------------- */ pre { From 6ab7cd4ab75440a70c4e3c0d79cd971c05a7b454 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 5 Jun 2010 18:37:16 +0200 Subject: [PATCH 5/8] #432: Fix UnicodeErrors while building LaTeX in translated locale; do not swallow UnicodeError as a warning. --- CHANGES | 2 ++ sphinx/builders/latex.py | 8 +------- sphinx/writers/latex.py | 22 +++++++++++----------- 3 files changed, 14 insertions(+), 18 deletions(-) diff --git a/CHANGES b/CHANGES index 0a034651e..16a1f0f1e 100644 --- a/CHANGES +++ b/CHANGES @@ -9,6 +9,8 @@ Release 0.6.7 (in development) * #428: Add some missing CSS styles for standard docutils classes. +* #432: Fix UnicodeErrors while building LaTeX in translated locale. + Release 0.6.6 (May 25, 2010) ============================ diff --git a/sphinx/builders/latex.py b/sphinx/builders/latex.py index 751bf28cd..0db30d553 100644 --- a/sphinx/builders/latex.py +++ b/sphinx/builders/latex.py @@ -102,13 +102,7 @@ class LaTeXBuilder(Builder): doctree.settings.title = title doctree.settings.docname = docname doctree.settings.docclass = docclass - try: - docwriter.write(doctree, destination) - except UnicodeError: - self.warn("a Unicode error occurred when writing the output. " - "Please make sure all config values that contain " - "non-ASCII content are Unicode strings.") - return + docwriter.write(doctree, destination) self.info("done") def assemble_doctree(self, indexfile, toctree_only, appendices): diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index d8818f017..ca79ce819 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -262,7 +262,7 @@ class LaTeXTranslator(nodes.NodeVisitor): self.first_document = 0 elif self.first_document == 0: # ... and all others are the appendices - self.body.append('\n\\appendix\n') + self.body.append(u'\n\\appendix\n') self.first_document = -1 if node.has_key('docname'): self.body.append('\\hypertarget{--doc-%s}{}' % @@ -275,14 +275,14 @@ class LaTeXTranslator(nodes.NodeVisitor): for bi in self.bibitems: if len(widest_label) < len(bi[0]): widest_label = bi[0] - self.body.append('\n\\begin{thebibliography}{%s}\n' % widest_label) + self.body.append(u'\n\\begin{thebibliography}{%s}\n' % widest_label) for bi in self.bibitems: # cite_key: underscores must not be escaped cite_key = bi[0].replace(r"\_", "_") - self.body.append('\\bibitem[%s]{%s}{\hypertarget{%s}{} %s}\n' % + self.body.append(u'\\bibitem[%s]{%s}{\hypertarget{%s}{} %s}\n' % (bi[0], cite_key, self.idescape(cite_key.lower()), bi[1])) - self.body.append('\\end{thebibliography}\n') + self.body.append(u'\\end{thebibliography}\n') self.bibitems = [] def visit_start_of_file(self, node): @@ -578,7 +578,7 @@ class LaTeXTranslator(nodes.NodeVisitor): pass def visit_seealso(self, node): - self.body.append("\n\n\\strong{%s:}\n\n" % admonitionlabels['seealso']) + self.body.append(u'\n\n\\strong{%s:}\n\n' % admonitionlabels['seealso']) def depart_seealso(self, node): self.body.append("\n\n") @@ -624,8 +624,8 @@ class LaTeXTranslator(nodes.NodeVisitor): self.table.longtable = True self.body = self._body if not self.table.longtable and self.table.caption is not None: - self.body.append('\n\\begin{threeparttable}\n' - '\\caption{%s}\n' % self.table.caption) + self.body.append(u'\n\\begin{threeparttable}\n' + u'\\caption{%s}\n' % self.table.caption) if self.table.longtable: self.body.append('\n\\begin{longtable}') elif self.table.has_verbatim: @@ -645,7 +645,7 @@ class LaTeXTranslator(nodes.NodeVisitor): else: self.body.append('{|' + ('L|' * self.table.colcount) + '}\n') if self.table.longtable and self.table.caption is not None: - self.body.append('\\caption{%s} \\\\\n' % self.table.caption) + self.body.append(u'\\caption{%s} \\\\\n' % self.table.caption) if self.table.longtable: self.body.append('\\hline\n') @@ -655,7 +655,7 @@ class LaTeXTranslator(nodes.NodeVisitor): % _('continued from previous page')) self.body.append('\n\\hline\n') self.body.append('\\endhead\n\n') - self.body.append(r'\hline \multicolumn{%s}{|r|}{{%s}} \\ \hline' + self.body.append(ur'\hline \multicolumn{%s}{|r|}{{%s}} \\ \hline' % (self.table.colcount, _('Continued on next page'))) self.body.append('\n\\endfoot\n\n') @@ -950,7 +950,7 @@ class LaTeXTranslator(nodes.NodeVisitor): def _make_visit_admonition(name): def visit_admonition(self, node): - self.body.append('\n\\begin{notice}{%s}{%s:}' % + self.body.append(u'\n\\begin{notice}{%s}{%s:}' % (name, admonitionlabels[name])) return visit_admonition def _depart_named_admonition(self, node): @@ -1305,7 +1305,7 @@ class LaTeXTranslator(nodes.NodeVisitor): def visit_inline(self, node): classes = node.get('classes', []) - self.body.append(r'\DUspan{%s}{' %','.join(classes)) + self.body.append(r'\DUspan{%s}{' % ','.join(classes)) def depart_inline(self, node): self.body.append('}') From 4f0be2bae1a8181bd0b9696027165f9cdb8510ea Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Wed, 26 May 2010 00:08:11 +0200 Subject: [PATCH 6/8] Be more precise. --- sphinx/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx/__init__.py b/sphinx/__init__.py index c5c5a4bfd..ccdfaf3b4 100644 --- a/sphinx/__init__.py +++ b/sphinx/__init__.py @@ -49,7 +49,7 @@ def main(argv=sys.argv): if whichmod.startswith('docutils'): whichmod = 'Docutils library' elif whichmod.startswith('jinja'): - whichmod = 'Jinja library' + whichmod = 'Jinja2 library' elif whichmod == 'roman': whichmod = 'roman module (which is distributed with Docutils)' hint = ('This can happen if you upgraded docutils using\n' From feab1d154ef88e06c1c2d344340945ede646cd46 Mon Sep 17 00:00:00 2001 From: Armin Ronacher Date: Tue, 25 May 2010 16:24:44 +0200 Subject: [PATCH 7/8] Fixed console.py function term_width_line() issue. #423 --- sphinx/util/console.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sphinx/util/console.py b/sphinx/util/console.py index bd2851fa4..381803bce 100644 --- a/sphinx/util/console.py +++ b/sphinx/util/console.py @@ -11,7 +11,9 @@ import os import sys +import re +_strip_core_re = re.compile('\x1b\\[(\\d\\d;){0,2}\\d\\dm') codes = {} def get_terminal_width(): @@ -29,14 +31,15 @@ def get_terminal_width(): terminal_width = int(os.environ.get('COLUMNS', 80)) - 1 return terminal_width -_tw = get_terminal_width() +_tw = get_terminal_width() def term_width_line(text): if not codes: # if no coloring, don't output fancy backspaces return text + '\n' else: - return text.ljust(_tw) + '\r' + # codes are not displayed and must be taken into account by introducing the correction factor + return text.ljust(_tw + len(text) - len(_strip_core_re.sub('', text))) + '\r' def color_terminal(): if not hasattr(sys.stdout, 'isatty'): From 7eb85e159a23526b823a636ccc956d61be1fba16 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Wed, 26 May 2010 00:25:41 +0200 Subject: [PATCH 8/8] Fix long lines. --- sphinx/util/console.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sphinx/util/console.py b/sphinx/util/console.py index 381803bce..b0f03921c 100644 --- a/sphinx/util/console.py +++ b/sphinx/util/console.py @@ -13,7 +13,7 @@ import os import sys import re -_strip_core_re = re.compile('\x1b\\[(\\d\\d;){0,2}\\d\\dm') +_ansi_re = re.compile('\x1b\\[(\\d\\d;){0,2}\\d\\dm') codes = {} def get_terminal_width(): @@ -38,8 +38,8 @@ def term_width_line(text): # if no coloring, don't output fancy backspaces return text + '\n' else: - # codes are not displayed and must be taken into account by introducing the correction factor - return text.ljust(_tw + len(text) - len(_strip_core_re.sub('', text))) + '\r' + # codes are not displayed, this must be taken into account + return text.ljust(_tw + len(text) - len(_ansi_re.sub('', text))) + '\r' def color_terminal(): if not hasattr(sys.stdout, 'isatty'):