I’d very much like to work on a package that can toggle folding or unfolding all comments in a document. I work on a few projects that have extensive inline docs, and when working on the code myself I like to have them folded away to be able to navigate the source more easily.
I’ve spent a little time looking through the API docs, but really am not sure where to start as far as making this happen. I know that you have access to
document and can select all elements that have a
.comment class on them, which does correctly return everything I need to fold, but it seems like the fold method operates on a selection which requires a Range to set where it is.
Based this, it doesn’t seem like selecting the already comments from the DOM will interop with the machinery for folding them (which is too bad), which I suppose means that you’d need to do a manual text search to discern comments somehow (maybe there’s a way I can get a comment syntax regex from the current syntax highlighter?), build ranges from where they are, then select, fold, and move on to the next one. At the same time this all sounds very difficult.
Can anyone that has a good knowledge of Atom and/or plugins help push me in the right direction of what would be the most efficient way to build a plugin like this?