Skip to content
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

Merged
merged 1 commit into from
Jun 8, 2022
Merged

Merge askama_derive into askama #677

merged 1 commit into from
Jun 8, 2022

Conversation

Kijewski
Copy link
Collaborator

No description provided.

@Kijewski
Copy link
Collaborator Author

Ping @jplatte.

Per #676, IMO this makes the project much easier to understand.

@djc
Copy link
Collaborator

djc commented Apr 26, 2022

We should keep askama_escape separate, that's actually used by other projects as well. I'll review the rest of this later.

Copy link
Contributor

@jplatte jplatte left a 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? 😮

askama_derive/src/input.rs Outdated Show resolved Hide resolved
askama_derive/src/generator.rs Outdated Show resolved Hide resolved
askama/Cargo.toml Outdated Show resolved Hide resolved
@Kijewski
Copy link
Collaborator Author

We should keep askama_escape separate, that's actually used by other projects as well. I'll review the rest of this later.

Oh, it's used quite often actually. I did not notice. I unpicked c9e7657.

So there wasn't really a need for a shared dependency between proc-macro and runtime code at all?

Once upon the time maybe there was. :)

This raises the MSRV for 1.60, although it seems like no MSRV than stable is enforced anyways?

I accepted cargo's suggestion to use dep:* without thinking. I use renaming now. The tests now run with 1.53 (any maybe older toolchains, too, but well … 1.53 is the oldest one I have installed except the ancient 1.36 + 1.38). Except for the ui tests (tests that are supposed to fail). Somewhen we broke them for the old versions even though we use version_check.

@Kijewski Kijewski changed the title Remove crates askama_escape and askama_shared Split askama_shared into askama and askama_derive Apr 26, 2022
Copy link
Collaborator

@djc djc left a 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.

@@ -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: () = ();
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

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_derive/src/lib.rs Outdated Show resolved Hide resolved
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 }
Copy link
Collaborator

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?

Copy link
Contributor

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.

Copy link
Collaborator

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?

Copy link
Contributor

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.

Comment on lines 24 to 26
use mod_humansize::{file_size_opts, FileSize};
#[cfg(feature = "num-traits")]
use num_traits::{cast::NumCast, Signed};
use mod_num_traits::{cast::NumCast, Signed};
Copy link
Collaborator Author

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.

Copy link
Contributor

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.

Copy link
Collaborator

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?

Copy link
Contributor

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.

Copy link
Collaborator Author

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.

Copy link
Contributor

@jplatte jplatte May 24, 2022

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).

Copy link
Collaborator Author

@Kijewski Kijewski May 24, 2022

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?

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Collaborator Author

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?

@Kijewski Kijewski changed the title Split askama_shared into askama and askama_derive Merge askama_derive into askama May 24, 2022
@djc
Copy link
Collaborator

djc commented Jun 8, 2022

This has a conflict now, mind rebasing? I'll merge it soon!

@Kijewski
Copy link
Collaborator Author

Kijewski commented Jun 8, 2022

Rebased.

@djc djc merged commit 6cce13f into rinja-rs:main Jun 8, 2022
@Kijewski Kijewski deleted the pr-back-into-derive branch September 21, 2022 11:39
@djc djc mentioned this pull request Feb 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants