I'm happy to report that this is exactly the use case the Asciidoctor API was designed to handle.
If you're just interested in the outline of sections, I refer you to the method in the HTML5 converter that generates the table of contents. That should give you a taste of what is possible. (In this method, "node" is the Document instance).
You might also find the find_by method on any block node to be useful. It allows you to do a depth search for nodes that match the parameters. For instance, to find all paragraphs, you can use:
paragraphs = doc.find_by context: :paragraph