mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Holger Schurig <holgerschurig@gmail.com>
To: barebox@lists.infradead.org
Subject: [PATCH 3/5] Documentation: only write changed *.rst files
Date: Tue, 22 Jul 2014 09:56:47 +0200	[thread overview]
Message-ID: <1406015809-20711-4-git-send-email-holgerschurig@gmail.de> (raw)

From: Holger Schurig <holgerschurig@gmail.com>

Documentation/gen_commands.py use to re-write all auto-generated *.rst
file, changed or not. That in turn didn't work well with the internal
cache of the Sphinx documentation generator.

By comparing the SHA1 hash of the newly generated *.rst with the
current sha1 file, the time to execute "make docs" can be reduced
from 6.2s to 2.4s on my humble laptop.
---
 Documentation/gen_commands.py | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/Documentation/gen_commands.py b/Documentation/gen_commands.py
index d3db350..eadea9e 100755
--- a/Documentation/gen_commands.py
+++ b/Documentation/gen_commands.py
@@ -4,6 +4,7 @@ import errno
 import os
 import re
 import sys
+import hashlib
 
 from collections import defaultdict
 from pprint import pprint
@@ -169,5 +170,18 @@ for name, cmd in CMDS.items():
     else:
       raise
   target = os.path.join(subdir, name+'.rst')
+
+  # Only write the new rst if it differs from the old one. Wroto
+  hash_old = hashlib.sha1()
+  try:
+    f = open(target, 'rb')
+    hash_old.update(f.read())
+  except:
+    pass
+  hash_new = hashlib.sha1()
+  hash_new.update(rst)
+  if hash_old.hexdigest() == hash_new.hexdigest():
+    continue
+
   file(target, 'w').write(rst)
 
-- 
1.8.5.2


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

                 reply	other threads:[~2014-07-22  7:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1406015809-20711-4-git-send-email-holgerschurig@gmail.de \
    --to=holgerschurig@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox