Note that there are some explanatory texts on larger screens.

plurals
  1. POOrganizing and Documenting Multi-File JavaScript Projects
    primarykey
    data
    text
    <p>I'm beginning a fairly large JavaScript project. The project will have everything exist within one or more namespaces, so only a sparse number of things will exist in the global scope (at the moment, there is only one thing).</p> <p>In order to keep things organized, I would like to keep each class in its own file (much like you would other many other languages) instead of in "modules".</p> <p>I built a little compilation script (with NodeJS) which will compile all of the files in to a single JavaScript file at the end of the day.</p> <p>I thought I had a good method, but I'm trying to get JSDoc(3) to cooperate with me and not having a lot of luck, so I'm wondering if I'm maybe tackling this in the wrong way, or if there is some trick with JSDoc I'm missing.</p> <p>In the source, each namespace is a folder and each class is a file of the same name.</p> <p>Each class file looks something like this:</p> <pre><code>var BaseNS = BaseNS || {}; BaseNS.SubNS = BaseNS.SubNS || {}; BaseNS.SubNS.MyClass = (function() { function MyClass() { } Object.defineProperties(MyClass.prototype, { 'someProp', { getter: function() { return this._someProp = this._someProp || 0; }, setter: function(val) { this._someProp = val; } } // ... more }); MyClass.prototype.someMethod = function() {}; // ... more return MyClass; }}()); </code></pre> <p>When compiled together, my compilation script handles dependencies to get the classes in the correct order and also removed duplicate namespace declaration lines.</p> <p>I think this method is relatively clean and straight-forward. The catch is, I can't figure out how to write the JSDoc documentation in a way which gives me things as I think they should be.</p> <p>I would like to go with a "class-like" method for things. This is actually for an application which is largely removed from the DOM. Also, I'd like the entire project to be vanilla, modern JavaScript (i.e., no RequireJS, etc.)</p> <p>Any ideas how to get this documented, or a better way to arrange things?</p> <p>Thanks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload