Spurious validation warning from readDocumentHeader()?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Spurious validation warning from readDocumentHeader()?

kanecta

When calling readDocumentHeader() on a file where an attribute is part of an include path a WARNING message is output warning that the attribute is missing.

However there appears to be no way to pass attributes into the readDocumentHeader method so isn't this warning redundant?

Available method signatures:

DocumentHeader readDocumentHeader(File filename);
DocumentHeader readDocumentHeader(String content);
DocumentHeader readDocumentHeader(Reader contentReader);

Test file:

include::{some-attribute}/file.adoc[]

Test code:

Asciidoctor asciidoctor = create();
asciidoctor.readDocumentHeader(new File("test.adoc"));

Test output:

asciidoctor: WARNING: dropping line containing reference to missing attribute: some-attribute

Is this an issue that should be resolved by dropping the warning or providing the ability to pass in attributes? Or have I missed another configuration step that would avoid the warning message?

Reply | Threaded
Open this post in threaded view
|

Re: Spurious validation warning from readDocumentHeader()?

mojavelinux
Administrator

On Thu, Sep 25, 2014 at 5:04 PM, kanecta [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Is this an issue that should be resolved by dropping the warning or providing the ability to pass in attributes?

Definitely option B. The functionality of this API is severely limited if there's no way to pass options or attributes. The Map<String,Object> options argument needs to be added to parallel readDocumentStructure.

Could you file an issue in AsciidoctorJ?

-Dan
Reply | Threaded
Open this post in threaded view
|

Re: Spurious validation warning from readDocumentHeader()?

kanecta
Reply | Threaded
Open this post in threaded view
|

Re: Spurious validation warning from readDocumentHeader()?

mojavelinux
Administrator

Thanks!

Reply | Threaded
Open this post in threaded view
|

Re: Spurious validation warning from readDocumentHeader()?

asotobu
Dan,Kanecta I think the loadFile method could be used instead of readDocumentHeader, so you will be able to pass the map and retrieve same information as well.

Currently I am refactoring all this part as well as changing the names to follow a convention. For this reason I plan to deprecate in next version 1.5.2 the readDocumentHeader method, in 1.6.0 the methods will still be there but deprecated and probably in 1.7.0 these methods will disappear.

You can read a bit more here:

http://discuss.asciidoctor.org/Questions-about-readDocumentStructure-td2252.html
Reply | Threaded
Open this post in threaded view
|

Re: Spurious validation warning from readDocumentHeader()?

mojavelinux
Administrator
Gotcha. To clarify, you should be able to call the load (or load_file) method and pass the "parse_header_only" option. That probably needs to be added to OptionsBuilder, though, to make it simpler to set. Currently, you have to manually create the options hash as follows:

[source,java]
----
Map<String, Object> options = new HashMap<String, Object>();
options.put("parse_header_only", true);
RubyHash rubyHash = RubyHashUtil.convertMapToRubyHashWithSymbols(rubyRuntime, options);

Document documentHeader = asciidoctor.load_file("sample.adoc", rubyHash);
----

You can see that this is what the parseDocumentHeader method is doing behind the scenes.

Sound right, Alex?

-Dan

On Fri, Sep 26, 2014 at 12:28 AM, asotobu [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Dan,Kanecta I think the loadFile method could be used instead of readDocumentHeader, so you will be able to pass the map and retrieve same information as well.

Currently I am refactoring all this part as well as changing the names to follow a convention. For this reason I plan to deprecate in next version 1.5.2 the readDocumentHeader method, in 1.6.0 the methods will still be there but deprecated and probably in 1.7.0 these methods will disappear.

You can read a bit more here:

http://discuss.asciidoctor.org/Questions-about-readDocumentStructure-td2252.html


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Spurious-validation-warning-from-readDocumentHeader-tp2283p2287.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--
Reply | Threaded
Open this post in threaded view
|

Re: Spurious validation warning from readDocumentHeader()?

asotobu
I will create the options as well, but let me fix the code you have posted hehehe :P

[source,java]
----
Map<String, Object> options = new HashMap<String, Object>();
options.put("parse_header_only", true);
//It is not necessary to do it by yourself because this line is handled automatically inside asciidoctorj.
//RubyHash rubyHash = RubyHashUtil.convertMapToRubyHashWithSymbols(rubyRuntime, options);

Document documentHeader = asciidoctor.loadFile(new File("sample.adoc"), options);
----
Reply | Threaded
Open this post in threaded view
|

Re: Spurious validation warning from readDocumentHeader()?

mojavelinux
Administrator
Thanks!

-Dan

On Fri, Sep 26, 2014 at 12:59 AM, asotobu [via Asciidoctor :: Discussion] <[hidden email]> wrote:
I will create the options as well, but let me fix the code you have posted hehehe :P

[source,java]
----
Map<String, Object> options = new HashMap<String, Object>();
options.put("parse_header_only", true);
//It is not necessary to do it by yourself because this line is handled automatically inside asciidoctorj.
//RubyHash rubyHash = RubyHashUtil.convertMapToRubyHashWithSymbols(rubyRuntime, options);

Document documentHeader = asciidoctor.loadFile(new File("sample.adoc"), options);
----


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Spurious-validation-warning-from-readDocumentHeader-tp2283p2289.html
To start a new topic under Asciidoctor :: Discussion, email [hidden email]
To unsubscribe from Asciidoctor :: Discussion, click here.
NAML



--