Skip to content

Apply JSDoc Comments to Lua code#1270

Merged
Perryvw merged 13 commits intoTypeScriptToLua:masterfrom
Zamiell:comments
May 30, 2022
Merged

Apply JSDoc Comments to Lua code#1270
Perryvw merged 13 commits intoTypeScriptToLua:masterfrom
Zamiell:comments

Conversation

@Zamiell
Copy link
Contributor

@Zamiell Zamiell commented May 7, 2022

Fixes #815, sort-of-but-not-really.

According to this StackOverlow page, it is not possible to get single-line comments in the AST. However, it is possible to extract JSDoc comments that are specifically attached to functions and variables.

So, for this PR, I simply extract JSDoc where I can, and then stick it on the "leadingComments" property that Perry added in 0fba69b.

This works, and seems good for a first iteration of the feature.

A better solution would be to:

  1. Wait for the Lua to be finished generating.
  2. Grab every possible comment in the entire TS source file via the method described in the StackOverflow post.
  3. Then, massage the comments into the already-generated-Lua.

However, how do we find the correct spot in the generated Lua that corresponds with this spot in the source code? Is that possible?

@Perryvw
Copy link
Member

Perryvw commented May 28, 2022

Could you make this respect the removeComments tsconfig configuration value

@Zamiell
Copy link
Contributor Author

Zamiell commented May 28, 2022

done

@Perryvw Perryvw merged commit da506ac into TypeScriptToLua:master May 30, 2022
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

Successfully merging this pull request may close these issues.

Preserve comments

3 participants