Skip to content

Commit

Permalink
feat: checking for key redefinition
Browse files Browse the repository at this point in the history
  • Loading branch information
gvwilson committed Apr 5, 2024
1 parent 6f74504 commit 2988109
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions lib/mccole/bin/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
import shortcodes
import yaml

UNIQUE_KEYS = {
"fig_def",
"gloss",
"tbl_def",
}


def main():
options = parse_args()
Expand Down Expand Up @@ -85,7 +91,7 @@ def collect_fig_def(pargs, kwargs, found):
"""Collect data from a figure definition shortcode."""
slug = kwargs["slug"]
if slug in found["fig_def"]:
print("Duplicate definition of figure slug {slug}")
print(f"Duplicate definition of figure slug {slug}")
else:
found["fig_def"].add(slug)

Expand Down Expand Up @@ -189,7 +195,10 @@ def reorganize_found(node, kind, collected, found):
for key in found[kind]:
if key not in collected[kind]:
collected[kind][key] = set()
collected[kind][key].add(node.slug if node.slug else "@root")
elif kind in UNIQUE_KEYS:
print(f"{kind} key {key} redefined")
slug = node.slug if node.slug else "@root"
collected[kind][key].add(slug)


if __name__ == "__main__":
Expand Down

0 comments on commit 2988109

Please sign in to comment.