-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Add Constant type/value properties #280
Add Constant type/value properties #280
Conversation
allow reading constant value/expr/is_literal and type (this one serialized to a json string since there is no impl to convert it to FieldValue)
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.
Nicely done! Thanks for the PR, I'd be happy to merge something like this.
I have a few suggestions around how to get the type info out more conveniently, and around some of the docs structure. Nothing major, should be resolvable in just a couple of minutes.
Also, are you interested in associated constants as well, or just regular ones? If the associated constants are missing fields, I'd be happy to take a PR there as well.
Co-authored-by: Predrag Gruevski <[email protected]>
to avoid repeating said example
just the regular ones, the associated ones already have the default value though seems to miss the |
until trustfall adds proper support for custom scalar types
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 couple of nitpicks on docs and such, otherwise it's good to merge. I usually don't merge PRs marked "draft" so when you've had a chance to take one more look and feel it's good to merge on your end, move it out of the draft state and I'll give it another quick look as well and then merge + publish.
If the constant is set: | ||
|
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.
minor formatting nit:
If the constant is set: | |
If the constant is set: |
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.
This is actually intentional since no space after the "header" breaks the formatting, so instead of 2 bullet points you get one line (at least in my Sublime editor with LSP plugin)
Not sure how it works in your wasm playground or any other tools
Let me know if you want to add an extra empty line before anyway (personally prefer a bit more compact, but up to you)
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.
Ah nice, thanks for double-checking it in the editor.
Let's add the extra empty line before the block, though. I think that way it's a bit more readable when it's not rendered as markdown.
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's just the adding the newline, so I'll merge this as-is and add the newline in a separate PR and then cut a release so we can move faster.
trait BatchIterator<const MIN: usize> { | ||
const SIZE: usize = 16; // `"16"` is the default | ||
const LOG_AS: &'static str = "batch"; // `"\"batch\""` is the default, including escaped quotes | ||
const MIN_SIZE: usize = MIN; // "MIN" is the default, referring to the other constant's name |
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.
In the original example, MIN_SIZE
was referring to the const generic constant. In the new example it refers to a local sibling constant only, and there's no example with a const generic. Mind adding a const generic example as well?
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.
restored MIN to be the const generic and the sibling is just a standalone NUM number
Co-authored-by: Predrag Gruevski <[email protected]>
Co-authored-by: Predrag Gruevski <[email protected]>
Co-authored-by: Predrag Gruevski <[email protected]>
Co-authored-by: Predrag Gruevski <[email protected]>
ea49e69
to
e0ced16
Compare
c109df4
to
e0a90fe
Compare
expr/value/is_literal
e0a90fe
to
0f75831
Compare
Done the last thing I wanted - updated a test, though had to split logic for Constants with more properties like (although I've only run the local test for this updaed const crate, not the whole test suite) Then pending the unresolved doc formatting edits should be more or less fine? And as far as I understood, porting to other rustdocs versions is semi-auto-done with the help of your magic script? |
Looks great. Going to merge this, add the newline in the docs, and cut a new release that you should be able to use. Thanks for the help! Let me know how this all works out in your use case.
Yup! I'll take care of porting it and cut a release for all the rustdoc versions that |
* add Constant property resolution function allow reading constant value/expr/is_literal and type (this one serialized to a json string since there is no impl to convert it to FieldValue) * add Constant property rustdocs example * add Constant property rustdoc schema * dep: add serde_json for Constant property Type * fix clippy * uglify with rustfmt * Update src/rustdoc_schema.graphql Co-authored-by: Predrag Gruevski <[email protected]> * squeeze doc comment * add a doc comment note referencing a more comprehensive example to avoid repeating said example * add type_ field to AssociatedConstant property resolution function (temporary in the json string format) * add type_ field to AssociatedConstant property rustdoc schema * split schema docs so that each Constant property is documented * update schema doc comment * update schema docs trait name * fix a typo in schema docs * remove type Assoc/Const property until trustfall adds proper support for custom scalar types * remove type Assoc/Const property from schema * fix a typo in schema docs Co-authored-by: Predrag Gruevski <[email protected]> * dep: remove serde_json since Constant property Type was removed Co-authored-by: Predrag Gruevski <[email protected]> * remove unstable rustdocs example for Constant properties Co-authored-by: Predrag Gruevski <[email protected]> * Update formatting of the schema docs Co-authored-by: Predrag Gruevski <[email protected]> * Update AssociatedConstant example to refer to a const generic * Update Constant test with extra properties expr/value/is_literal --------- Co-authored-by: Predrag Gruevski <[email protected]>
* add Constant property resolution function allow reading constant value/expr/is_literal and type (this one serialized to a json string since there is no impl to convert it to FieldValue) * add Constant property rustdocs example * add Constant property rustdoc schema * dep: add serde_json for Constant property Type * fix clippy * uglify with rustfmt * Update src/rustdoc_schema.graphql Co-authored-by: Predrag Gruevski <[email protected]> * squeeze doc comment * add a doc comment note referencing a more comprehensive example to avoid repeating said example * add type_ field to AssociatedConstant property resolution function (temporary in the json string format) * add type_ field to AssociatedConstant property rustdoc schema * split schema docs so that each Constant property is documented * update schema doc comment * update schema docs trait name * fix a typo in schema docs * remove type Assoc/Const property until trustfall adds proper support for custom scalar types * remove type Assoc/Const property from schema * fix a typo in schema docs Co-authored-by: Predrag Gruevski <[email protected]> * dep: remove serde_json since Constant property Type was removed Co-authored-by: Predrag Gruevski <[email protected]> * remove unstable rustdocs example for Constant properties Co-authored-by: Predrag Gruevski <[email protected]> * Update formatting of the schema docs Co-authored-by: Predrag Gruevski <[email protected]> * Update AssociatedConstant example to refer to a const generic * Update Constant test with extra properties expr/value/is_literal --------- Co-authored-by: Predrag Gruevski <[email protected]>
* add Constant property resolution function allow reading constant value/expr/is_literal and type (this one serialized to a json string since there is no impl to convert it to FieldValue) * add Constant property rustdocs example * add Constant property rustdoc schema * dep: add serde_json for Constant property Type * fix clippy * uglify with rustfmt * Update src/rustdoc_schema.graphql * squeeze doc comment * add a doc comment note referencing a more comprehensive example to avoid repeating said example * add type_ field to AssociatedConstant property resolution function (temporary in the json string format) * add type_ field to AssociatedConstant property rustdoc schema * split schema docs so that each Constant property is documented * update schema doc comment * update schema docs trait name * fix a typo in schema docs * remove type Assoc/Const property until trustfall adds proper support for custom scalar types * remove type Assoc/Const property from schema * fix a typo in schema docs * dep: remove serde_json since Constant property Type was removed * remove unstable rustdocs example for Constant properties * Update formatting of the schema docs * Update AssociatedConstant example to refer to a const generic * Update Constant test with extra properties expr/value/is_literal --------- Co-authored-by: Evgeny <[email protected]>
* add Constant property resolution function allow reading constant value/expr/is_literal and type (this one serialized to a json string since there is no impl to convert it to FieldValue) * add Constant property rustdocs example * add Constant property rustdoc schema * dep: add serde_json for Constant property Type * fix clippy * uglify with rustfmt * Update src/rustdoc_schema.graphql * squeeze doc comment * add a doc comment note referencing a more comprehensive example to avoid repeating said example * add type_ field to AssociatedConstant property resolution function (temporary in the json string format) * add type_ field to AssociatedConstant property rustdoc schema * split schema docs so that each Constant property is documented * update schema doc comment * update schema docs trait name * fix a typo in schema docs * remove type Assoc/Const property until trustfall adds proper support for custom scalar types * remove type Assoc/Const property from schema * fix a typo in schema docs * dep: remove serde_json since Constant property Type was removed * remove unstable rustdocs example for Constant properties * Update formatting of the schema docs * Update AssociatedConstant example to refer to a const generic * Update Constant test with extra properties expr/value/is_literal --------- Co-authored-by: Evgeny <[email protected]>
New versions are available on crates.io! |
This is some draft of the edits I've made (currently only to v26 as that's the version of the locally generated docs) to be able to extract a list of constants from a crate as mentioned in #279
Unresolved question:
Type
since there is no conversion to trustfall::FieldValue implemented for this type, but that seems clunky, so what's the easiest way to have a proper support of this conversion (is it only possible in the trustfall main crate?)try_into_struct
into a string field, can't make it deserialise from json automatically).
(haven't done any formatting/tests yet)