Retrieve all images in catalog during conversion#1171
Conversation
|
Thanks for starting the work on enhancing the catalogAssets feature!
Can you shed some light on what is failing? I see that we're not returning the Document object when converting to a file, just returning null instead. |
Yes, haven't had time to check yet. I assume there's some error in the bindings that should not be very complicated 🤞 |
78efe30 to
4a6ed03
Compare
|
I see we explicitly check the return type and just insert null And going back into the git history I could not find a real reason for it, seems to come from initial versions and it has been preserved. Could be that we considered returning Document odd when the Java AST was not well defined. I think the best is to align with Asciidoctor Ruby and we should not take actions that limit functionality. Unless we want to create new methods to distinguish "conversion" from "conversion + return AST", but given the combinations of methods and options are already not simple (eg. convert + toFile == convert_file), I would not add more layers. So I changed the check that returned null to actually return Document, and furthermore seeing the code now I see why |
78e0a63 to
4b49877
Compare
4b49877 to
0395c8a
Compare
|
I can't recall if this has always been the case, or whether I changed it to this to avoid the problems with the wrappers generated by JRuby. |
0395c8a to
d547961
Compare
That's my idea, adaptReturn takes care of it for now in a simple way. In another PR we can improve and create some fancy Java class ReturnTypeAdapterVisitorPattern. I just updated the changelog, nothing else to add or change from me. |
| private <T> T adaptReturn(IRubyObject object, Class<T> expectedResult) { | ||
| if (NodeConverter.NodeType.DOCUMENT_CLASS.isInstance(object)) { | ||
| if (Document.class.isAssignableFrom(expectedResult)) { | ||
| return (T) new DocumentImpl(object); |
There was a problem hiding this comment.
Maybe it would be better to use NodeConverter.createNode() if expectedResult is Document.class?
Then we would keep NodeConverter as the only class that creates AST nodes.
d547961 to
5086248
Compare
* Current implementation works correctly when using load+getContent, convert and convertFile. * Fix 'convert' & 'convertFile' to correctly return Document type when applies * Fix WhenTwoAsciidoctorInstancesAreCreated test, not being run and having invalid code * Format RubyGemsPreloader.java and use immutable Map for options * Remove unused method JRubyAsciidoctor.scanForAsciiDocFiles
|
Unless objected, this being a new feature I am not considering porting to v2.5.x |
|
anything else to improve? 👀 |
|
Sorry for being behind a bit, I'll check it over the weekend. |
|
Thanks! Looks good to me. |
|
Thanks! |
Remove unnecessary 'gem' packaging during upstream gem installation. * Bump 'com.github.jruby-gradle.base' to v2.0.1 * Bump 'gem-maven-plugin' to v2.0.1 * Remove some unnecessary test files and configurations Fixes asciidoctor#1171
Remove unnecessary 'gem' packaging during upstream gem installation. * Bump 'com.github.jruby-gradle.base' to v2.0.1 * Bump 'gem-maven-plugin' to v2.0.1 * Remove some unnecessary test files and configurations Fixes asciidoctor#1171
Kind of change
Description
What is the goal of this pull request?
DRAFT PR, WIP
Offer users the option to obtain images from the assets catalog.
However, it only works when calling
load()+getContent(), and unlike in Asciidoctor Ruby, we cannot callconvertbecause it fails (see comment).How does it achieve that?
Exposes the images properties from the catalog.
However, this PR is not done yet untill:
convertto obtain theDocumentinstanceWhenReadingImagesFromCatalogAssetFromConverter) 👉 I think that fixing the first issue should fix this.Are there any alternative ways to implement this?
WIP
Are there any implications of this pull request? Anything a user must know?
Not
Issue
If this PR fixes an open issue, please add a line of the form:
Fixes #1166
Release notes
Please add a corresponding entry to the file CHANGELOG.adoc