Kernel.js and YUIdoc

43 views
Skip to first unread message

Matija Urh

unread,
Feb 21, 2014, 2:38:27 AM2/21/14
to kern...@googlegroups.com
Hi, I started working on a fairly big project with kernel.js and I want to implement automatic documentation ASAP.

I was wondering if any of you have any good practices on using YUIdoc in combination with Kernel.js?
The problem that I have is that I would like to "set" modules as @module but then I don't know what to set hub, so I went with hub - @module, module - @submodule, but then documentation doesn't get "rendered" correctly.  

And additional question - I implemented whole logic over multiple files - so I was wondering if this is correct "structure".

For example:

---
kernel.js (main file)
---
/**
 * Dont know what to write here
 */
Kernel.extend(Kernel, {

    doAjax: function(config) {
    },

    doREST: function(config) {
    }
});

$(document).ready(function() {
    Kernel.start([
    // starting all modules
    ]);

});

---
kernel.main.hub.js (hub)
---
/**
 * Main hub
 * @module main
 */
Kernel.hub.define('main', {

    // Expose REST capabilities to hub
    request: function(config) {
        Kernel.doREST(config);
    },

    someFunction: function(category) {

        var self = this;

        /**
         * Sth happened
         * @event event-name
         * @param {Object} [data] Event data payload
         */
        self.broadcast('event-name', data);

    }
});

---
kernel.main.modules.js (modules)
---
/**
 * Some module
 * @module main
 * @submodule doSth
 */
Kernel.module.define('doSth', {

    /**
     * Initialize
     * @class init
     * @extends doSth
     */
    init: function() {

    },

    /**
     * Another function
     * @class anotherFunction
     * @extends doSth
     */
    anotherFunction: function(picture) {
    }
});

// Module registration
Kernel.register([

    {id: 'module-doSth', type: 'doSth', hub: 'main'}

]);

alan lindsay

unread,
Feb 21, 2014, 9:52:40 AM2/21/14
to kern...@googlegroups.com
I can't speak to YUIdoc because I haven't used it. I have had great success using JSDuck with Kernel though. Even thought JSDuck was initially designed for ExtJS, it is very flexible and allows you to structure your objects pretty much any way you like. I was able to classify Kernel, each hub and modules rather nicely. 

Alan


--
You received this message because you are subscribed to the Google Groups "Kernel.js" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kerneljs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

alan lindsay

unread,
Feb 21, 2014, 9:55:50 AM2/21/14
to kern...@googlegroups.com
With regards to your question on structure. I would put each object in its own file. I would not put multiple modules in the same file. Also, I would not put module registration code in the same file as the module definition because registration is a very application specific task and may vary from application to application. Instead, consider handling module registration in your main application file.

Alan

alan lindsay

unread,
Feb 21, 2014, 9:59:16 AM2/21/14
to kern...@googlegroups.com
Sorry, one more point, I just noticed your ready handler inside the main Kernel extension. This should be moved to an application file, something like application.js. The application file should handle any tasks relevant to bootstrapping your application. Kernel extensions should be independent and should only include code that extends Kernel. This is a safer approach in my view.

Alan

Matija Urh

unread,
Feb 26, 2014, 2:51:26 AM2/26/14
to kern...@googlegroups.com
Thanks Alan for all your input. I will take another look in structure of my code - btw when you have that many files, how do you include them one by one? Here we have a release script which combines all code and compresses it before PROD release.

matija

alindsay55661

unread,
Feb 27, 2014, 10:06:25 PM2/27/14
to kern...@googlegroups.com
I use a build process as well.

Alan
Reply all
Reply to author
Forward
0 new messages