balena-io / balena-masterclass-skeleton

A template skeleton base for balena masterclasses
2 stars 6 forks source link

Add ToC autogeneration hook #8

Open xginn8 opened 4 years ago

xginn8 commented 4 years ago

Having a table of contents for each masterclass would make navigation easier. We should be able to autogenerate that fairly easily as a precommit git hook, using something like https://github.com/thlorenz/doctoc perhaps.

cc @hedss @garethtdavies

garethtdavies commented 4 years ago

doctoc works great for manual generation - I used doctoc README.md --github --notitle. Output here. However, I hit this issue when using it as a pre-commit hook https://github.com/thlorenz/doctoc/issues/161. I'm also concerned adding a git hook also becomes a barrier to quick/trivial contributions, which are unlikely to change the structure of the document and having to install the dependencies etc...

It does emit a nice warning not to manually edit:

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
.....
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
hedss commented 4 years ago

I've started looking at Markdown All In One with Gareth suggested, and the table seems to work fine with the GH compatibility enabled. I'm going to add this to the Docker MC I'm writing and see how it goes.