[gtk-doc] tools/c10e-html: add a tool to ease diffing html files



commit 943cfaa2657933f21e7e2dbe9be2caaa71b6bd8a
Author: Stefan Sauer <ensonic users sf net>
Date:   Tue Apr 3 08:54:29 2018 +0200

    tools/c10e-html: add a tool to ease diffing html files

 tools/c10e-html.py |   38 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/tools/c10e-html.py b/tools/c10e-html.py
new file mode 100755
index 0000000..d90ff7b
--- /dev/null
+++ b/tools/c10e-html.py
@@ -0,0 +1,38 @@
+#!/usr/bin/python3
+# canonicalize html dirs to ease comaring them
+#
+# run as:
+# ./tools/c10e-html html
+
+import argparse
+import glob
+import os
+import sys
+
+from bs4 import BeautifulSoup
+
+
+def prettify(filename):
+    with open(filename, 'r') as doc:
+        soup = BeautifulSoup(doc.read(), 'lxml')
+    with open(filename, 'w') as doc:
+        doc.write(soup.prettify())
+
+
+def main(htmldir):
+    for filename in glob.glob(os.path.join(htmldir, '*.devhelp2')):
+        prettify(filename)
+    for filename in glob.glob(os.path.join(htmldir, '*.html')):
+        prettify(filename)
+
+
+if __name__ == '__main__':
+    parser = argparse.ArgumentParser(
+        description='c10e-html - canonicalize html files for diffing')
+    parser.add_argument('args', nargs='*',  help='HTML_DIR')
+
+    options = parser.parse_args()
+    if len(options.args) < 1:
+        sys.exit('Too few arguments')
+
+    main(options.args[0])


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]