Skip to content
This repository has been archived by the owner on Jan 3, 2018. It is now read-only.

Checking glossary #512

Merged
merged 4 commits into from
May 26, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ contribs :
fixme :
grep -i -n FIXME $$(find novice -type f -print | grep -v .ipynb_checkpoints)

## gloss : check the glossary.
gloss : $(INDEX)
python bin/gloss.py gloss.md $(patsubst %.md,$(SITE)/%.html,$(MOST_SRC))

## tidy : clean up odds and ends.
tidy :
rm -rf \
Expand Down
18 changes: 8 additions & 10 deletions bin/gloss.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def get_gloss_entries(filename):
(initially all 0). Checks along the way that internal definitions
resolve.'''

# Entry pattern: 0 = key, 1 = abbrev, 2 = term
p_entry = re.compile(r'\*\*([^\*]+)\*\*(\s+\(.+\))?:\s+<a\s+name="([^"]+)"></a>')
# Entry pattern: 1 = key, 2 = term, optional 3 = abbrev
p_entry = re.compile(r'\*\*<a\s+name="([^"]+)">(.+)</a>\*\*(\s+\((.+)\))?:')

# Use pattern: 0 = key
p_use = re.compile(r'\([^\)]+\)\[\#([^\]]+)\]')
Expand All @@ -38,14 +38,12 @@ def get_gloss_entries(filename):
for line in reader:
m = p_entry.search(line)
if m:
text = m.group(1)
if text == 'FIXME':
undone += 1
else:
if text.lower() < last_seen:
out_of_order.append(text)
last_seen = text.lower()
key = m.group(3)
key = m.group(1)
text = m.group(2)
abbrev = m.group(3)
if text.lower() < last_seen:
out_of_order.append(text)
last_seen = text.lower()
if key in result:
print 'Duplicate key {0} in {1}'.format(key, filename)
result[key] = 0
Expand Down
Loading