only match sections at top level

This commit is contained in:
j 2014-12-01 18:12:22 +01:00
parent 55322cce67
commit c0e665eb67

View file

@ -31,10 +31,10 @@ def update(config_jsonc='config.jsonc', base='config.pandora.jsonc'):
current_docs = get(config_jsonc)
for key in docs:
if key in current_docs:
match = re.escape(' '+docs[key]) + '\W+"' + re.escape(key) + '":'
match = '\n' + re.escape(' '+docs[key]) + '\W+"' + re.escape(key) + '":'
else:
match = ' "' + re.escape(key) + '":'
data = re.sub(match, ' %s\n "%s":' % (docs[key], key), data)
match = '\n "' + re.escape(key) + '":'
data = re.sub(match, '\n %s\n "%s":' % (docs[key], key), data)
if data != config:
print('updating config documentation', config_jsonc)
with open('%s' % config_jsonc, 'wb') as fd: