AMD module format

384 views
Skip to first unread message

drKarl

unread,
Oct 16, 2012, 9:27:54 AM10/16/12
to yui...@googlegroups.com
Hi,

    I would like to know if there is support for CommonJS AMD (Asynchronouse Module Definition) format in YUIDoc.

    If there is, how would you actually use it? If not, is there any plans to support it? Is there any way to create a plugin for YUIDoc?

    I have looked the source code and I think I should modify docparser.js in order to provide support for AMD. I guess I would have to add a regular expression to accept define and requires, add tags and digesters.

    Thank you very much.

    Kind regards 

Dav Glass

unread,
Oct 16, 2012, 9:29:59 AM10/16/12
to yui...@googlegroups.com
I'm totally not sure what AMD has to do with YUIDoc at all. YUIDoc
parses the Doc Block syntax, not the JS itself. There should be no
modification needed to parse and document AMD modules.

Dav

--
Dav Glass
davg...@gmail.com
blog.davglass.com


+ Windows: n. - The most successful computer virus, ever. +
+ A computer without a Microsoft operating system is like a dog
without bricks tied to its head +
+ A Microsoft Certified Systems Engineer is to computing what a
McDonalds Certified Food Specialist is to fine cuisine +
> --
> You received this message because you are subscribed to the Google Groups
> "yuidoc" group.
> To post to this group, send email to yui...@googlegroups.com.
> To unsubscribe from this group, send email to
> yuidoc+un...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/yuidoc/-/42eGMCvhL_0J.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

drKarl

unread,
Oct 16, 2012, 9:45:01 AM10/16/12
to yui...@googlegroups.com
I understand that, I know that YUIDoc doesn't parse the javascript but the Doc Block syntax, but what I mean is, which tags would you use to document AMD code? When I referred to docparse.js I meant to create new tags, for instance define or require tags.

For instance, how would you document these two snippets taken from the Dojo documentation?

define([
    "dojo/dom"
], function(dom){
    var oldText = {};
    return {
        setText: function(id, text){
            var node = dom.byId(id);
            oldText[id] = node.innerHTML;
            node.innerHTML = text;
        },
        restoreText: function(id){
            var node = dom.byId(id);
            node.innerHTML = oldText[id];
            delete oldText[id];
        }
    };
});

and

require(["demo/myModule"], function(myModule){
    myModule.setText("greeting", "Hello Dojo!");
 
    setTimeout(function(){
        myModule.restoreText("greeting");
    }, 3000);
});

Thank you

gp

unread,
Mar 18, 2013, 9:10:32 AM3/18/13
to yui...@googlegroups.com
I also would like to document modules and classes with the AMD syntax.

For example before using AMD I was documenting in this way: myNamespace.myModule.MyClass
Now, I'd like to document it as myNamespace/myModule/MyClass

gp

Dav Glass

unread,
Mar 20, 2013, 11:34:42 AM3/20/13
to yui...@googlegroups.com
YUIDoc has support for modules with Slashes in them:


But Namespaces are just that, a Namespace. So it won't likely support it since it's not valid.


--
Dav Glass
davg...@gmail.com
blog.davglass.com


+ Windows: n. - The most successful computer virus, ever. +
+ A computer without a Microsoft operating system is like a dog
    without bricks tied to its head +
+ A Microsoft Certified Systems Engineer is to computing what a
   McDonalds Certified Food Specialist is to fine cuisine  +


--
You received this message because you are subscribed to the Google Groups "yuidoc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to yuidoc+un...@googlegroups.com.

To post to this group, send email to yui...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/yuidoc/-/x8UyBa9SLDwJ.

Florian Kappes

unread,
Aug 20, 2013, 9:40:05 AM8/20/13
to yui...@googlegroups.com
I recognized the links on the top of a class page are broken in the current release if slashes are used within module names. Links on the module selector on the left side are still working.

Florian Kappes

unread,
Aug 21, 2013, 8:35:38 AM8/21/13
to yui...@googlegroups.com
I issued the bug and found a solution.

Rob D

unread,
Sep 12, 2013, 10:42:50 AM9/12/13
to yui...@googlegroups.com
I think the issue is that it's difficult to see which is the class to define.  In the following code if I code the AMD 'wrapper' which exports the method initialise as a class then the real class inside AppRouter isn't visible, it seems I can't nest a class (of course).  Yet if I put the @class tags above AppRouter inside the wrapper then it's ignored by YUIdoc.  So, the question is really how to bend or code doc block to handle the AMD wrappers which export an instance with a class defined inside it?

example code:
define
([
   
'ModuleListView',
   
'backbone',
],
function(Backbone, ModuleListView,) {


   
var AppRouter = Backbone.Router.extend({
            routes
: {
               
"": "listCourse",
               
"showcourse/:id": "showCourse",
               
"liststudent/:id": "listStudentOnCourse",
               
"listmodules/:id": "listModule",
               
'listmodulestudents/:id': 'listmoduleStudents',
               
// Default
             
'*actions': 'defaultAction'
           
},


           
// methods
            initialize
: function () {
               
var tabHeader = '.tab > :header';
               
// initialisation code
           
},
           
            listCourse
: function () {
           
}
 
});
 
 
var initialize = function(){  // create a new AppRouter instance local, start the history bookmark
     
var app_router = new AppRouter;
     
     
Backbone.on('courseChange', function (id) {
          app_router
.navigate('showcourse/'+id, {trigger: true});
     
});
     
Backbone.history.start();
 
};
 
 
return {   // return a handle to the initialize function
    initialize
: initialize
 
};
});



On Tuesday, October 16, 2012 2:30:21 PM UTC+1, Dav Glass wrote:
I'm totally not sure what AMD has to do with YUIDoc at all. YUIDoc
parses the Doc Block syntax, not the JS itself. There should be no
modification needed to parse and document AMD modules.

Dav

--
Dav Glass
davg...@gmail.com
blog.davglass.com


Reply all
Reply to author
Forward
0 new messages