annotate-extension
annotate-extension copied to clipboard
Use a Javascript parser instead of reqular expressions
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)
I agree with Hopiu, acorn looks like it can make our lives easier. I would suggest to create an object like
function JSDocsObject (string) {
//@constructor...
}
JSDocsObject.prototype = {
//----------------------------------------------
// PRIVATE METHODS
//----------------------------------------------
_getReturnType : function() {...},
//----------------------------------------------
// PUBLIC METHODS
//----------------------------------------------
genJSDocs: function() {}
}
I agree with you guys, regexps can only go so far. I have no experience with acorn though, and I'm just wondering if this isn't a bit oversized for the job. @Hopiu , from your experience, what do you think? Do you think it's suited, performance wise?
Performance wise I think it's not a problem. If it's a bit oversized, ummm, maybe but still I think it's better to use a parser than regexps that will never understand the code.
@davidderaedt How about creating a new branch where we could start getting something together?
@ajorquera Let's use the coding guidelines from https://github.com/adobe/brackets/wiki/Brackets-Coding-Conventions
Generally, isn't there something like the CodeHintManager but targeting Docs? I mean, JS is not the only language that needs Documentation.
Good question about the CodeHintManager, I'll try to investigate that. In the meantime, I'm creating the acorn branch. Not sure I'll have the time to actually code anything before a while though, so feel free to go crazy. ;)
Sorry @Hopiu I don't quite understand the purpose of the link you sent me. I mean, it doesn't talk about coding conventions for creating objects. I just wanted for us to focus on creating them.
@ajorquera Oh, sorry I got that wrong. It's absolutely fine for me creating such an object.