davidderaedt / annotate-extension Goto Github PK
View Code? Open in Web Editor NEWBrackets extension to generate JSDoc annotations
License: MIT License
Brackets extension to generate JSDoc annotations
License: MIT License
I tried it on your own main.js
and it only shows me your no function found
alert
function generateComment(fname, params,returnsValue, prefix) {
var output = [];
output.push("/**");
// Assume function is private if it starts with an underscore
if (fname.charAt(0) === "_") {
output.push(" * @private");
}
// Add description
output.push(" * Description");
// Add parameters
if (params.length > 0) {
var i;
for (i = 0; i < params.length; i++) {
var param = params[i];
output.push(" * @param {type} " + param + " Description");
}
}
if (returnsValue) output.push(" * @returns {type} Description");
// TODO use if 'return' is found in the function body?
//output += " * @return {type} ???\n";
output.push(" */");
return prefix + output.join("\n" + prefix) + "\n";
}
I was hoping #25 would fix it, but object functions still cannot be found, ie:
var MyObject = {
myFunction: function () {
}
}
Hi David,
Referring to #27 I think too, that the design of the extension should be rethought. As a first suggestion I'd like to propose to switch to a JS parser to identify functions (and possibly other things to annotate) instead of using regular expressions.
Codemirror uses acorn.js anyway for code completion, so why not use it too to generate the jsdocs? What's you opinion on that?
As a start I wrote my first brackets plugin from scratch which uses acorn.js and can be found at:
https://github.com/Hopiu/brackets-annotate-extension
(Of course I won't publish the plugin in the extension repo)
function getHand(svgDoc, id)
{
}
/**
* Description
* @param {type} svgDoc Description
* @param {type} id Description
*/
function getHand(svgDoc, id)
{
}
/**
* Description
* @param {type} svgDoc Description
* @param {type} id Description
*/
{
}
Result:
My code is corrupted
Expected Result:
Code should not be removed. Either comment is added, or nothing.
When I run annotate, I always get the alert "no functions found". I consistently use expressions (foo = function() {}) rather than function declarations. Is that the reason, or is something else going on?
Thanks,
Robert
No annotation is generated if function is an expression, ie with the form:
var myFunction = function(){
};
Annotations are only generated for function declarations, ie with the form
function myFunction() {
}
The extension currently only looks for the function signature to generate the annotation, ignoring its body, including any return statement.
I installed the extension from the registry and saw that this is a newer version which provides a multiline description but the extension is unfortunately really slow in this version :/
It would be great to check if a description already exists. Checking if there is a
/**
*/
directly in front of the function name
Annotations are inserted starting from the current cursor position and no indentation is generated, which results in a lesser readable code.
For this code:
function ValidationFor($filter) {
}
extension generates:
/**
* Description
* @param {type} filter Description
*/
function ValidationFor($filter) {
}
and i have no clue why :-(
i am working on windows 7, current brackets sprint is 28.
Annotate form the Edit menu works.
If you try to create a JSDoc annotation with a function that has text preceding it, it will format the annotation with the same characters.
;(function (params) {}());
Will create
;(/**
;( * Description
;( */
I wish the tool would step you through all the parts of creation like Sublime's DocBlockr does. So the description would be highlighted first for you to edit and then it with each subsequent [tab] it would highlight the next field to edit.
the extension doesn't work for prototype function :
MyObject.prototype.myFunction = function (pram1, param2) {
//content
};
A feature of my current editor, WebStorm, is that if I type /** and hit enter just before the start of a function it generates the JSDoc info.
I find this very useful because, there is no need to break my workflow by going to the menu, and no need to remember yet another obscure shortcut to invoke the annotator :)
Hello my name is Andrew and I have a few ideas I will like to discuss. This the first project I have contributed, so maybe I'm wrong in a lot of things.
*Design pattern: I have checked the code and I don't see a clear pattern of design. So, maybe we can discuss about the design.
*Discussion over each pull: maybe before the owner of the project makes a merge, he can give at least a few days to discuss about the code. This way, contributors can give their opinions about it.
*Create a branch for development: maybe the owner can make a develop branch. This way we can test that nothing breaks before releasing the new version.
*Unnecessary pull request: I have seen sometimes that people will make pull requests just for minor changes that doesn't really make a difference.
I think we can work better and more efficient if we all put our heads together than just working by ourselves. If anyone has other ideas or think I'm wrong, please feel free to post.
The shortcut, CTRL
+SHIFT
+D
, is already used natively by Brackets for "delete line." It's not a big deal just an observation.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.