2020-07-20 01:34:14 +02:00
|
|
|
# Simple jq script to extract all TODO comments in the code base from
|
|
|
|
# ripgrep's JSON output.
|
|
|
|
#
|
|
|
|
# This assumes that the filter used is something like 'TODO\(\w+\):'
|
|
|
|
|
2021-04-01 16:19:50 +02:00
|
|
|
# Capture the username and todo entry from an input string.
|
|
|
|
def capture_todo:
|
|
|
|
capture("TODO\\((?<user>\\w+)\\):\\s+(?<todo>.*)$");
|
|
|
|
|
2020-07-20 01:34:14 +02:00
|
|
|
# Construct a structure with only the fields we need to populate the
|
|
|
|
# page.
|
|
|
|
def simplify_match:
|
2021-04-01 16:19:50 +02:00
|
|
|
.data as $data
|
|
|
|
| (.data.submatches[0].match.text | capture_todo) as $capture
|
2020-07-20 01:34:14 +02:00
|
|
|
| {
|
2021-04-01 16:19:50 +02:00
|
|
|
file: ($data | .path.text | sub("/nix/store/.+-depot/"; "")),
|
|
|
|
line: ($data | .line_number),
|
|
|
|
todo: ($capture | .todo),
|
|
|
|
user: ($capture | .user),
|
2020-07-20 01:34:14 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
# Group all matches first by the user and return them in sorted order
|
|
|
|
# by the file in which they appear. This matches the presentation
|
|
|
|
# order on the website.
|
|
|
|
def group_by_user: .
|
|
|
|
| group_by(.user)
|
|
|
|
| map(sort_by(.file));
|
|
|
|
|
|
|
|
# main:
|
|
|
|
map(select(.type == "match") | simplify_match) | group_by_user
|