Code Monkey home page Code Monkey logo

vscode-comment's Introduction

vscode-comment

Adds simple jsdoc comments for the parameters of a selected function signature

Using

In a typescript or javascript file, select a function signature, ideally one that contains one or more parameters. Select the whole function signature then invoke the Add Doc Comments extension (open the command palette (F1 on Windows) and look for the command 'Add doc comments'. Hit enter.)

install and work

The extension will parse the selected signature and add @param and @return tags for each parameter and any return type in the selected signature, directly above the signature.

Limitations

The extension does not support any other type of jsdoc tags. It only calculates @param and @return

Parameter types are not inferred based on usage. If a type is not specified, empty braces {} are returned.

Other extensions

Document This provides the same functionality but supports many more tags

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

vscode-comment's People

Contributors

chrisdias avatar msftgits avatar stevencl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vscode-comment's Issues

In some cases it does not recognize the correct return type

I have this method:

register(registerData: RegisterFingerprintData): Observable<{fingerToken: string} | OperationFailure> {..}

that can return an Observable of type {fingerToken: string} or OperationFailure. When I add Jsdoc comments I get the following comments:

It says that returns an string but is not, it returns an Observable.

Thank you in advance!

extra space added.

Repro:
Have a class function like:

  static makeV1TableHeadings(headings) {

  }

Run "Add doc comments."
View the result:

  /**
   * @param  {} headings
   */

Note there's an extra space before the curly brackets.

Doesn't seem to support typescript methods

e.g., in this class:

    export class TwoPageView extends Marionette.LayoutView<TwoPageModel> {
        private __leftContent: Content.ContentController = null;
        private __leftView: Page.PageView;

        private __rightContent: Content.ContentController = null;
        private __rightView: Page.PageView;

        public initialize() {
            logger.trace("initialize");
            this.listenTo(this, "view.updateParentController", this.__onSetParentController);
            this.listenTo(this.model, "change:split", this.__onSetPageSplit);

            this.addRegions({
                'leftRegion': '.js-region-left',
                'rightRegion': '.js-region-right'
            });
        }
    }

You can't add doc comments for "public initialize()" - no matter what I try it always says "Please select a TypeScript or JavaScript function signature"

image

Merge new comment with existing

When there is already a doc comment above the function, but it only contains a description, no @param or @return tags, please add the tags to existing docblock

Findability in vscode extension store

In your read me, you should include a link to the extension or at least say that it is named Add jsdoc comments. Had to look at your package config to figure it out.

I can make this change, and put a pr in if you dont have any attachment to styling.

Incorrect handling of default values

The plugin incorrectly identifies the arguments of the function if an argument is taking a default value with a comma.

For instance, for separator: string = ',' it ends up detecting single quote ' as an argument.

/**
 * @param  {string} csvHeader
 * @param  {object[]} objs
 * @param  {string='} separator
 * @param  {} '
 * @returns string
 */
export function jsonArrToCsv(csvHeader: string, objs: object[], separator: string = ','): string

Document on tab completion

I'm a Sublime Text user, and one of the remaining features that's stopping the switch to VSCode for me is the DocBlockr extension.

It's essentially the same as this plugin, but it can be invoked from pressing TAB after /**:

/**tab
function say(word) {
    return word;
}

becomes:

/**
 * @param word
 * @return string
 */
function say(word) {
    return word;
}

Would it be possible to add this 'tab to complete' functionality to this extension for VSCode?

TypeScript constuctors not fully supported

The regular constructors work, but the shorthand constructors create issues, input:

class Experiment {

  constructor(public  lines:           string[],
              private alignSymbols:    number,
              private firstSymbolOnly: boolean) {

  }  
}

Will cause the "add doc" command create this:

  class Experiment {
  /**
   * @param  {string[]} publiclines
   * @param  {number}   privatealignSymbols
   * @param  {boolean}  privatefirstSymbolOnly
   */
  constructor(public  lines:           string[],
              private alignSymbols:    number,
              private firstSymbolOnly: boolean) {

  }  
}

Notice the public/private are now part of a field name in the auto-generated documentation.

Typescript types are not recognized, jsdoc comments confused

The very first typescript I attempted to generate jsdoc comments for:

/**

  • @param {} {data
  • @param {{data:T[]} columns}
  • @param {ColumnSpecifications}} columns?
  • @returns Shape
    */
    function analyze<T = unknown>({data, columns}: {data: T[], columns?: ColumnSpecifications}): {types: Record<string, ColumnType>, shape: Shape} {

The arguments are incorrect with the types and don't have correct syntax (The number of open/closed braces don't match). The return type is also incorrect.

Slow to pick up block comment in JavaScript

OS: MacOS Version 10.14.5
VSCode Version 1.36.0

I used to be able to type: /** before my function like this:

/**
const myFunc = (myparams) => {}

then VSCode will immediately return:

/**
 * 
 * @param {*} myparams 
 */
const myFunc = (myparams) => {}

Now after the update of VSCode (I assume), it's very slow to pick up the comment. I normally have to quit VSCode and restart it to make it work, but it's very slow, it takes up to 2 seconds to return the JSDoc comment.

Comment isn't properly indented

Generated comments are not indented the same as the function.

/**
 * @param  {any} someParam
 */
        function myFunc(someParam) {
            return true;
        }

Make keyboard shortcut configurable

I'd love to use this extension, but CTRL-ALT-D is mapped to switching desktops on Ubuntu.
I understand that any shortcut would clash for someone, so would it be possible to make the shortcut configurable in the workspace settings?

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.