There is a lot of variation to how sections are handled (skins change it, Minerva has collapsing sections, Parsoid HTML might or might not have <section> wrappers making sections easy to identify, DiscussionTools changes section headers significantly, Flow does its own thing) which makes a section-level entry point challanging to do in a robust way.
It would be nice to have a stable API for gadgets which provides the following functionality:
- Access TOC data (list of sections, with level, HTML ID / anchor, plain text of the section title (either the wikitext or the plaintextified HTML))
- Add a button with a click handler to a specified section. On most skins this might look like the [edit] link, on Minerva it might use some sort of icon; or maybe just take an arbitrary DOM element and plug it into the right place.
- Maybe section collapse/uncollapse functionality if the skin supports it.