-
-
Notifications
You must be signed in to change notification settings - Fork 224
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
Merge askama_derive into askama #677
Conversation
We should keep askama_escape separate, that's actually used by other projects as well. I'll review the rest of this later. |
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.
So there wasn't really a need for a shared dependency between proc-macro and runtime code at all? 😮
Oh, it's used quite often actually. I did not notice. I unpicked c9e7657.
Once upon the time maybe there was. :)
I accepted cargo's suggestion to use |
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 think this is a good direction! Don't remember why I didn't do it this way in the first place...
Some nits, I'd like to take a closer look again after this.
askama/src/lib.rs
Outdated
@@ -73,7 +73,8 @@ pub use askama_shared::{ | |||
pub mod mime { | |||
#[cfg(all(feature = "mime_guess", feature = "mime"))] | |||
#[deprecated(since = "0.11.1", note = "Use Template::MIME_TYPE instead")] | |||
pub use crate::shared::extension_to_mime_type; | |||
#[allow(non_upper_case_globals)] | |||
pub const extension_to_mime_type: () = (); |
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 point of this? It's the same symbol, but it has a different type.
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.
To keep the deprecation notice, so the user gets a message how to proceed even thought their compilation will fail.
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 an interesting idea, but I think we should just get rid of the symbol instead. Probably not a lot of people using it anyway.
askama/Cargo.toml
Outdated
askama_shared = { version = "0.13.0", path = "../askama_shared", default-features = false } | ||
|
||
comrak = { version = "0.12", optional = true, default-features = false } | ||
humansize_ = { package = "humansize", version = "1.1.0", optional = true } |
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.
Not a fan of the _
suffixes here. Is there another way to do this?
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.
Yes, use a different prefix / suffix 😛
The prefix / suffix doesn't need to be visible in the code, you can rename the dependency back via extern crate humansize_ as humansize;
(related post on my blog).
The cleanest solution would be to not rename, and use dep:humansize
syntax for the dependency of the feature on the dependency. That is however a new feature from 1.60, so would raise the MSRV.
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.
We can rename the features instead of the dependencies, right?
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.
Sure, that works too. But it often causes a lot of confusion, especially when the name of the optional dependency was previously a feature name. Every optional dependency is automatically a feature (unless shadowed by an explicit feature as of 1.60), so there will be no error for activating the humansize
feature.
askama/src/filters/mod.rs
Outdated
use mod_humansize::{file_size_opts, FileSize}; | ||
#[cfg(feature = "num-traits")] | ||
use num_traits::{cast::NumCast, Signed}; | ||
use mod_num_traits::{cast::NumCast, Signed}; |
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.
A mod_
prefix is better than a _
suffix, I guess. :) I'm open for other ideas.
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.
There is also the possibility of having overlapping module / external crate names and disambiguating using ::humansize
for the crate and self::humansize
for the module.
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.
But the problem here isn't module vs crate names but crate name vs feature name, IIRC?
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's what the other review thread is about, this looks separate to me.
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.
No, it's the same issue.
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.
Oh, so mod_
as a crate name prefix? Yeah IMHO that's confusing, and crate
would be a better prefix (or suffix).
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.
To me a crate
{pre,suf}fix sounds like it's an alias for crate::
. How about pkg_*
, since the Cargo.toml option is called package
?
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.
Well, packages are a little bit of a different concept to crates, but it doesn't seem too bad. Other options could be dep
and ext
.
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.
Notably dep:
is the disambiguation syntax in current versions of Cargo.
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.
Yeah, I guess there's a difference between crates and packages. I'm also sure I will have forgotten about it again tomorrow. :)
I don't like ext_*
. So, dep_*
it is?
This has a conflict now, mind rebasing? I'll merge it soon! |
Rebased. |
No description provided.