diff --git a/CHANGES b/CHANGES index d57846c6d..c14c570f0 100644 --- a/CHANGES +++ b/CHANGES @@ -25,6 +25,8 @@ Release 1.1 (in development) Release 1.0.4 (Sep 17, 2010) ============================ +* #544: Allow ``.pyw`` as a source file extension. + * #524: Open intersphinx inventories in binary mode on Windows, since version 2 contains zlib-compressed data. diff --git a/EXAMPLES b/EXAMPLES index b5fd96af4..0dab0046e 100644 --- a/EXAMPLES +++ b/EXAMPLES @@ -112,6 +112,7 @@ Documentation using another builtin theme * pip: http://pip.openplans.org/ (nature) * Programmieren mit PyGTK und Glade (German): http://www.florian-diesch.de/doc/python-und-glade/online/ (agogo) +* pypol: http://pypol.altervista.org/ (nature) * Spring Python: http://springpython.webfactional.com/current/sphinx/index.html (nature) * sqlparse: http://python-sqlparse.googlecode.com/svn/docs/api/index.html diff --git a/doc/_static/pocoo.png b/doc/_static/pocoo.png new file mode 100644 index 000000000..297dcd5e0 Binary files /dev/null and b/doc/_static/pocoo.png differ diff --git a/doc/_templates/indexsidebar.html b/doc/_templates/indexsidebar.html index 85b8fba95..feafd9046 100644 --- a/doc/_templates/indexsidebar.html +++ b/doc/_templates/indexsidebar.html @@ -1,3 +1,6 @@ + +

Download

{% if version.endswith('(hg)') %}

