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

Gentype: propagate more comments #6334

Merged
merged 6 commits into from
Aug 8, 2023
Merged

Gentype: propagate more comments #6334

merged 6 commits into from
Aug 8, 2023

Conversation

zth
Copy link
Collaborator

@zth zth commented Jul 29, 2023

This propagates more comments from the ReScript code to emitted TS code via gentype.

  • Comments for types
  • Comments in the generated module-like structure

@zth zth requested a review from cristianoc July 29, 2023 20:03
export const DecideSubject__placeholder: (run:string, times:number) => void = CommentsBS.DecideSubject._placeholder;

export const DecideSubject: { _placeholder: (run:string, times:number) => void } = CommentsBS.DecideSubject
export const DecideSubject: {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This const represents the DecideSubject module in Comments.res, and it has a comment in the original res file, but I cannot for the life of me figure out how to propagate that comment out to here. It would be very valuable though, comments for modules are important.

@cristianoc any ideas?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gentype does not store info about modules.
It stores info about values, and what module they belong to.
I guess this would go to some separate module info somewhere.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After trying several different approaches with no luck I conclude this seem to require some fairly deep changes. Maybe I'm missing something valuable.

The rest in this PR is useful by itself - maybe we could review and merge what's in this PR, and then do module comments separately.

@@ -2,6 +2,23 @@ module StringMap = Map.Make (String)
module StringSet = Set.Make (String)
module Config = GenTypeConfig

module DocString : sig
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@@ -2,6 +2,23 @@ module StringMap = Map.Make (String)
module StringSet = Set.Make (String)
module Config = GenTypeConfig

module DocString : sig
type t
val make : string option -> t
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this abstraction?
An explicit string option would remove make and the interface.
Unless this will change in future.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably do without it. It was mostly a way to make sense of all the places where we had docstrings, where they would occasionally be formatted as comments already, and occasionally not. But I can probably just make it a string option now again. Let me give it a shot.

@zth zth merged commit 1293ec1 into master Aug 8, 2023
14 checks passed
@zth zth deleted the gentype-more-comments branch August 8, 2023 15:01
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.

2 participants