MacPortsのSphinx 1.1.3にはまる

久しぶりにShphinxでドキュメント生成を行う。ソースを変更する前に、まずは既存の内容を確認するためhtmlを生成させてみるが、何故かエラーが発生してしまう。ログ出力の内容は下記の通り。

% make html
sphinx-build -b html -d _build/doctrees   . _build/html
Making output directory...
Running Sphinx v1.1.3
loading pickled environment... not yet created
building [html]: targets for 11 source files that are out of date
updating environment: 11 added, 0 changed, 0 removed
reading sources... [100%] src/unittest                                           
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [ 18%] src/class                                               
Exception occurred:
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/docutils/writers/html4css1/__init__.py", line 1026, in visit_image
    and self.settings.file_insertion_enabled):
AttributeError: Values instance has no attribute 'file_insertion_enabled'
The full traceback has been saved in /var/folders/b7/9czd2nnw8xldnr006s7d77980000gn/T/sphinx-err-BJ9KmA.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
Either send bugs to the mailing list at <http://groups.google.com/group/sphinx-dev/>,
or report them in the tracker at <http://bitbucket.org/birkenfeld/sphinx/issues/>. Thanks!
make: *** [html] Error 1

動作環境は次の通り。

前回のドキュメントはSphinx 1.0.7で問題なく生成出来ており、MacPortsSphinxを更新したどこかの時点から正常に動作しなくなっていたらしい。上記のログに出てきた__init__.pyを開いて、該当箇所を確認してみる。確かに指摘の1026行目には"self.settings.file_insertion_enabled"という記載があるものの、ログによればこのプロパティがどこにも設定されていないらしい。

バージョンアップに伴い必須プロパティが追加されているのだろうか?あいにく問題の根本原因まで調べる時間が無かったので、取りあえず問題のHTMLTranslatorクラスの__init__に、下記の初期化を追加した。(326行目辺り)

    self.author_in_authors = False
    self.math_header = ''
    self.settings.file_insertion_enabled = True  # Added (2012/6/3)

これでhtmlが正常に出力されることを確認した。

$ make clean
rm -rf _build/*
$ make html
sphinx-build -b html -d _build/doctrees   . _build/html
Making output directory...
Running Sphinx v1.1.3
loading pickled environment... not yet created
building [html]: targets for 11 source files that are out of date
updating environment: 11 added, 0 changed, 0 removed
reading sources... [100%] src/unittest                                          
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] src/unittest                                           
writing additional files... genindex search
copying images... [100%] img/nunitresult.png                                    
copying static files... done
dumping search index... done
dumping object inventory... done
build succeeded.

Build finished. The HTML pages are in _build/html.

環境依存の問題なのかもしれないけど、もし同様に事例に困っているならご参考までに。