From 88b1e0523dbc8d0dd9186592e8b633ccb014adbe Mon Sep 17 00:00:00 2001 From: Dan Vanderkam Date: Sun, 13 Mar 2011 15:40:33 -0400 Subject: [PATCH] more comments --- generate-documentation.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/generate-documentation.py b/generate-documentation.py index 5b6400f..e06c223 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) @@ -44,6 +49,7 @@ for test_file in glob.glob('tests/*.html'): docs[opt]['tests'].append(test_file) def name(f): + """Takes 'tests/demo.html' -> 'demo'""" return f.replace('tests/', '').replace('.html', '') for opt_name in sorted(docs.keys()): -- 2.7.4