mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Incompatibility. Now :confval:gettext_uuid
is set False by default. If False, also levenshtein calculation is disabled. refs #1426
This commit is contained in:
parent
5eb459f5a6
commit
ee98decec1
2
CHANGES
2
CHANGES
@ -20,6 +20,8 @@ Incompatible changes
|
|||||||
templates directory.
|
templates directory.
|
||||||
* Custom domains should implement the new `Domain.resolve_any_xref`
|
* Custom domains should implement the new `Domain.resolve_any_xref`
|
||||||
method to make the `any` role work properly.
|
method to make the `any` role work properly.
|
||||||
|
* gettext builder: gettext doesn't emit uuid information to generated pot files
|
||||||
|
by default. Please set ``True`` to `gettext_uuid` to emit uuid information.
|
||||||
* gettext builder: disable extracting/apply 'index' node by default. Please set
|
* gettext builder: disable extracting/apply 'index' node by default. Please set
|
||||||
'index' to :confval:`gettext_enables` to enable extracting index entries.
|
'index' to :confval:`gettext_enables` to enable extracting index entries.
|
||||||
|
|
||||||
|
@ -424,9 +424,13 @@ documentation on :ref:`intl` for details.
|
|||||||
.. confval:: gettext_uuid
|
.. confval:: gettext_uuid
|
||||||
|
|
||||||
If true, Sphinx generates uuid information for version tracking in message
|
If true, Sphinx generates uuid information for version tracking in message
|
||||||
catalogs.
|
catalogs. It is used for:
|
||||||
|
|
||||||
The default is ``True``.
|
* Add uid line for each msgids in .pot files.
|
||||||
|
* Calculate similarity between new msgids and previously saved old msgids.
|
||||||
|
This calculation take many time.
|
||||||
|
|
||||||
|
The default is ``False``.
|
||||||
|
|
||||||
.. versionadded:: 1.3
|
.. versionadded:: 1.3
|
||||||
|
|
||||||
|
@ -42,12 +42,14 @@ class Builder(object):
|
|||||||
format = ''
|
format = ''
|
||||||
# doctree versioning method
|
# doctree versioning method
|
||||||
versioning_method = 'none'
|
versioning_method = 'none'
|
||||||
|
versioning_compare = False
|
||||||
# allow parallel write_doc() calls
|
# allow parallel write_doc() calls
|
||||||
allow_parallel = False
|
allow_parallel = False
|
||||||
|
|
||||||
def __init__(self, app):
|
def __init__(self, app):
|
||||||
self.env = app.env
|
self.env = app.env
|
||||||
self.env.set_versioning_method(self.versioning_method)
|
self.env.set_versioning_method(self.versioning_method,
|
||||||
|
self.versioning_compare)
|
||||||
self.srcdir = app.srcdir
|
self.srcdir = app.srcdir
|
||||||
self.confdir = app.confdir
|
self.confdir = app.confdir
|
||||||
self.outdir = app.outdir
|
self.outdir = app.outdir
|
||||||
|
@ -84,6 +84,11 @@ class I18nBuilder(Builder):
|
|||||||
"""
|
"""
|
||||||
name = 'i18n'
|
name = 'i18n'
|
||||||
versioning_method = 'text'
|
versioning_method = 'text'
|
||||||
|
versioning_compare = None # be set by `gettext_uuid`
|
||||||
|
|
||||||
|
def __init__(self, app):
|
||||||
|
self.versioning_compare = app.env.config.gettext_uuid
|
||||||
|
super(I18nBuilder, self).__init__(app)
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
Builder.init(self)
|
Builder.init(self)
|
||||||
|
@ -27,6 +27,7 @@ class WebSupportBuilder(PickleHTMLBuilder):
|
|||||||
"""
|
"""
|
||||||
name = 'websupport'
|
name = 'websupport'
|
||||||
versioning_method = 'commentable'
|
versioning_method = 'commentable'
|
||||||
|
versioning_compare = True # for commentable node's uuid stability.
|
||||||
|
|
||||||
def init(self):
|
def init(self):
|
||||||
PickleHTMLBuilder.init(self)
|
PickleHTMLBuilder.init(self)
|
||||||
|
@ -209,7 +209,7 @@ class Config(object):
|
|||||||
# gettext options
|
# gettext options
|
||||||
gettext_compact = (True, 'gettext'),
|
gettext_compact = (True, 'gettext'),
|
||||||
gettext_location = (True, 'gettext'),
|
gettext_location = (True, 'gettext'),
|
||||||
gettext_uuid = (True, 'gettext'),
|
gettext_uuid = (False, 'gettext'),
|
||||||
gettext_auto_build = (True, 'env'),
|
gettext_auto_build = (True, 'env'),
|
||||||
gettext_enables = ([], 'env'),
|
gettext_enables = ([], 'env'),
|
||||||
|
|
||||||
|
@ -194,6 +194,7 @@ class BuildEnvironment:
|
|||||||
|
|
||||||
# the method of doctree versioning; see set_versioning_method
|
# the method of doctree versioning; see set_versioning_method
|
||||||
self.versioning_condition = None
|
self.versioning_condition = None
|
||||||
|
self.versioning_compare = None
|
||||||
|
|
||||||
# the application object; only set while update() runs
|
# the application object; only set while update() runs
|
||||||
self.app = None
|
self.app = None
|
||||||
@ -268,7 +269,7 @@ class BuildEnvironment:
|
|||||||
self._warnfunc = func
|
self._warnfunc = func
|
||||||
self.settings['warning_stream'] = WarningStream(func)
|
self.settings['warning_stream'] = WarningStream(func)
|
||||||
|
|
||||||
def set_versioning_method(self, method):
|
def set_versioning_method(self, method, compare):
|
||||||
"""This sets the doctree versioning method for this environment.
|
"""This sets the doctree versioning method for this environment.
|
||||||
|
|
||||||
Versioning methods are a builder property; only builders with the same
|
Versioning methods are a builder property; only builders with the same
|
||||||
@ -284,6 +285,7 @@ class BuildEnvironment:
|
|||||||
'selected builder, please choose another '
|
'selected builder, please choose another '
|
||||||
'doctree directory.')
|
'doctree directory.')
|
||||||
self.versioning_condition = condition
|
self.versioning_condition = condition
|
||||||
|
self.versioning_compare = compare
|
||||||
|
|
||||||
def warn(self, docname, msg, lineno=None):
|
def warn(self, docname, msg, lineno=None):
|
||||||
"""Emit a warning.
|
"""Emit a warning.
|
||||||
@ -776,19 +778,21 @@ class BuildEnvironment:
|
|||||||
time.time(), path.getmtime(self.doc2path(docname)))
|
time.time(), path.getmtime(self.doc2path(docname)))
|
||||||
|
|
||||||
if self.versioning_condition:
|
if self.versioning_condition:
|
||||||
# get old doctree
|
old_doctree = None
|
||||||
try:
|
if self.versioning_compare:
|
||||||
f = open(self.doc2path(docname,
|
# get old doctree
|
||||||
self.doctreedir, '.doctree'), 'rb')
|
|
||||||
try:
|
try:
|
||||||
old_doctree = pickle.load(f)
|
f = open(self.doc2path(docname,
|
||||||
finally:
|
self.doctreedir, '.doctree'), 'rb')
|
||||||
f.close()
|
try:
|
||||||
except EnvironmentError:
|
old_doctree = pickle.load(f)
|
||||||
old_doctree = None
|
finally:
|
||||||
|
f.close()
|
||||||
|
except EnvironmentError:
|
||||||
|
pass
|
||||||
|
|
||||||
# add uids for versioning
|
# add uids for versioning
|
||||||
if old_doctree is None:
|
if not self.versioning_compare or old_doctree is None:
|
||||||
list(add_uids(doctree, self.versioning_condition))
|
list(add_uids(doctree, self.versioning_condition))
|
||||||
else:
|
else:
|
||||||
list(merge_doctrees(
|
list(merge_doctrees(
|
||||||
|
@ -57,6 +57,9 @@ def merge_doctrees(old, new, condition):
|
|||||||
if old_node is None:
|
if old_node is None:
|
||||||
new_nodes.append(new_node)
|
new_nodes.append(new_node)
|
||||||
continue
|
continue
|
||||||
|
if not getattr(old_node, 'uid', None):
|
||||||
|
# maybe config.gettext_uuid has been changed.
|
||||||
|
old_node.uid = uuid4().hex
|
||||||
if new_node is None:
|
if new_node is None:
|
||||||
old_nodes.append(old_node)
|
old_nodes.append(old_node)
|
||||||
continue
|
continue
|
||||||
|
Loading…
Reference in New Issue
Block a user