Add "source_encoding" config value.

This commit is contained in:
Georg Brandl 2008-10-16 19:21:06 +00:00
parent 918fbecb12
commit 516d1a2872
5 changed files with 23 additions and 4 deletions

View File

@ -55,6 +55,8 @@ New features added
- Added ``exclude_dirnames`` config value that can be used to exclude
e.g. CVS directories from source file search.
- Added ``source_encoding`` config value to select input encoding.
* Extensions:
- The new extensions ``sphinx.ext.jsmath`` and ``sphinx.ext.pngmath``

View File

@ -67,8 +67,16 @@ General configuration
.. confval:: source_suffix
The file name extension of source files. Only files with this suffix will be
read as sources. Default is ``.rst``.
read as sources. Default is ``'.rst'``.
.. confval:: source_encoding
The encoding of all reST source files. The recommended encoding, and the
default value, is ``'utf-8'``.
.. versionadded:: 0.5
Previously, Sphinx accepted only UTF-8 encoded sources.
.. confval:: master_doc
The document name of the "master" document, that is, the document that

View File

@ -35,6 +35,7 @@ class Config(object):
master_doc = ('contents', True),
source_suffix = ('.rst', True),
source_encoding = ('utf-8', True),
unused_docs = ([], True),
exclude_dirs = ([], True),
exclude_trees = ([], True),

View File

@ -496,9 +496,14 @@ class BuildEnvironment:
return data
self.docname = docname
doctree = publish_doctree(None, src_path, SphinxSourceClass,
settings_overrides=self.settings,
reader=SphinxStandaloneReader())
self.settings['input_encoding'] = self.config.source_encoding
try:
doctree = publish_doctree(None, src_path, SphinxSourceClass,
settings_overrides=self.settings,
reader=SphinxStandaloneReader())
except UnicodeError, err:
from sphinx.application import SphinxError
raise SphinxError(err.message)
self.filter_messages(doctree)
self.process_dependencies(docname, doctree)
self.process_images(docname, doctree)

View File

@ -54,6 +54,9 @@ templates_path = ['%(dot)stemplates']
# The suffix of source filenames.
source_suffix = '%(suffix)s'
# The encoding of source files.
#source_encoding = 'utf-8'
# The master toctree document.
master_doc = '%(master)s'