This documentation is for version {{ version }}, which is diff --git a/doc/conf.py b/doc/conf.py index dd23b0812..69741661d 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -21,7 +21,6 @@ show_authors = True html_theme = 'sphinxdoc' modindex_common_prefix = ['sphinx.'] html_static_path = ['_static'] -html_index = 'index.html' html_sidebars = {'index': ['indexsidebar.html', 'searchbox.html']} html_additional_pages = {'index': 'index.html'} html_use_opensearch = 'http://sphinx.pocoo.org' diff --git a/doc/config.rst b/doc/config.rst index fbf7fc40b..4c6735726 100644 --- a/doc/config.rst +++ b/doc/config.rst @@ -98,7 +98,7 @@ General configuration Example patterns: - ``'library/xml.rst'`` -- ignores the ``library/xml.rst`` file (replaces - entry in :confval:`unused_docs` + entry in :confval:`unused_docs`) - ``'library/xml'`` -- ignores the ``library/xml`` directory (replaces entry in :confval:`exclude_trees`) - ``'library/xml*'`` -- ignores all files and directories starting with diff --git a/sphinx/application.py b/sphinx/application.py index 97b1b396d..cd4503a64 100644 --- a/sphinx/application.py +++ b/sphinx/application.py @@ -209,6 +209,12 @@ class Sphinx(object): self.builder.cleanup() def warn(self, message, location=None, prefix='WARNING: '): + if isinstance(location, tuple): + docname, lineno = location + if docname: + location = '%s:%s' % (self.env.doc2path(docname), lineno or '') + else: + location = None warntext = location and '%s: %s%s\n' % (location, prefix, message) or \ '%s%s\n' % (prefix, message) if self.warningiserror: diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index 78bafda81..cdeb334a2 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -88,6 +88,8 @@ class StandaloneHTMLBuilder(Builder): self.tags_hash = '' # section numbers for headings in the currently visited document self.secnumbers = {} + # currently written docname + self.current_docname = None self.init_templates() self.init_highlighter() @@ -398,6 +400,7 @@ class StandaloneHTMLBuilder(Builder): self.imgpath = relative_uri(self.get_target_uri(docname), '_images') self.post_process_images(doctree) self.dlpath = relative_uri(self.get_target_uri(docname), '_downloads') + self.current_docname = docname self.docwriter.write(doctree, destination) self.docwriter.assemble_parts() body = self.docwriter.parts['fragment'] diff --git a/sphinx/environment.py b/sphinx/environment.py index 883c91e99..85d43fcbf 100644 --- a/sphinx/environment.py +++ b/sphinx/environment.py @@ -377,12 +377,8 @@ class BuildEnvironment: self.settings['warning_stream'] = WarningStream(func) def warn(self, docname, msg, lineno=None): - if docname: - if lineno is None: - lineno = '' - self._warnfunc(msg, '%s:%s' % (self.doc2path(docname), lineno)) - else: - self._warnfunc(msg) + # strange argument order is due to backwards compatibility + self._warnfunc(msg, (docname, lineno)) def clear_doc(self, docname): """Remove all traces of a source file in the inventory.""" diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index 3a2476a6b..696e5f1d0 100644 --- a/sphinx/ext/autodoc.py +++ b/sphinx/ext/autodoc.py @@ -664,7 +664,7 @@ class Documenter(object): # parse right now, to get PycodeErrors on parsing (results will # be cached anyway) self.analyzer.find_attr_docs() - except PycodeError, err: + except PycodeError: # no source file -- e.g. for builtin and C modules self.analyzer = None # at least add the module.__file__ as a dependency diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py index 6d7109199..798c2d7bc 100644 --- a/sphinx/highlighting.py +++ b/sphinx/highlighting.py @@ -207,7 +207,7 @@ class PygmentsBridge(object): lexer = lexers[lang] = get_lexer_by_name(lang) except ClassNotFound: if warn: - warn('Pygments lexer name %s is not known' % lang) + warn('Pygments lexer name %r is not known' % lang) return self.unhighlighted(source) else: raise diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py index ee00e4d11..0028340ff 100644 --- a/sphinx/util/__init__.py +++ b/sphinx/util/__init__.py @@ -209,7 +209,7 @@ def get_module_source(modname): lfilename = filename.lower() if lfilename.endswith('.pyo') or lfilename.endswith('.pyc'): filename = filename[:-1] - elif not lfilename.endswith('.py'): + elif not (lfilename.endswith('.py') or lfilename.endswith('.pyw')): raise PycodeError('source is not a .py file: %r' % filename) if not path.isfile(filename): raise PycodeError('source file is not present: %r' % filename) diff --git a/sphinx/writers/html.py b/sphinx/writers/html.py index 33d90c915..858681f7a 100644 --- a/sphinx/writers/html.py +++ b/sphinx/writers/html.py @@ -232,8 +232,10 @@ class HTMLTranslator(BaseTranslator): lang = node['language'] if node.has_key('linenos'): linenos = node['linenos'] - highlighted = self.highlighter.highlight_block(node.rawsource, - lang, linenos) + def warner(msg): + self.builder.warn(msg, (self.builder.current_docname, node.line)) + highlighted = self.highlighter.highlight_block( + node.rawsource, lang, linenos, warn=warner) starttag = self.starttag(node, 'div', suffix='', CLASS='highlight-%s' % lang) self.body.append(starttag + highlighted + '\n') diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index de57e35a8..2ded01e3e 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -429,10 +429,8 @@ class LaTeXTranslator(nodes.NodeVisitor): elif self.this_is_the_title: if len(node.children) != 1 and not isinstance(node.children[0], nodes.Text): - self.builder.warn( - 'document title is not a single Text node', - '%s:%s' % (self.builder.env.doc2path(self.curfilestack[-1]), - node.line or '')) + self.builder.warn('document title is not a single Text node', + (self.curfilestack[-1], node.line)) if not self.elements['title']: # text needs to be escaped since it is inserted into # the output literally @@ -465,8 +463,7 @@ class LaTeXTranslator(nodes.NodeVisitor): self.builder.warn( 'encountered title node not in section, topic, table, ' 'admonition or sidebar', - '%s:%s' % (self.builder.env.doc2path(self.curfilestack[-1]), - node.line or '')) + (self.curfilestack[-1], node.line or '')) self.body.append('\\textbf{') self.context.append('}\n') self.in_title = 1 @@ -1107,10 +1104,8 @@ class LaTeXTranslator(nodes.NodeVisitor): self.body.append('\\grammartoken{') self.context.append('}') else: - self.builder.warn( - 'unusable reference target found: %s' % uri, - '%s:%s' % (self.builder.env.doc2path(self.curfilestack[-1]), - node.line or '')) + self.builder.warn('unusable reference target found: %s' % uri, + (self.curfilestack[-1], node.line)) self.context.append('') def depart_reference(self, node): self.body.append(self.context.pop()) @@ -1215,7 +1210,10 @@ class LaTeXTranslator(nodes.NodeVisitor): lang = node['language'] if 'linenos' in node: linenos = node['linenos'] - hlcode = self.highlighter.highlight_block(code, lang, linenos) + def warner(msg): + self.builder.warn(msg, (self.curfilestack[-1], node.line)) + hlcode = self.highlighter.highlight_block(code, lang, linenos, + warn=warner) # workaround for Unicode issue hlcode = hlcode.replace(u'€', u'@texteuro[]') # must use original Verbatim environment and "tabular" environment @@ -1238,7 +1236,7 @@ class LaTeXTranslator(nodes.NodeVisitor): * inline markup is supported. * serif typeface """ - self.body.append('{\\raggedright{}') + self.body.append('\n{\\raggedright{}') self.literal_whitespace += 1 def depart_line_block(self, node): self.literal_whitespace -= 1