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 |
YetAnotherClown
left a comment
There was a problem hiding this comment.
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. |
YetAnotherClown
left a comment
There was a problem hiding this comment.
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
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". |
You can just extract the individual tokenreferences and do |
|
Perhaps it should be explicitly stated on the official website that type statement inference is supported? Not too sure since in theory everything that makes sense should be supported - maybe a simple message saying that assignments, function declarations, and type declarations are inferred from. I mentioned this a bit here: #176 (comment) |
|
There is a Clippy warning: - type_info: Option<TypeInfo>,
+ type_info: Box<Option<TypeInfo>>,Should I make this change? |
extractor/tests/snapshots/test_inputs__passing__type_statement_inference.lua-stdout.snap
Show resolved
Hide resolved
Test nameNow I kind of want to rename the test from Lua file extensionAnother useless change would be switching from the |
Typeof CommentsBy the way, I just want to draw attention to this commit: 0a4c060 type data = typeof({} :: {
id: number --- Monotonically increases.
}) |
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
TypeInfoso 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 theDocEntryKindenum does not use lifetimes, it would feel weird to use it just for theTypevariation. Additionally, functions seem to copy strings?I do not understand why
cargo install --path . --lockedneeds to be run after every change whilecargo buildwill 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