Adding a Table of TODOs to a Google Document

I have been working on a document that details the changes needed to migrate a system from Java 8 to OpenJDK 11. While writing documents I add notes to myself in-situ, eg "TODO: Buy bread and milk before the next nor'easter." As the document was getting longer and the TODOs were mounting an itch was developing. I wanted a "Table of TODOs."

I use Google Docs and so the itch was scratched using Google's App Script. The script collects the text of all the TODO paragraphs and organizes them under a Table of TODOs heading. The TODO is a normal-styled paragraph that starts with "TODO: ". The Table of TODOs is a heading-styled paragraph that contains only "Table of TODOs". The script organizes the TODO texts in to numbered list items under the heading. The script also adds a Bookmark to each TODO paragraph so that it can be referenced from the numbered list item. To see the example you will need a Google account and to make a copy before you can view the script (under Tools / Script editor). [Update: Placed the script in a gist.]

The script was far more difficult to write than I expected. Google's scripting documentation is sparse and the IDE would randomly stop working. There is noApp Script language documentation (a mixed set of JavaScript versions) and the documentation for the Document API is a bare description of each class. Searching for help was hindered by the generality of any kind of questions I had, eg "google app script api bookmark" was more likely to get results about using URI bookmarks in Chrome. I am sure there are good resources and communities out there, but I have not found them yet. I will keep looking as the Google Suite can be combined into sophisticated applications and I would like to know how to do that.