reddit / emacs

How to edit Typescript docstring examples like an org-babel source block?

Moardant · 2022-06-19 01:48
I have some typescript projects I'm working on, and trying to keep them well documented using some docstring comments with examples like this: ```typescript /** * A greeter function! * * @param name - Who to greet * @returns "hello {name}". * * @example * const greeter = hello("world") * greeter === "hello world" * */ export function hello(name: string): string { return `hello ${name}` } ``` What I would like is some way to edit the `@example` code as typescript code, like how I can edit an org-babel source block using `typescript-mode` in a popup buffer by calling `(org-edit-special &optional ARG)` using `C-c '` (in doom emacs). Ideally, I could just add the `@example` tag and then call some function to open a popup typescript buffer, which when I save it will add all of the necessary `* ` prefixes to each line. I thought maybe something like [polymode](https://github.com/polymode/polymode) might help, except the buffer is already in `typescript` mode.
KonpakuYoumu · 2022-06-19 10:53
https://github.com/twlz0ne/separedit.el
Moardant · 2022-06-19 12:23
Amazing, exactly what I was looking for!