Using JSDoc-Toolkit for other languages

455 views
Skip to first unread message

Jan Schütze

unread,
Oct 22, 2009, 5:00:34 AM10/22/09
to jsd...@googlegroups.com
Hello,

I am using jsdoc toolkit for quite a while to create javascript
documentation. It's really handy, because it offers so many
possibilities to document the features of most of the complicated
constructs, which somebody is able to come up in Javaascript!

Additionally I regulary also create code in Lua [1]. This languages has
also meta methods, lexical scoping, closures and is quite difficult to
document in full extend.

So I was wondering if JsDoc Toolkit is intended to be used also for
other languages? The -nocode option, seems to be capable of commenting
code as long as it has @name.
At a first glance I thought creating a custom Walker.js would do the
trick, but I surely miss something ;). Is there any work done in this
field already?

Kind regards,
Jan

[1] http://www.lua.org

--

http://dracoblue.net

Michael

unread,
Nov 22, 2009, 10:57:27 AM11/22/09
to JsDoc Toolkit Users
Hello Jan,

I have never tested JsDoc Toolkit with Lua, but several people have
asked about PHP. You are right that if you use @name tags you should
be able to document code in languages other than JavaScript. I would
suggest you use the -n commandline option to tell the parser to ignore
the code. By default JsDoc Toolkit will ignore files that don't end
in .js so you will also need to use the -x option to add additional
extensions. So in the case of PHP it might be: -n -x=php

For example:

<?php

/**
* Represents a person.
* @class
* @name Person
* @param {string} $name
*/
class Person
{
/**
* The preson's name.
* @field
* @name Person#$name
*/
public $name;

function __construct($name) {
$this->name = $name;
}

/**
* Get the preson's name.
* @function
* @name Person#getName
* @type string
* @returns The name of this person.
*/
public function getName() {
return $this->name;
}
}

/**
* Represents a worker person.
* @class
* @name Worker
* @param {string} $name
* @param {string} $id
* @extends Person
*/
class Worker extends Person
{

/**
* The worker's id.
* @field
* @name Worker#$id
*/
public $id;

function __construct($name, $id) {
parent::__construct($name);

$this->id = $id;

DracoBlue

unread,
Dec 26, 2009, 8:36:42 AM12/26/09
to JsDoc Toolkit Users
Hello Michael,

thanks for your kind reply.

In lua the comment blocks are made by multiline with --[[ ... ]] or a
preceding -- (per line).

Is it possible to configure that, too?

Kind regards,
Jan

Michael Mathews

unread,
Dec 26, 2009, 10:21:01 AM12/26/09
to jsd...@googlegroups.com
Bearing in mind I don't speak lua, you should be able to simply nest
jsdoc comments inside your lua comments:

==== file: animal.lua

require 'class'

--[[/**
@name Animal
@class
@description The base class for my menagerie.
*/]]
Animal = class(function(a,name)
a.name = name
end)

--[[/**
@name Dog
@class
@extends Animal
@description A canine animal.
*/]]
Dog = class(Animal)

--[[/**
@name Dog#speak
@method
@description Bark bark.
*/]]
function Dog:speak()
return 'bark'
end

====

Use the following commandline:
java -jar jsrun.jar app/run.js -t=templates/jsdoc/ -n -x=lua animal.lua

Everything should work as expected except for the syntax hiliting for
the source code views. You can disable source code hiliting by
removing that file from the plugins folder.

Regards,
Michael

> --
>
> You received this message because you are subscribed to the Google Groups
> "JsDoc Toolkit Users" group.
> To post to this group, send email to jsd...@googlegroups.com.
> To unsubscribe from this group, send email to
> jsdoc-2+u...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/jsdoc-2?hl=en.
>
>
>

Reply all
Reply to author
Forward
0 new messages