GithubHelp home page GithubHelp logo

Comments (3)

spadgos avatar spadgos commented on June 7, 2024

Do you mean inspecting the body of the function which you're documenting to look at the return statement?

ie, the template inserted would look like this for these functions:

/**
 * [foo description]
 */
function foo() { }

/**
 * [bar description]
 * @return [description]
 */
function bar() {
  return 1;
}

If this is what you mean, then there's no plan to implement that. The plugin simply does some string comparisons against the surrounding code to infer what it can, and I would actually resist any attempt to make it do much more than that. It's not possible to reliably perform this sort of detection without building an entire source tree out of the file -- string comparison obviously can't tell the difference between nested functions, or the word "return" inside a string without getting really complicated. Plus, most of the time while you're editing a file, you don't actually have a valid document which makes a lot of the parsers worthless, since they'd just report a syntax error and die.

So, long story short: adding this sort of functionality is very complicated and couldn't be relied upon most of the time, whereas the alternative is that the developer manually delete a single line. Sorry!

However if I misunderstood the request, please do let me know, and I'd be happy to take another look.

from sublime-jsdocs.

alexwhitman avatar alexwhitman commented on June 7, 2024

You've understood correctly and I get the complexity of doing it 'properly'.

As a compromise (if the ST2 API makes this any simpler) how about finding the closing brace of the function and checking the line before? If it starts with return then that would be a good indicator. This wouldn't catch return statements in the middle of a function with a fall back to an implicit null return but it would pretty safe to assume that most functions returning something would return as the last thing it does.

from sublime-jsdocs.

spadgos avatar spadgos commented on June 7, 2024

This could possibly work, however it'd be a much larger change to the plugin than I have the time for right now. If you wanted to have a go at it, I'd be happy to accept pull-requests. I guess I see the 'stupidity' of the plugin as a positive thing 😃

from sublime-jsdocs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.