-
Notifications
You must be signed in to change notification settings - Fork 761
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 docs + slight refactor for num-complex and num-bigint dependencies #1670
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.
Overall this is a really nice tidy-up, thank you!
My main query is regarding the #[must_use]
annotations. I highlighted two but there's a few more. Are they really necessary?
src/num_bigint.rs
Outdated
//! ```toml | ||
//! [dependencies] | ||
//! num-bigint = "0.4" | ||
//! pyo3 = { version = "0.14", features = ["num-bigint"] } | ||
//! ``` |
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.
Agreed this is useful to have but I worry we'll forget to update the versions...
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.
I don't think there is a way to auto update it :/ This is definitely going to be an annoying maintenance burden going forward.
I've seen other crates document this like:
[dependencies]
# replace * with the current pyo3 version
pyo3 = { version = "*", features = ["num-bigint"] }
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 seems like a really good idea. Could also say "check pyo3's Cargo.toml
" for supported num-bigint
version?
... or we could do something fun with an mdbook
preprocessor to parse Cargo.toml
and put the supported num-bigint
version in the guide in a table 🙈
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.
or we could do something fun with an mdbook preprocessor to parse Cargo.toml and put the supported num-bigint version in the guide in a table 🙈
Can we do something dynamically in the docs? I'd really prefer something that can be straight up copy-pasted.
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.
I'm not aware of similar tricks to do dynamic docs, however if you want to go for something dynamic in the guide you might find the existing preprocessor I wrote useful: https://github.com/PyO3/pyo3/blob/main/guide/pyo3_version.py
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 we have other locations where the current version must be substituted, I think the best way is a small (Python) script that replaces everything at once. This can then be run simply as part of the release process.
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.
I tried a couple of things but didn't find anything that didn't feel like a gross hack. So I've just taken the *
approach as above.
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.
What's the "gross hack" with my suggestion?
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 not, really. I figured out a proc macro that does it by just search+replacing text in a module, but it doesn't work in lib.rs and messes up the [src] links (which is pretty gross).
I don't like the idea of adding things to the release process for something that's at best "nice to have". It's not that big of a deal on its own but these things do add up.
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.
TBH I would be happy to have a python script to automate releasing (at the moment it's done manually by me), but i think that's best in a separate PR.
I'm not sure how to fix the failing I see the following solutions:
|
Hmm, that's an awkward one. I think I'd rather not do anything too complicated but agree it'd be nice to test the example. How about ditching |
I've I think that is all 👌 |
If you can afford it, could you please revise the tests to use |
@kngwyu sure! |
Thanks! |
nalgebra
as a dev-dependency - this is required to test the num-complex example. I really wanted an example that shows usingComplex
in a linear algebra crate, which is probably what most people using the feature want to do. I don't like adding dependencies, but given that it requires two other crates I would feel uncomfortable not testing it.Rendered