Generating dependency from .adoc file

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

Generating dependency from .adoc file

wimalopaan
Hi all,

is it possible (or are there plans) to generate a dependency list, e.g. for all the files that are included in an asciidoctor document. This would be similar to the clang / gcc feature

gcc -MM -MG abc.cc

It would be helpfull to write makefiles for generating the docs.

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

Re: Generating dependency from .adoc file

mojavelinux
Administrator
I have good news for you! This is already captured as it's needed for the inter-document cross reference feature.

You can get the table from the document.references map.

[source,asciidoc]
----
require 'pp'
require 'asciidoctor'

doc = Asciidoctor.load_file 'sample.adoc', safe: :safe
pp doc.references
----

There's some other stuff in there you might be interested in as well.

-Dan

On Thu, Oct 2, 2014 at 6:55 AM, wimalopaan [via Asciidoctor :: Discussion] <[hidden email]> wrote:
Hi all,

is it possible (or are there plans) to generate a dependency list, e.g. for all the files that are included in an asciidoctor document. This would be similar to the clang / gcc feature

gcc -MM -MG abc.cc

It would be helpfull to write makefiles for generating the docs.

--
Wilhelm


If you reply to this email, your message will be added to the discussion below:
http://discuss.asciidoctor.org/Generating-dependency-from-adoc-file-tp2306.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: Generating dependency from .adoc file

mojavelinux
Administrator
In reply to this post by wimalopaan

On Wed, Oct 8, 2014 at 2:21 AM, Dan Allen <[hidden email]> wrote:
[source,asciidoc]
----
require 'pp'
require 'asciidoctor'

doc = Asciidoctor.load_file 'sample.adoc', safe: :safe
pp doc.references
----

Wow, I'm writing too much AsciiDoc lately. That should be "source,ruby".

Reply | Threaded
Open this post in threaded view
|

Re: Generating dependency from .adoc file

wimalopaan
Ok, thank you very much!
Reply | Threaded
Open this post in threaded view
|

Re: Generating dependency from .adoc file

wimalopaan
In reply to this post by mojavelinux
Hi Dan,

I tried to generate dependency info, but there is a problem.

Following is a test-file:
= Test
Wilhelm Meier <wilhelm.meier@hs-kl.de>
$Id: ppcSlide.adoc 868 2015-01-29 13:27:00Z wimalopaan $
:title: Test
:lang: de
:toc:
:toc-title: Inhalt
:toclevels: 4
:numbered:
:src_numbered: 
:icons: font
:sectanchors:
:sectlinks:
:experimental:
:duration: 90
:source-highlighter: coderay
:coderay-css: style
:status:
:menu:
:navigation:
:split:
:goto:
:blank:
:deckjs_theme: swiss
:showtitle:
:deckjs_transition: horizontal-slide
:customcss: css/deckjs.css 

:srcbase: ../src
:srcdir: cpp0000
:extractordir: .extractor

== SourceCode

include::{srcbase}/{srcdir}/{extractordir}/hello2.cc.Hello[]


When I try to run your above ruby code, the included file isn't found:

34% [lmeier:/home/lmeier/Lehre/Eigene/Prog2NeuesKonzept/ppc/doc] ppc(5) ‡ ruby dep.ruby 
asciidoctor: WARNING: include file has illegal reference to ancestor of jail, auto-recovering
asciidoctor: WARNING: test3.adoc: line 35: include file not found: /home/lmeier/Lehre/Eigene/Prog2NeuesKonzept/ppc/doc/src/cpp0000/.extractor/hello2.cc.Hello
{:ids=>{"_sourcecode"=>"SourceCode"},
 :footnotes=>[],
 :links=>[],
 :images=>[],
 :indexterms=>[],
 :includes=>#<Set: {}>}

*But*, renedring is ok:

⌁34% [lmeier:/home/lmeier/Lehre/Eigene/Prog2NeuesKonzept/ppc/doc] ppc(5) ‡ make test3.html
asciidoctor -I ~/asciidoctor/extensions/lib  -r view-result-postprocessor -r man-inline-macro -r asciidoctor-diagram -a data-uri -a single -o test3.html test3.adoc
⌁34% [lmeier:/home/lmeier/Lehre/Eigene/Prog2NeuesKonzept/ppc/doc] ppc(5) ‡ 

Any hints?
--
 Wilhelm
Reply | Threaded
Open this post in threaded view
|

Re: Generating dependency from .adoc file

mojavelinux
Administrator

On Wed, Mar 18, 2015 at 9:55 AM, wimalopaan [via Asciidoctor :: Discussion] <[hidden email]> wrote:
:srcbase: ../src

Because of this line, you need to use unsafe instead of safe mode. Thus, the code would be:

[source,ruby]
----
require 'pp'
require 'asciidoctor'

doc = Asciidoctor.load_file 'sample.adoc', safe: :unsafe
pp doc.references
----

I hope that helps.

Reply | Threaded
Open this post in threaded view
|

Re: Generating dependency from .adoc file

wimalopaan
Am 01.04.2015 um 19:08 schrieb mojavelinux [via Asciidoctor :: Discussion]:

>
> On Wed, Mar 18, 2015 at 9:55 AM, wimalopaan [via Asciidoctor ::
> Discussion] <[hidden email]
> </user/SendEmail.jtp?type=node&node=2915&i=0>> wrote:
>
>     :srcbase: ../src
>
>
> Because of this line, you need to use unsafe instead of safe mode. Thus,
> the code would be:
>
> [source,ruby]
> ----
> require 'pp'
> require 'asciidoctor'
>
> doc = Asciidoctor.load_file 'sample.adoc', safe: :unsafe
> pp doc.references
> ----
>
> I hope that helps.

Yes, it works!



--
Wilhelm