X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=generate-documentation.py;h=155393b8a32912604f4d80e0b881cc4c56af6ae4;hb=606568fef36a321148399da4c58a05e2753ac2f9;hp=5b6400f35b38710f63dae18fee99f3b41c8ae245;hpb=0e37f8e5b44d3e747be8ad87fa47cc734a630626;p=dygraphs.git
diff --git a/generate-documentation.py b/generate-documentation.py
index 5b6400f..155393b 100755
--- a/generate-documentation.py
+++ b/generate-documentation.py
@@ -3,6 +3,7 @@ import json
import glob
import re
+# Pull options reference JSON out of dygraph.js
js = ''
in_json = False
for line in file('dygraph.js'):
@@ -21,6 +22,8 @@ docs = json.loads(js)
for opt in docs:
docs[opt]['tests'] = []
+# This is helpful for differentiating uses of options like 'width' and 'height'
+# from appearances of identically-named options in CSS.
def find_braces(txt):
"""Really primitive method to find text inside of {..} braces.
Doesn't work if there's an unmatched brace in a string, e.g. '{'. """
@@ -35,7 +38,9 @@ def find_braces(txt):
level -= 1
return out
-prop_re = re.compile(r'\b([a-zA-Z]+):')
+# Find text followed by a colon. These won't all be options, but those that
+# have the same name as a Dygraph option probably will be.
+prop_re = re.compile(r'\b([a-zA-Z0-9]+):')
for test_file in glob.glob('tests/*.html'):
braced_html = find_braces(file(test_file).read())
ms = re.findall(prop_re, braced_html)
@@ -43,28 +48,114 @@ for test_file in glob.glob('tests/*.html'):
if opt in docs and test_file not in docs[opt]['tests']:
docs[opt]['tests'].append(test_file)
+# Extract a labels list.
+labels = []
+for nu, opt in docs.iteritems():
+ for label in opt['labels']:
+ if label not in labels:
+ labels.append(label)
+
+print """
+
+
Dygraphs tries to do a good job of displaying your data without any further configuration. But inevitably, you're going to want to tinker. Dygraphs provides a rich set of options for configuring its display and behavior.