Conversation
This macro allows you to include a portion of a file like this:
```
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests}/DeleteDocumentationIT.java[delete-request]
--------------------------------------------------
<1> Index name
<2> Type
<3> Document id
```
Which can be used to extract a section of a file like this:
```
// tag::delete-request
DeleteRequest request = new DeleteRequest(
"index", // <1>
"type", // <2>
"id"); // <3>
// end::delete-request
```
|
I gave a quick look at it (well I'm not a Python guy :) ). It looks good. I guess that automatically find what is the indentation of the tag with |
Right. We copy the indentation of the tag and strip it from all the other fields. At least, that is what I tried to do. |
resources/es-asciidoc.conf
Outdated
| </phrase> | ||
|
|
||
| [include-tagged-inlinemacro] | ||
| # it is a nightmare to get this to work with eval3 so we're forking a new process every time.... |
There was a problem hiding this comment.
I think eval3 should be sys3 actually.
|
@clintongormley, do you want to have a look at this? |
clintongormley
left a comment
There was a problem hiding this comment.
I've improved the error reporting a bit to give the user more context. With that change in place, it's good to merge
| indentation = m.group(1) | ||
|
|
||
|
|
||
| if __name__ == '__main__': |
There was a problem hiding this comment.
I'd tidy up the error output a bit, to look more like this:
if __name__ == '__main__':
from sys import argv, stdout, stderr
try:
result = extract_tagged(argv[1], argv[2])
if result:
stdout.write(result)
else:
raise Exception("Couldn't find tag")
except Exception as e:
stderr.write("asciidoc: ERROR: Extracting tag `" + argv[2] + "` from file `" + argv[1]+ "`: " + e.__str__() + "\n")
exit(1)
|
Thanks @clintongormley! |
This macro allows you to include a portion of a file like this:
Which can be used to extract a section of a file like this: