typescript.el icon indicating copy to clipboard operation
typescript.el copied to clipboard

Support for inserting jsdoc-like comments

Open raxod502 opened this issue 7 years ago • 7 comments

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.

raxod502 avatar Jun 08 '17 20:06 raxod502

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.

josteink avatar Jun 09 '17 08:06 josteink

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.

ananthakumaran avatar Jun 15 '17 12:06 ananthakumaran

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?

josteink avatar Jun 15 '17 13:06 josteink

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.

raxod502 avatar Jun 15 '17 15:06 raxod502

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

ananthakumaran avatar Jun 15 '17 16:06 ananthakumaran

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.

dgutov avatar Jun 15 '17 18:06 dgutov

FYI tide-jsdoc-templatecan insert now

nothingrealhappen avatar Nov 15 '18 03:11 nothingrealhappen