Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a Javascript parser instead of reqular expressions #29

Open
Hopiu opened this issue Apr 1, 2014 · 6 comments
Open

Use a Javascript parser instead of reqular expressions #29

Hopiu opened this issue Apr 1, 2014 · 6 comments

Comments

@Hopiu
Copy link

Hopiu commented Apr 1, 2014

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)

@Hopiu Hopiu changed the title Use a jspar Use a Javascript parser instead of reqular expressions Apr 1, 2014
@ajorquera
Copy link
Contributor

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() {}
}

@davidderaedt
Copy link
Owner

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?

@Hopiu
Copy link
Author

Hopiu commented Apr 4, 2014

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.

@davidderaedt
Copy link
Owner

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. ;)

@ajorquera
Copy link
Contributor

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.

@Hopiu
Copy link
Author

Hopiu commented Apr 4, 2014

@ajorquera Oh, sorry I got that wrong. It's absolutely fine for me creating such an object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants