From 259750277a67bcc89377cbe9456c463cb3f5a59a Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 20 Jul 2020 00:34:14 +0100 Subject: feat(web/todolist): Implement a "todo-list" page generator This invokes ripgrep & jq to construct a list of TODOs from known users across depot sources, and dumps it into a static page that we can serve. The structure is relatively simple, but it might be useful. See here for an example of what this looks like: https: //tazj.in/blobs/todos.png Change-Id: I1edef56606273584ab886b9e762c8ed4d210919d Reviewed-on: https://cl.tvl.fyi/c/depot/+/1296 Tested-by: BuildkiteCI Reviewed-by: Alyssa Ross --- web/todolist/extract-todos.jq | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 web/todolist/extract-todos.jq (limited to 'web/todolist/extract-todos.jq') diff --git a/web/todolist/extract-todos.jq b/web/todolist/extract-todos.jq new file mode 100644 index 0000000000..cda717fceb --- /dev/null +++ b/web/todolist/extract-todos.jq @@ -0,0 +1,25 @@ +# 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+\):' + +# Construct a structure with only the fields we need to populate the +# page. +def simplify_match: + .data.submatches[0].match.text as $todo + | { + file: (.data.path.text | sub("/nix/store/.+-depot/"; "")), + line: .data.line_number, + todo: $todo, + user: ($todo | capture("TODO\\((?\\w+)\\)") | .user), + }; + +# 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 -- cgit 1.4.1