Include and base dir

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

Include and base dir

wdrai
Hi,

It seems that the base directory for include:: is always the base directory of the parent document, i.e. :

parent.adoc :
include::module1/module1.adoc[]

module1.adoc :
include::src/main/java/someClass.java[]

When generating parent.adoc, the file included in module1.adoc is not found because the relative path is from the parent document and not from the module document.

Is there a way to specify a base dir in the include:: directive, something like :
include::module1/module1.adoc[basedir=module1]

Or even a way to always use the current document base dir during includes
Reply | Threaded
Open this post in threaded view
|

Re: Include and base dir

LightGuardjp
Hi, welcome!

I think the issues (maybe there's more) regarding the issue you're seeing are


At least that's a quick search through the issues. Feel free to comment on one of those as well.


On Thu, Nov 14, 2013 at 9:33 AM, wdrai [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi,

It seems that the base directory for include:: is always the base directory of the parent document, i.e. :

parent.adoc :
include::module1/module1.adoc[]

module1.adoc :
include::src/main/java/someClass.java[]

When generating parent.adoc, the file included in module1.adoc is not found because the relative path is from the parent document and not from the module document.

Is there a way to specify a base dir in the include:: directive, something like :
include::module1/module1.adoc[basedir=module1]

Or even a way to always use the current document base dir during includes



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Include-and-base-dir-tp995.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: Include and base dir

mojavelinux
Administrator

Indeed, this is something we need to make more flexible as different people have different needs and expectations.

Keep in mind it is possible to modify the behavior as of Asciidoctor 0.1.4 using an IncludeProcessor. This extension can assume complete control over the include functionality, so you can resolve the target in whatever way works best for you.

If you have ideas about how the default behavior may be modified, I encourage you to comment on those issues. We want to get this right for sure.

-Dan

On Nov 21, 2013 12:36 PM, "LightGuardjp [via Asciidoctor :: Discussion]" <[hidden email]> wrote:
Hi, welcome!

I think the issues (maybe there's more) regarding the issue you're seeing are


At least that's a quick search through the issues. Feel free to comment on one of those as well.


On Thu, Nov 14, 2013 at 9:33 AM, wdrai [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi,

It seems that the base directory for include:: is always the base directory of the parent document, i.e. :

parent.adoc :
include::module1/module1.adoc[]

module1.adoc :
include::src/main/java/someClass.java[]

When generating parent.adoc, the file included in module1.adoc is not found because the relative path is from the parent document and not from the module document.

Is there a way to specify a base dir in the include:: directive, something like :
include::module1/module1.adoc[basedir=module1]

Or even a way to always use the current document base dir during includes



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



--



If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Include-and-base-dir-tp995p1044.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: Include and base dir

wdrai
I think my question was related but a bit different from the two mentioned issues.
It was not about fixed assets, but nested includes.

Here is a complete example to try to be more clear:

app
    src
        asciidoc
            appdoc.adoc
    module1
        src
            asciidoc
                module1doc.adoc
            main/java
                SomeClass.java
            main/resource
                someresource.xml
    module2
        src
            asciidoc
                module2doc.adoc
            main/java
                SomeOtherClass.java
            main/resource
                someotherresource.xml
   
appdoc.adoc
|
| Module 1:
| include::module1/module1doc.adoc[]
|
| Module 2:
| include::module2/module2doc.adoc[]

module1doc.adoc
|
| Bla bla:
| ----
| include::../main/java/SomeClass.java[]
| ----

module2doc.adoc
|
| More bla bla:
| ----
| include::../main/resource/someotherresource.xml[]
| ----

It's possible to generate module1doc.adoc and module2doc.adoc separately but not appdoc.adoc because it won't find the nested includes of the java and xml files from the document basedir.
This makes very difficult to reuse the same document both standalone and included in another document.

If I try to summarize what I would find consistent and predictable :
- all styling assets (css, images, scripts, ..) should be resolved from the main document so the overall style of the document is always the same
- all included content should be resolved from the basedir of the document containing the include directive (I'm not sure of what should happen when a document included from a remote url itself includes other documents with relative paths)

I can open a new issue on github if you think it can be useful.

I've not seen about this IncludeProcessor but I guess this is in the ruby core, so how can I use this from the maven and gradle plugins ? I've tried to browse the ruby code where includes are handled but my ruby knowledge is ridiculously rudimentary.
Reply | Threaded
Open this post in threaded view
|

Re: Include and base dir

mojavelinux
Administrator

I agree this is a separate issue. I remember being concerned about the lack of reusable fragments when I was implementing the behavior from AsciiDoc.

Go ahead and open a new issue and post the use case you included here. This is definitely something that needs to be addressed...perhaps even the default behavior since clearly AsciiDoc is Python is inconsistent here.

-Dan

On Nov 26, 2013 7:38 PM, "wdrai [via Asciidoctor :: Discussion]" <[hidden email]> wrote:
I think my question was related but a bit different from the two mentioned issues.
It was not about fixed assets, but nested includes.

Here is a complete example to try to be more clear:

app
    src
        asciidoc
            appdoc.adoc
    module1
        src
            asciidoc
                module1doc.adoc
            main/java
                SomeClass.java
            main/resource
                someresource.xml
    module2
        src
            asciidoc
                module2doc.adoc
            main/java
                SomeOtherClass.java
            main/resource
                someotherresource.xml
   
appdoc.adoc
|
| Module 1:
| include::module1/module1doc.adoc[]
|
| Module 2:
| include::module2/module2doc.adoc[]

module1doc.adoc
|
| Bla bla:
| ----
| include::../main/java/SomeClass.java[]
| ----

module2doc.adoc
|
| More bla bla:
| ----
| include::../main/resource/someotherresource.xml[]
| ----

It's possible to generate module1doc.adoc and module2doc.adoc separately but not appdoc.adoc because it won't find the nested includes of the java and xml files from the document basedir.
This makes very difficult to reuse the same document both standalone and included in another document.

If I try to summarize what I would find consistent and predictable :
- all styling assets (css, images, scripts, ..) should be resolved from the main document so the overall style of the document is always the same
- all included content should be resolved from the basedir of the document containing the include directive (I'm not sure of what should happen when a document included from a remote url itself includes other documents with relative paths)

I can open a new issue on github if you think it can be useful.

I've not seen about this IncludeProcessor but I guess this is in the ruby core, so how can I use this from the maven and gradle plugins ? I've tried to browse the ruby code where includes are handled but my ruby knowledge is ridiculously rudimentary.


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