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

Implementing typescript doc_string #102

Closed
wants to merge 4 commits into from

Conversation

Mattchine
Copy link

Example in test file.

Fix my ts-to-zod issue.

Ps. I don't think passing comment from rust to ts is necessary so I decided to implement it as docstring

@NyxCode
Copy link
Collaborator

NyxCode commented May 29, 2022

thanks for the PR! Could you take a look at the merge conflict? Once it's resolved, I'd love to merge this.

@Mattchine
Copy link
Author

I think this solve the conflict.

Mattchine added 3 commits May 30, 2022 17:05
Adding doc_string to enum

Adding doc_string to newtype

Implement doc_string for tuple

Implement doc_string for tuple

Fix test
@Mattchine
Copy link
Author

Mattchine commented May 30, 2022

I have an idea of taking multi-line docstring as
#[ts(doc_string=["@params a", "second line"])]

But I'm not sure how to implement this. Any idea?

Ps. Currently you have to manually type as
#[ts(doc_string="@params a\n* second line")]

@NyxCode
Copy link
Collaborator

NyxCode commented Sep 17, 2022

@Mattchine Sorry for the late reply. I currently don't have much time for the project, though I hope that will change soon.

I have an idea of taking multi-line docstring as
#[ts(doc_string=["@params a", "second line"])]
But I'm not sure how to implement this. Any idea?

I think it should be possible to parse vanilla doc-comments (/// ..) in the proc macro. As far as I know, /// is desugared into #[doc = ".."]. I'll look into this as soon as I've got some spare time.

I feel like it would make sense to use a similar syntax for #[ts(doc_string)]. I also think it might make sense to directly parse #[doc] attributes and convert them to TS doc strings, but I'm not completely sure about that yet.

@timephy
Copy link
Contributor

timephy commented Nov 29, 2023

This would be awesome!
What's the state of this PR? I'd love to be able to work with this soon..

If you feel uncertain about whether to translate all docs from RS to TS - how about:

  • ts(doc) translates docs from RS to TS.
  • ts(doc_string="...") puts the given string into TS.
  • Otherwise no docs in TS

@escritorio-gustavo
Copy link
Contributor

This has been inactive since 2022 and #187 seems to reimplement it, so I'll be closing this PR

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.

None yet

4 participants