From 124864ed2772b59b130ee48fb6dc65953f8157f2 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Tue, 28 Apr 2009 20:08:17 +0200 Subject: [PATCH 1/5] #145: Fix autodoc problem with automatic members that refuse to be getattr()'d from their parent. --- CHANGES | 4 ++++ sphinx/ext/autodoc.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 6f99a6cf9..cf9f05580 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ Release 0.6.2 (in development) ============================== +* #145: Fix autodoc problem with automatic members that refuse to be + getattr()'d from their parent. + * If specific filenames to build are given on the command line, check that they are within the source directory. @@ -11,6 +14,7 @@ Release 0.6.2 (in development) * #134: Fix pending_xref leftover nodes when using the todolist directive from the todo extension. + Release 0.6.1 (Mar 26, 2009) ============================ diff --git a/sphinx/ext/autodoc.py b/sphinx/ext/autodoc.py index 53f533979..110314242 100644 --- a/sphinx/ext/autodoc.py +++ b/sphinx/ext/autodoc.py @@ -485,7 +485,7 @@ class Documenter(object): # using keys() because apparently there are objects for which # __dict__ changes while getting attributes return False, sorted([ - (mname, self.get_attr(self.object, mname)) + (mname, self.get_attr(self.object, mname, None)) for mname in self.get_attr(self.object, '__dict__').keys()]) def filter_members(self, members, want_all): From cb86f75bab99e3318311fe4471d04d697f673bb7 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Tue, 28 Apr 2009 20:31:00 +0200 Subject: [PATCH 2/5] In the LaTeX writer, do not raise an exception on too many section levels, just use the "subparagraph" level for all of them. --- CHANGES | 3 +++ sphinx/writers/latex.py | 6 ++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index cf9f05580..864bb9929 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,9 @@ Release 0.6.2 (in development) ============================== +* In the LaTeX writer, do not raise an exception on too many section + levels, just use the "subparagraph" level for all of them. + * #145: Fix autodoc problem with automatic members that refuse to be getattr()'d from their parent. diff --git a/sphinx/writers/latex.py b/sphinx/writers/latex.py index 37281fa9f..6eaabfb3e 100644 --- a/sphinx/writers/latex.py +++ b/sphinx/writers/latex.py @@ -383,10 +383,8 @@ class LaTeXTranslator(nodes.NodeVisitor): try: self.body.append(r'\%s{' % self.sectionnames[self.sectionlevel]) except IndexError: - raise UnsupportedError( - '%s:%s: too many nesting section levels for ' - 'LaTeX, at heading: %s' % (self.curfilestack[-1], - node.line or '', node.astext())) + # just use "subparagraph", it's not numbered anyway + self.body.append(r'\%s{' % self.sectionnames[-1]) self.context.append('}\n') elif isinstance(parent, (nodes.topic, nodes.sidebar)): self.body.append(r'\textbf{') From 82af37ea7c5bf1c351e908d3266e631b2deabe6a Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Tue, 28 Apr 2009 20:46:24 +0200 Subject: [PATCH 3/5] Don't put image "alt" text into table-of-contents entries. --- CHANGES | 2 ++ sphinx/environment.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/CHANGES b/CHANGES index 864bb9929..128e6e9a4 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ Release 0.6.2 (in development) ============================== +* Don't put image "alt" text into table-of-contents entries. + * In the LaTeX writer, do not raise an exception on too many section levels, just use the "subparagraph" level for all of them. diff --git a/sphinx/environment.py b/sphinx/environment.py index 522e2bd06..064b71ae1 100644 --- a/sphinx/environment.py +++ b/sphinx/environment.py @@ -190,6 +190,9 @@ class SphinxContentsFilter(ContentsFilter): self.parent.append(nodes.literal(text, text)) raise nodes.SkipNode + def visit_image(self, node): + raise nodes.SkipNode + class BuildEnvironment: """ From 8011b358c822546e6beed1937905c05ca864279f Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Tue, 28 Apr 2009 20:59:11 +0200 Subject: [PATCH 4/5] Copy stat as well as files for static content. --- sphinx/builders/html.py | 27 +++++++++++++-------------- sphinx/builders/latex.py | 19 +++++++++---------- sphinx/util/__init__.py | 11 +++++++++-- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index 365cf5f96..a1731b3a9 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -11,7 +11,6 @@ import os import codecs -import shutil import posixpath import cPickle as pickle from os import path @@ -30,7 +29,7 @@ from docutils.readers.doctree import Reader as DoctreeReader from sphinx import package_dir, __version__ from sphinx.util import SEP, os_path, relative_uri, ensuredir, \ - movefile, ustrftime, copy_static_entry + movefile, ustrftime, copy_static_entry, copyfile from sphinx.errors import SphinxError from sphinx.search import js_index from sphinx.theming import Theme @@ -495,8 +494,8 @@ class StandaloneHTMLBuilder(Builder): ensuredir(path.join(self.outdir, '_images')) for src, dest in self.images.iteritems(): self.info(' '+src, nonl=1) - shutil.copyfile(path.join(self.srcdir, src), - path.join(self.outdir, '_images', dest)) + copyfile(path.join(self.srcdir, src), + path.join(self.outdir, '_images', dest)) self.info() # copy downloadable files @@ -505,8 +504,8 @@ class StandaloneHTMLBuilder(Builder): ensuredir(path.join(self.outdir, '_downloads')) for src, (_, dest) in self.env.dlfiles.iteritems(): self.info(' '+src, nonl=1) - shutil.copyfile(path.join(self.srcdir, src), - path.join(self.outdir, '_downloads', dest)) + copyfile(path.join(self.srcdir, src), + path.join(self.outdir, '_downloads', dest)) self.info() # copy static files @@ -521,8 +520,8 @@ class StandaloneHTMLBuilder(Builder): jsfile = path.join(package_dir, 'locale', self.config.language, 'LC_MESSAGES', 'sphinx.js') if path.isfile(jsfile): - shutil.copyfile(jsfile, path.join(self.outdir, '_static', - 'translations.js')) + copyfile(jsfile, path.join(self.outdir, '_static', + 'translations.js')) # then, copy over all user-supplied static files if self.theme: staticdirnames = [path.join(themepath, 'static') @@ -545,8 +544,8 @@ class StandaloneHTMLBuilder(Builder): # last, copy logo file (handled differently) if self.config.html_logo: logobase = path.basename(self.config.html_logo) - shutil.copyfile(path.join(self.confdir, self.config.html_logo), - path.join(self.outdir, '_static', logobase)) + copyfile(path.join(self.confdir, self.config.html_logo), + path.join(self.outdir, '_static', logobase)) # write build info file fp = open(path.join(self.outdir, '.buildinfo'), 'w') @@ -663,7 +662,7 @@ class StandaloneHTMLBuilder(Builder): source_name = path.join(self.outdir, '_sources', os_path(ctx['sourcename'])) ensuredir(path.dirname(source_name)) - shutil.copyfile(self.env.doc2path(pagename), source_name) + copyfile(self.env.doc2path(pagename), source_name) def handle_finish(self): self.info(bold('dumping search index... '), nonl=True) @@ -778,7 +777,7 @@ class SerializingHTMLBuilder(StandaloneHTMLBuilder): source_name = path.join(self.outdir, '_sources', os_path(ctx['sourcename'])) ensuredir(path.dirname(source_name)) - shutil.copyfile(self.env.doc2path(pagename), source_name) + copyfile(self.env.doc2path(pagename), source_name) def handle_finish(self): # dump the global context @@ -794,8 +793,8 @@ class SerializingHTMLBuilder(StandaloneHTMLBuilder): # copy the environment file from the doctree dir to the output dir # as needed by the web app - shutil.copyfile(path.join(self.doctreedir, ENV_PICKLE_FILENAME), - path.join(self.outdir, ENV_PICKLE_FILENAME)) + copyfile(path.join(self.doctreedir, ENV_PICKLE_FILENAME), + path.join(self.outdir, ENV_PICKLE_FILENAME)) # touch 'last build' file, used by the web application to determine # when to reload its environment and clear the cache diff --git a/sphinx/builders/latex.py b/sphinx/builders/latex.py index bc2f1ba58..95b343a4c 100644 --- a/sphinx/builders/latex.py +++ b/sphinx/builders/latex.py @@ -10,7 +10,6 @@ """ import os -import shutil from os import path from docutils import nodes @@ -19,7 +18,7 @@ from docutils.utils import new_document from docutils.frontend import OptionParser from sphinx import package_dir, addnodes -from sphinx.util import SEP, texescape +from sphinx.util import SEP, texescape, copyfile from sphinx.builders import Builder from sphinx.environment import NoUri from sphinx.util.console import bold, darkgreen @@ -175,8 +174,8 @@ class LaTeXBuilder(Builder): self.info(bold('copying images...'), nonl=1) for src, dest in self.images.iteritems(): self.info(' '+src, nonl=1) - shutil.copyfile(path.join(self.srcdir, src), - path.join(self.outdir, dest)) + copyfile(path.join(self.srcdir, src), + path.join(self.outdir, dest)) self.info() # copy additional files @@ -184,20 +183,20 @@ class LaTeXBuilder(Builder): self.info(bold('copying additional files...'), nonl=1) for filename in self.config.latex_additional_files: self.info(' '+filename, nonl=1) - shutil.copyfile(path.join(self.confdir, filename), - path.join(self.outdir, path.basename(filename))) + copyfile(path.join(self.confdir, filename), + path.join(self.outdir, path.basename(filename))) self.info() # the logo is handled differently if self.config.latex_logo: logobase = path.basename(self.config.latex_logo) - shutil.copyfile(path.join(self.confdir, self.config.latex_logo), - path.join(self.outdir, logobase)) + copyfile(path.join(self.confdir, self.config.latex_logo), + path.join(self.outdir, logobase)) self.info(bold('copying TeX support files... '), nonl=True) staticdirname = path.join(package_dir, 'texinputs') for filename in os.listdir(staticdirname): if not filename.startswith('.'): - shutil.copyfile(path.join(staticdirname, filename), - path.join(self.outdir, filename)) + copyfile(path.join(staticdirname, filename), + path.join(self.outdir, filename)) self.info('done') diff --git a/sphinx/util/__init__.py b/sphinx/util/__init__.py index 7e4b1092b..7d00964fb 100644 --- a/sphinx/util/__init__.py +++ b/sphinx/util/__init__.py @@ -384,7 +384,7 @@ def force_decode(string, encoding): def movefile(source, dest): - # move a file, removing the destination if it exists + """Move a file, removing the destination if it exists.""" if os.path.exists(dest): try: os.unlink(dest) @@ -393,6 +393,13 @@ def movefile(source, dest): os.rename(source, dest) +def copyfile(source, dest): + """Copy a file and its modification times, if possible.""" + shutil.copyfile(source, dest) + try: shutil.copystat(source, dest) + except shutil.Error: pass + + def copy_static_entry(source, target, builder, context={}): if path.isfile(source): if source.lower().endswith('_t'): @@ -403,7 +410,7 @@ def copy_static_entry(source, target, builder, context={}): fsrc.close() fdst.close() else: - shutil.copyfile(source, target) + copyfile(source, target) elif path.isdir(source): if source in builder.config.exclude_dirnames: return From 75cccedad15dd7e0abe8db1e33a864322eabf14e Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Tue, 28 Apr 2009 21:13:02 +0200 Subject: [PATCH 5/5] Fix cross-reference roles when put into substitutions. --- CHANGES | 2 ++ sphinx/addnodes.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 128e6e9a4..619076269 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,8 @@ Release 0.6.2 (in development) ============================== +* Fix cross-reference roles when put into substitutions. + * Don't put image "alt" text into table-of-contents entries. * In the LaTeX writer, do not raise an exception on too many section diff --git a/sphinx/addnodes.py b/sphinx/addnodes.py index 63907a0e6..b8c9a3544 100644 --- a/sphinx/addnodes.py +++ b/sphinx/addnodes.py @@ -63,7 +63,7 @@ class toctree(nodes.General, nodes.Element): pass class centered(nodes.Part, nodes.Element): pass # pending xref -class pending_xref(nodes.Element): pass +class pending_xref(nodes.Inline, nodes.Element): pass # compact paragraph -- never makes a

class compact_paragraph(nodes.paragraph): pass