It's a newbie question, but I didn't manage to google anything reasonably concise yet enlightening on the subject. I've got Sublime Text
editor and an excellent plugin DocBlockr
https://github.com/spadgos/sublime-jsdocs , which makes proper commenting a piece of cake. What am I supposed to do after I'm through with the comments? At a very minimum, I'd like to be able to invoke annotations in REPL. What else documentation wise is available? I want something lightweight and easy, for medium scripts.
EDIT:
var helper = exports.helper = (function() {
...
/**
* Reduces a sequence of names to initials.
* @param {String} name Space Delimited sequence of names.
* @param {String} sep A period separating the initials.
* @param {String} trail A period ending the initials.
* @param {String} hyph A hypen separating double names.
* @return {String} Properly formatted initials.
*/
function makeInits(name, sep, trail, hyph) {
function splitBySpace(nm) {
return nm.trim().split(/\s+/).map(function(x) {return x[0]}).join(sep).toUpperCase();
}
return name.split(hyph).map(splitBySpace).join(hyph) + trail;
}
/**
* Reduces a sequence of names to initials.
* @param {String} name Space delimited sequence of names.
* @return {String} Properly formatted initials.
*/
function makeInitials(name) {
return makeInits(name, '.', '.', '-');
}
...
})();
With $ jsdoc src.js
no errors, but only dummy header is generated.
Python documentation strings (or docstrings) provide a convenient way of associating documentation with Python modules, functions, classes, and methods. It's specified in source code that is used, like a comment, to document a specific segment of code.
Module docstrings are placed at the top of the file even before any imports. Module docstrings should include the following: A brief description of the module and its purpose. A list of any classes, exception, functions, and any other objects exported by the module.
Docstrings are accessible from the doc attribute (__doc__) for any of the Python objects and also with the built-in help() function. An object's docstring is defined by including a string constant as the first statement in the object's definition.
Give example to support your answer? CS-XII, Sumita Arora / By Sanjay Kumar. Docstring are comment quoted with triple quotation marks. Used within a program for documentation.
When you write this
function bar (foo) {
return foo + foo;
}
If you place your cursor in the line just above function
and you write /**
when you push « Enter » you'll be obtain this:
/**
* [bar description]
* @param {[type]} foo [description]
* @return {[type]} [description]
*/
function bar (foo) {
return foo + foo;
}
There are a lot of similary shortcurt.
For exemple, if you place your cursor after @param {[type]} foo [description]
, push « Enter » will create a new a *
line, and write @
will propose you (in the intellisense) all JSDoc comments and the validation create a full line.
When your file is correctly documented, just use the jsdoc
CLI to create your documentation.
Documentation: http://usejsdoc.org/
EDIT: I just realize the response to your question is in your https://github.com/spadgos/sublime-jsdocs link so maybe you want know how generate the documentation so...
Install Node.js and use CLI command
npm install jsdoc -g
Then, supposed file name you want document is foo.js
, run the following command:
jsdoc foo.js
This will create a documentation into out
directory.
All CLI documentation to generate doc is here : http://usejsdoc.org/about-commandline.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With