Provide a custom Asciidoctor macro that reduces the boilerplate required to include snippets
See original GitHub issueThe basic idea is that rather than using an include
for each individual snippet, you can use a single macro to include all of the snippets for a particular operation that’s been documented. For added flexibility, the macro could use attributes to control which snippets are included.
I prototyped this a while ago as a custom target for the include
macro: https://github.com/wilkinsona/springrestdocs/commit/6657af0d590be2673f05d7ecd8f1a91244751edc. I think this could be further refined so that it becomes something like operation::{snippets}/operation-name
.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:5
- Comments:37 (19 by maintainers)
Top Results From Across the Web
Includes | Asciidoctor Docs
Reuse content snippets and boilerplate content, such as term definitions, disclaimers, etc., multiple times within the same document. Include directive syntax.
Read more >AsciiDoc Syntax Quick Reference - Asciidoctor Docs
The link: macro prefix is not required when the target starts with a URL ... If you use a line comment, the convention...
Read more >Macro Substitutions | Asciidoctor Docs
The content of inline and block macros, such as cross references, links, and block images, are processed by the macros substitution step.
Read more >AsciiDoc Writer's Guide | Asciidoctor
In those cases, you'll need to use markup to escape the text. ... The triple-plus macro is often used to output custom HTML...
Read more >Asciidoctor User Manual
This guide describes the Asciidoctor attributes, values, and layout options available for producing a customized and polished document.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks @mojavelinux , somehow I was mixing up options and attributes.
For now I have the Ruby based extension running included in the spring-restdocs-asciidoctor module and used in one of the samples and it is including static input. Next stop: loading snippets.
Btw. the same approach also works with Java but feels “not so right”. Maybe I will show both ones in the end.
Aha. The problem is that right now, the
parse_content
method assumes it’s only dealing with non-section content. Upon reflection, this feels like a bad assumption. But we’ll have to deal with it upstream.If what you are parsing includes sections, you have 3 options:
I don’t think you really want (3), and (1) is way too risky. So let’s focus on (2).
The fragment attribute is important because it informs the parser that the source is a document fragment and should not be validated as a standalone document. Specifically, this allows the top-level section titles to start at any level.
It’s clear we need a method in the extensions API that performs a similar operation. That method would also be careful to carry over all processor options so that the parser is operating with the same configuration. But this code is sufficient portable for your needs, I think.