mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
fix: output all html every time with python3.3.
Sphinx detect config changing by hash(str(cfgdict)). In python3.3, str(dict_instance) retun another string per process.
This commit is contained in:
parent
6e4a36d2fe
commit
a1bf7dbcf8
@ -53,6 +53,23 @@ INVENTORY_FILENAME = 'objects.inv'
|
|||||||
LAST_BUILD_FILENAME = 'last_build'
|
LAST_BUILD_FILENAME = 'last_build'
|
||||||
|
|
||||||
|
|
||||||
|
def get_object_hash(obj):
|
||||||
|
"""
|
||||||
|
In python3.3, unicode(dict_instance) retun another string per process.
|
||||||
|
get_object_hash(dict_instance) return same hash for same dict_instance.
|
||||||
|
"""
|
||||||
|
if isinstance(obj, dict):
|
||||||
|
return get_object_hash(list(obj.items()))
|
||||||
|
|
||||||
|
elif isinstance(obj, (list, tuple)):
|
||||||
|
obj = sorted(get_object_hash(o) for o in obj)
|
||||||
|
|
||||||
|
else: # int or other objects
|
||||||
|
pass
|
||||||
|
|
||||||
|
return md5(unicode(obj).encode('utf8')).hexdigest()
|
||||||
|
|
||||||
|
|
||||||
class StandaloneHTMLBuilder(Builder):
|
class StandaloneHTMLBuilder(Builder):
|
||||||
"""
|
"""
|
||||||
Builds standalone HTML docs.
|
Builds standalone HTML docs.
|
||||||
@ -156,9 +173,8 @@ class StandaloneHTMLBuilder(Builder):
|
|||||||
cfgdict = dict((name, self.config[name])
|
cfgdict = dict((name, self.config[name])
|
||||||
for (name, desc) in self.config.values.iteritems()
|
for (name, desc) in self.config.values.iteritems()
|
||||||
if desc[1] == 'html')
|
if desc[1] == 'html')
|
||||||
self.config_hash = md5(unicode(cfgdict).encode('utf-8')).hexdigest()
|
self.config_hash = get_object_hash(cfgdict)
|
||||||
self.tags_hash = md5(unicode(sorted(self.tags)).encode('utf-8')) \
|
self.tags_hash = get_object_hash(sorted(self.tags))
|
||||||
.hexdigest()
|
|
||||||
old_config_hash = old_tags_hash = ''
|
old_config_hash = old_tags_hash = ''
|
||||||
try:
|
try:
|
||||||
fp = open(path.join(self.outdir, '.buildinfo'))
|
fp = open(path.join(self.outdir, '.buildinfo'))
|
||||||
|
Loading…
Reference in New Issue
Block a user