Commits

Georg Brandl committed 3371e92 Merge

merge with 0.6

  • Participants
  • Parent commits 1b3e77c, b2aca87

Comments (0)

Files changed (7)

 Release 0.6.6 (in development)
 ==============================
 
+* #409: Make the ``highlight_language`` config value work properly
+  in the LaTeX builder.
+
+* #418: Allow relocation of the translation JavaScript files to
+  the system directory on Unix systems.
+
+* #414: Fix handling of Windows newlines in files included with
+  the ``literalinclude`` directive.
+
+* #377: Fix crash in linkcheck builder.
+
 * #387: Fix the display of search results in ``dirhtml`` output.
 
 * #376: In autodoc, fix display of parameter defaults containing

File doc/Makefile

 	@echo "  html      to make standalone HTML files"
 	@echo "  dirhtml   to make HTML files called index.html in directories"
 	@echo "  pickle    to make pickle files"
+	@echo "  json      to make json files"
 	@echo "  htmlhelp  to make HTML files and a HTML help project"
 	@echo "  epub      to make an epub file"
 	@echo "  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
 pickle:
 	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) _build/pickle
 
+json:
+	mkdir -p _build/json _build/doctrees
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) _build/json
+
 htmlhelp:
 	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) _build/htmlhelp
 	@echo
 # -*- coding: utf-8 -*-
-import ez_setup
-ez_setup.use_setuptools()
+try:
+    from setuptools import setup, find_packages
+except ImportError:
+    import ez_setup
+    ez_setup.use_setuptools()
+    from setuptools import setup, find_packages
 
 import os
 import sys
-from setuptools import setup, find_packages
 from distutils import log
 
 import sphinx

File sphinx/builders/html.py

 """
 
 import os
+import sys
 import zlib
 import codecs
 import posixpath
             self.link_suffix = self.out_suffix
 
         if self.config.language is not None:
-            jsfile = path.join(package_dir, 'locale', self.config.language,
-                               'LC_MESSAGES', 'sphinx.js')
-            if path.isfile(jsfile):
-                self.script_files.append('_static/translations.js')
+            jsfile_list = [path.join(package_dir, 'locale',
+                self.config.language, 'LC_MESSAGES', 'sphinx.js'),
+                path.join(sys.prefix, 'share/sphinx/locale',
+                    self.config.language, 'sphinx.js')]
+
+            for jsfile in jsfile_list:
+                if path.isfile(jsfile):
+                    self.script_files.append('_static/translations.js')
+                    break
 
     def get_theme_config(self):
         return self.config.html_theme, self.config.html_theme_options
         f.close()
         # then, copy translations JavaScript file
         if self.config.language is not None:
-            jsfile = path.join(package_dir, 'locale', self.config.language,
-                               'LC_MESSAGES', 'sphinx.js')
-            if path.isfile(jsfile):
-                copyfile(jsfile, path.join(self.outdir, '_static',
-                                           'translations.js'))
+            jsfile_list = [path.join(package_dir, 'locale',
+                self.config.language, 'LC_MESSAGES', 'sphinx.js'),
+                path.join(sys.prefix, 'share/sphinx/locale',
+                    self.config.language, 'sphinx.js')]
+            for jsfile in jsfile_list:
+                if path.isfile(jsfile):
+                    copyfile(jsfile, path.join(self.outdir, '_static',
+                                               'translations.js'))
+                    break
         # then, copy over theme-supplied static files
         if self.theme:
             themeentries = [path.join(themepath, 'static')

File sphinx/builders/linkcheck.py

             return
 
         lineno = None
-        while lineno is None and node:
+        while lineno is None:
             node = node.parent
+            if node is None:
+                break
             lineno = node.line
 
         if uri[0:5] == 'http:' or uri[0:6] == 'https:':

File sphinx/directives/code.py

                 line=self.lineno)]
 
         encoding = self.options.get('encoding', env.config.source_encoding)
+        codec_info = codecs.lookup(encoding)
         try:
-            f = codecs.open(fn, 'rU', encoding)
+            f = codecs.StreamReaderWriter(open(fn, 'U'),
+                    codec_info.streamreader, codec_info.streamwriter, 'strict')
             lines = f.readlines()
             f.close()
         except (IOError, OSError):

File sphinx/writers/latex.py

         self.bibitems = []
         self.table = None
         self.next_table_colspec = None
-        self.highlightlang = builder.config.highlight_language
-        self.highlightlinenothreshold = sys.maxint
+        # stack of [language, linenothreshold] settings per file
+        # the first item here is the default and must not be changed
+        # the second item is the default for the master file and can be changed
+        # by .. highlight:: directive in the master file
+        self.hlsettingstack = 2 * [[builder.config.highlight_language, sys.maxint]]
         self.footnotestack = []
         self.curfilestack = []
         self.handled_abbrs = set()
         # also add a document target
         self.next_section_ids.add(':doc')
         self.curfilestack.append(node['docname'])
+        # use default highlight settings for new file
+        self.hlsettingstack.append(self.hlsettingstack[0])
 
     def collect_footnotes(self, node):
         fnotes = {}
     def depart_start_of_file(self, node):
         self.footnotestack.pop()
         self.curfilestack.pop()
+        self.hlsettingstack.pop()
 
     def visit_highlightlang(self, node):
-        self.highlightlang = node['lang']
-        self.highlightlinenothreshold = node['linenothreshold']
+        self.hlsettingstack[-1] = [node['lang'], node['linenothreshold']]
         raise nodes.SkipNode
 
     def visit_section(self, node):
         self.verbatim = ''
     def depart_literal_block(self, node):
         code = self.verbatim.rstrip('\n')
-        lang = self.highlightlang
-        linenos = code.count('\n') >= self.highlightlinenothreshold - 1
+        lang = self.hlsettingstack[-1][0]
+        linenos = code.count('\n') >= self.hlsettingstack[-1][1] - 1
         if node.has_key('language'):
             # code-block directives
             lang = node['language']