Skip to content

Instantly share code, notes, and snippets.

@frebib
Created January 30, 2018 22:38
Show Gist options
  • Save frebib/f04b39c73b953ca9623f777029c4b4b9 to your computer and use it in GitHub Desktop.
Save frebib/f04b39c73b953ca9623f777029c4b4b9 to your computer and use it in GitHub Desktop.
Generate a markdown TODO list from project source files.
#!/bin/sh
set -e
# This script requires ripgrep and sed.
# Save as .git/hooks/pre-commit for automatic TODO list updates when committing to git.
echo "Updating TODO list"
rg \
--heading \
--sort-files \
--line-number \
-g '!TODO.md' \
'TODO' \
| sed \
-e '/\(^[0-9]\|^\s*$\)/!s/^\s*\(.*\)\s*$/## [\1]\(\1\)/g' \
-e '/^\s*##\s*$/s///g' \
-e 's|\s*//\s*TODO:\s*| |g' \
-e '/^[0-9]/s/^/ - Line /g' \
-e '1i# A list of every _todo_ comment in this project\n**Please note:** _This file is automatically generated from all TODO comments found within the code_' \
> TODO.md
git diff TODO.md | cat
git add TODO.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment