diff options
| author | Georg Brandl <georg@python.org> | 2013-03-29 13:01:21 +0100 |
|---|---|---|
| committer | Georg Brandl <georg@python.org> | 2013-03-29 13:01:21 +0100 |
| commit | 07530ab75b2b78a2d3d0fc71759e6653094f4ae0 (patch) | |
| tree | 3ff0b743cf5613e4bfacc62749ea632621c5d68f /sphinx/builders/html.py | |
| parent | 2706e741769b3008cd2379e2d742c9d29241a375 (diff) | |
| parent | fdd89341a104a26628a69dd70c1441df72e5282b (diff) | |
| download | sphinx-07530ab75b2b78a2d3d0fc71759e6653094f4ae0.tar.gz | |
merge with parallel repo
Diffstat (limited to 'sphinx/builders/html.py')
| -rw-r--r-- | sphinx/builders/html.py | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/sphinx/builders/html.py b/sphinx/builders/html.py index 32376333..67b55ed8 100644 --- a/sphinx/builders/html.py +++ b/sphinx/builders/html.py @@ -53,6 +53,19 @@ INVENTORY_FILENAME = 'objects.inv' LAST_BUILD_FILENAME = 'last_build' +def get_stable_hash(obj): + """ + Return a stable hash for a Python data structure. We can't just use + the md5 of str(obj) since for example dictionary items are enumerated + in unpredictable order due to hash randomization in newer Pythons. + """ + if isinstance(obj, dict): + return get_stable_hash(list(obj.items())) + elif isinstance(obj, (list, tuple)): + obj = sorted(get_stable_hash(o) for o in obj) + return md5(unicode(obj).encode('utf8')).hexdigest() + + class StandaloneHTMLBuilder(Builder): """ Builds standalone HTML docs. @@ -157,9 +170,8 @@ class StandaloneHTMLBuilder(Builder): cfgdict = dict((name, self.config[name]) for (name, desc) in self.config.values.iteritems() if desc[1] == 'html') - self.config_hash = md5(unicode(cfgdict).encode('utf-8')).hexdigest() - self.tags_hash = md5(unicode(sorted(self.tags)).encode('utf-8')) \ - .hexdigest() + self.config_hash = get_stable_hash(cfgdict) + self.tags_hash = get_stable_hash(sorted(self.tags)) old_config_hash = old_tags_hash = '' try: fp = open(path.join(self.outdir, '.buildinfo')) @@ -293,7 +305,7 @@ class StandaloneHTMLBuilder(Builder): self.relations = self.env.collect_relations() rellinks = [] - if self.config.html_use_index: + if self.get_builder_config('use_index', 'html'): rellinks.append(('genindex', _('General Index'), 'I', _('index'))) for indexname, indexcls, content, collapse in self.domain_indices: # if it has a short name @@ -441,7 +453,7 @@ class StandaloneHTMLBuilder(Builder): self.handle_page(pagename, context, template) # the global general index - if self.config.html_use_index: + if self.get_builder_config('use_index', 'html'): self.write_genindex() # the global domain-specific indices |
