Re: JSDoc templates to output XML format OR a good example/tutorial on how to build a JSDoc template from scratch

875 views
Skip to first unread message

Venkatram Akkineni

unread,
Mar 7, 2013, 11:32:54 AM3/7/13
to Ishita jain, jsdoc...@googlegroups.com
How about this.

./jsdoc myscript.js -t templates/haruki -d console -q format=xml

https://github.com/jsdoc3/jsdoc/tree/master/templates/haruki





On Wed, Mar 6, 2013 at 8:12 PM, Ishita jain <its...@gmail.com> wrote:
Hi,

So I am trying to create a JSDoc template to ouput a XML representation of our code module comments.

I couldn't find any template online or any good tutorial or exxample on how can we build that from scratch.

Can anyone please help me and direct to right resource?

Thanks

--
You received this message because you are subscribed to the Google Groups "JSDoc Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsdoc-users...@googlegroups.com.
To post to this group, send email to jsdoc...@googlegroups.com.
Visit this group at http://groups.google.com/group/jsdoc-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Sincerely
Venkat R Akkineni

Jeff Williams

unread,
Mar 7, 2013, 11:39:34 AM3/7/13
to Venkatram Akkineni, Ishita jain, jsdoc...@googlegroups.com
I was just writing a very similar reply! Ishita, here's a little more information in case the Haruki template does not meet your needs:

The code for the Haruki template is pretty straightforward. Most of it is a giant forEach() statement that loops through the parse results and extracts information from them.

The Haruki template supports a subset of JSDoc tags; see the template overview for details. Adding support for new tags would be relatively easy--just update the forEach() statement to handle additional tags.

To generate XML, Haruki uses a library called js2xmlparser, which is included with JSDoc.

I hope that helps!

- Jeff

Venkatram Akkineni

unread,
Mar 7, 2013, 11:43:29 AM3/7/13
to Jeff Williams, Ishita jain, jsdoc...@googlegroups.com
:) Apologies for the telepathic malfuncition there Jeff.

Ishita jain

unread,
Mar 7, 2013, 12:28:53 PM3/7/13
to Venkatram Akkineni, Jeff Williams, jsdoc...@googlegroups.com
Thanks everyone for your help.

Jeff:

I just wonder that why do they have only publish file and not any template file (file with extension .tmpl).
I believe that these "tmpl" files are the one those shapes and structures the final output documentation.

Jeff Williams

unread,
Mar 7, 2013, 3:18:03 PM3/7/13
to Ishita jain, Venkatram Akkineni, jsdoc...@googlegroups.com
Hi Ishita,

The Haruki template works a little differently. It just builds a JavaScript object, then converts the object to JSON or XML. The output has the same information as the JavaScript object, and it's organized in the same way; for example, the object's property names are mapped directly to XML element names.

In contrast, the default template generates output by extracting lots of bits and pieces from the parse tree; wrapping those bits and pieces with HTML; and combining them into output files. The .tmpl files define the logic and the HTML structure for the conversion process.

You could certainly create a template that uses .tmpl files to generate XML, but Haruki's approach is simpler.

- Jeff

Michael Mathews

unread,
Mar 7, 2013, 3:22:11 PM3/7/13
to Jeff Williams, Ishita jain, Venkatram Akkineni, jsdoc...@googlegroups.com
Yes, that. You could even write your own app or process that consumes haruki XML or JSON and turns it into something else.

Michael Mathews
mic...@gmail.com


Message has been deleted

Ishita jain

unread,
Mar 7, 2013, 4:05:45 PM3/7/13
to jsdoc...@googlegroups.com, Ishita jain, Venkatram Akkineni
Aaahhh..that explans it!

Moreover it only extracts a very few tags (whihc is already mentioned in readme file)

Thanks for your help .. I will try to build on top of that!

In case if you come across any other template that extracts document in XML format..please do let me know

Thanks a lot! :)

Ishita jain

unread,
Mar 8, 2013, 3:50:40 PM3/8/13
to Jeff Williams, Venkatram Akkineni, jsdoc...@googlegroups.com
So, I am trying to run the Haruki template but it throws a reference error.

It doesnt validate the template and says "publish" is not defined and "exports" is not defined in the line below:

exports.publish = function (data, opts) {


Please can any one tell me what am i doing wrong?

Thanks
Reply all
Reply to author
Forward
0 new messages