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

Support for inserting jsdoc-like comments #41

Open
raxod502 opened this issue Jun 8, 2017 · 7 comments
Open

Support for inserting jsdoc-like comments #41

raxod502 opened this issue Jun 8, 2017 · 7 comments

Comments

@raxod502
Copy link

raxod502 commented Jun 8, 2017

As far as I know, TypeScript tends to be documented like this:

/**
 * Run the provided promise, and call process.exit with an appropriate code.
 */
export function runPromise<T>(promise: Promise<T>): void {

In js2-mode, I can type:

/**

and press C-M-j, to get:

/**
 * 
 */

with point at the end of the second line. This would be a nice feature to have in typescript.el, as well.

@josteink
Copy link
Member

josteink commented Jun 9, 2017

From the docs:

C-M-j runs the command indent-new-comment-line (found in global-map), which is an alias for ‘comment-indent-new-line’ in ‘newcomment.el’.

Running this command anywhere in typescript-mode gives mixed results:


var x;
|<- newline here

//
//|<- newline here

/*
/*|<- newline here

/**
/*|<- newline here

If we're going to override this command with a custom command for typescript-mode, we should properly address all these comment-styles.

@ananthakumaran
Copy link
Collaborator

I wonder whether we should rebind M-j to c-indent-new-comment-line by default. It seems to work better than indent-new-comment-line from my minimal testing.

@josteink
Copy link
Member

That's a good idea, and leaves us reinventing fewer wheels than we need to.

Have you experienced any cases where that does anything which is explicitly wrong?

@raxod502
Copy link
Author

It might also be relevant to ask @dgutov if there is a reason that js2-mode doesn't do this, and instead implements its own js2-line-break function.

@ananthakumaran
Copy link
Collaborator

ananthakumaran commented Jun 15, 2017

Have you experienced any cases where that does anything which is explicitly wrong?

It's not as good as js2-mode, but better than what we have. I never encountered any case so far where indent-new-comment-line is better

@dgutov
Copy link

dgutov commented Jun 15, 2017

In js2-mode, it's wasn't a particular decision to write js2-line-break instead of using c-indent-new-comment-line.

Before I got to it, js2-line-break was a command js2-enter-key bound to RET. So using a custom 'comment-line-break-function function provides some continuity.

So c-indent-new-comment-line might be a good choice of you, except it's tying you to CC Mode a bit, and will probably require you to set a few related variables.

@lddubeau lddubeau changed the title Support for jsdoc-like comments Support for inserting jsdoc-like comments Aug 22, 2017
@liyaodong
Copy link

FYI tide-jsdoc-templatecan insert now

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

5 participants