-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Address final review of #2638 #2788
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some comments @cprecioso , I like where we are going, I think we are quite closer to a finished thing!
Except for what I commented on, one main thing that I am suspicious a bit of is the current LanguageInfo
situation. That whole part is certainly better now, as you said it is more explicit, there are less hidden assumptions. But on the other hand, this centralization of LanguageInfo seems a bit weird to me, a bit artifical and too emphasized. I tryed playing a bit with replacing that structure with functions like function tsToJsExt (tsExt: "ts" | "tsx"): "js" | "jsx"
and function tsExtIsJsx (tsExt: "ts" | "tsx"): boolean
but I am not sure that is the right direction either.
Maybe that is ok all together -> I would say, let's take care of everyting that is outstanding, then at the very end we can take one last look at the LanguageInfo situation and see if we want to do something there or not, it will be clearer situation then.
Deploying wasp-docs-on-main with
|
Latest commit: |
b8d75e7
|
Status: | ✅ Deploy successful! |
Preview URL: | https://5a5f0985.wasp-docs-on-main.pages.dev |
Branch Preview URL: | https://cprecioso-push-lxzuqtyxotlm.wasp-docs-on-main.pages.dev |
@Martinsos addressed the comments, please review
I think Haskell-isms are leading you on here, I wouldn't say this kind of solution is idiomatic JS/TS at all.
Well, yes 😅 If we want to operate at this level of abstraction, we need a more-or-less central way of defining the transformation. And right now, it does look like overkill for just two possible alternatives. If we want to make it simpler I think I'd end up slipping back to something very similar to what we had. |
Yes it is probably a bit of Haskellisms as you said :D. I do find Haskell often to influence my code in other languages for better though, so I don't disregard them but usually follow them, to see where it brings me. Ok, good with me, nice stuff! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cprecioso ok we are very close now! I think there is nothing major left,expect for one thing that I would really want us to fix before we close this, and that is making that function for chekcing the meta flag work correctly and not give false positives.
@Martinsos ready |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cprecioso some last improvements for the new code and I think that will be it.
web/src/remark/util/code-blocks.ts
Outdated
import type { VFile } from "vfile"; | ||
import { formatCode, FormatCodeOptions } from "./prettier"; | ||
|
||
const CODE_BLOCK_META_REGEX = /([^\s=]+)(?:="([^"]*)")?/g; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this regex is standalone here, and not inside the function that uses it, I would shortly document what it intends to capture, since regexes are not easy to read not get the intention from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment for the parse
function can work for both
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice comment on the CODE_BLOCK_META_REGEX
! Doesn't mention anything about what matching groups capture, nor does it have an example, but that ok, reader can figure that on their own also.
I am not sure what do you mean by
The comment for the parse function can work for both
I wouldn't count on parseCodeBlockMetaString
being documented by comment that is on CODE_BLOCK_META_REGEX
. They are close to each other right now, in the source file, but they are both top level definitions in this file, and that makes them standalone. Meaning that their implementations and contracts/APIs are not tied together and can digress at any moment, even if they stay close to each other (which also might change).
So if we think parseCodeBlockMetaString
deserves a comment explaining what it expects from the metaString
, and I think it does (I probably suggested it earlier? I can't remember), then there should be an explicit comment. If nothing, let's at least in that comment tell the reader to check out the CODE_BLOCK_META_REGEX
, that metaString
needs to satisfy it -> that will already work well enough. Because at the moment that is only implementation detail, and is not a part of the contract/API of this function, this way you make it so though.
It would be a different story if you moved that regex inside of the parseCodeBlockMetaString function, then it would be an implementation detail and any comment would be just there to make it easier to understand it, not to define the contract/API of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It really feels like we'd prefer the regex to be inside of the function so I did that 😜
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That also works! I don't mind any of the approaches, as long as stuff has clear APIs/contracts.
RAW
@Martinsos ready |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! But there check out the last comments I left, one of them will probably need handling before merging (adding comments to parse
function). Then merge.
@Martinsos check it out |
All good, and I already approved it last time, feel free to merge! |
Review changes for #2638