-
Notifications
You must be signed in to change notification settings - Fork 23
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
Infer from type statements #164
base: master
Are you sure you want to change the base?
Infer from type statements #164
Conversation
Hey, thanks for the PR! When you follow the development guide, you can edit code in the With the extractor, you can just rerun |
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.
Just a quick review to guide you in the right direction.
Another thing outside of my review comments is that table types should be the equivalent of an @interface
tag, these should be inferred from type statements as well.
Don't forget to also write some test cases in extractor/test-input/
and set them up in extractor/tests/test-inputs.rs
. You can run the tests with cargo test
. We use insta for snapshot testing, you'll have to read the snapshots from your new tests, confirm everything is correct, and approve the changes.
Using insta was a bit confusing at first, a little tutorial in README.md or at least some mention of it would be nice. I can write it if you want, essentially just |
I also think adding a quick note on snapshot testing to the contributing section would be a great addition to the README.md, feel free to make a new PR for 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.
Looks good so far, we just need to fix some issues that appeared in the snapshot and fix some oversights.
It's mostly just avoiding trivia being included in the snapshot and also accounting for comments for interface fields.
extractor/tests/snapshots/test_inputs__passing__type_statement_inference.lua-stdout.snap
Show resolved
Hide resolved
extractor/tests/snapshots/test_inputs__passing__type_statement_inference.lua-stdout.snap
Outdated
Show resolved
Hide resolved
…eld` tag comments for overriding type and description
Having a bit of trouble with leading trivia being taken as part of type interface = {
field: number --- Comment
} The This is a problem in: doc_entry.fields.push(Field {
name,
lua_type: field.value().to_string(),
desc,
}); Is the best course of action to create a function that essentially does the same thing as Full Moon's |
I've been trying to find a nice way to solve this issue, because your proposed solution would be a lot of work.
Unfortunately, I haven't found a different solution that works. |
…ride comment\n\nAlso add entire TypeInfo stringifier to avoid trivia.
I checked snapshots and website preview, everything seems to work EXCEPT for types that use a colon (table and callback) not adding a space after the colon since my TypeInfo stringifier removes all trivia, including spaces. I think this is something the website should handle since, if someone's real Luau code does not have a space after the colon, the website should still be consistent. An example of the problem:
On the website, there is no space between "pet" and "pet". |
I wanted to try contributing to Moonwave and this seemed relatively easy to add. However, my current implementation has everything be on one line, instead of one line per field. I am pretty sure writing the table type explicitly, such as
@type {id: number}
displays properly, so I am not sure why inferring using Full Moon's string representation does not.Additionally, I am very new to Rust so feel free to nitpick on style or unidiomatic code. This code copies
TypeInfo
so that it can later be converted to a string - this sounds unnecessary to me but I could not see any other way to do it without using lifetimes, and considering the rest of theDocEntryKind
enum does not use lifetimes, it would feel weird to use it just for theType
variation. Additionally, functions seem to copy strings?I do not understand why
cargo install --path . --locked
needs to be run after every change whilecargo build
will not work (even if I call the executable with an absolute path totarget/release
). README.md mentions:Maybe I am missing something but I do not see a folder titled "moonwave". Is this just referring to hot reload when you edit Luau files?
Thanks!
Closes #155