Unify `fluent_embed` macro API as `localize()`
Dependencies
- [2]
OCR4YRQ2Parse group from fluent file specified by macro attribute - [3]
QSK7JRBAAdd simple `attribute_path` function - [4]
XGNME3WRMove `Group::derive_enum` to new `crate::parse_macro` module - [5]
UOMQT7LTAdd support for cardinal CLDR plural selectors - [6]
D652S2N3Rename `parse` module to `parse_fluent` - [7]
5TEX4MNUSplit `fluent_embed` into `group` and `parse` modules - [8]
HJMYJDC7Simplify `fluent_embed::group` module - [*]
O77KA6C4Create `fluent_embed` crate
Change contents
- edit in fluent_embed/src/parse_macro.rs at line 5
use proc_macro2::TokenStream; - edit in fluent_embed/src/parse_macro.rs at line 7
use syn::punctuated::Punctuated; - replacement in fluent_embed/src/parse_macro.rs at line 12
enum_data: syn::DataEnum,) -> proc_macro2::TokenStream {let mut idents = Vec::with_capacity(enum_data.variants.len());let mut messages = Vec::with_capacity(enum_data.variants.len());variants: Punctuated<syn::Variant, syn::token::Comma>,) -> TokenStream {let mut idents = Vec::with_capacity(variants.len());let mut messages = Vec::with_capacity(variants.len()); - replacement in fluent_embed/src/parse_macro.rs at line 17
for variant in enum_data.variants {for variant in variants { - replacement in fluent_embed/src/parse_macro.rs at line 55
pub fn attribute_groups(attribute: syn::Attribute) -> Group {match attribute.meta {syn::Meta::List(list_data) => {let path_literal: syn::LitStr = syn::parse2(list_data.tokens).unwrap();pub fn attribute_groups(path_literal: syn::LitStr) -> Group {// Read the fluent file at the given pathlet manifest_root = std::env::var("CARGO_MANIFEST_DIR").unwrap();let resource_path = PathBuf::from(manifest_root).join(path_literal.value());let fluent_contents = std::fs::read_to_string(resource_path).unwrap(); - replacement in fluent_embed/src/parse_macro.rs at line 61
// Read the fluent file at the given pathlet manifest_root = std::env::var("CARGO_MANIFEST_DIR").unwrap();let resource_path = PathBuf::from(manifest_root).join(path_literal.value());let fluent_contents = std::fs::read_to_string(resource_path).unwrap();// Parse the file into a `Group`let resource = fluent_syntax::parser::parse(fluent_contents).unwrap();let group = Group::from_resource(resource); - replacement in fluent_embed/src/parse_macro.rs at line 65
// Parse the file into a `Group`let resource = fluent_syntax::parser::parse(fluent_contents).unwrap();let group = Group::from_resource(resource);group} - replacement in fluent_embed/src/parse_macro.rs at line 68[3.328]→[2.554:572](∅→∅),[3.461]→[3.1589:1599](∅→∅),[2.572]→[3.1589:1599](∅→∅),[3.1589]→[3.1589:1599](∅→∅),[3.1599]→[3.462:545](∅→∅),[3.545]→[3.1599:1605](∅→∅),[3.1599]→[3.1599:1605](∅→∅)
group}syn::Meta::Path(_) => todo!(),syn::Meta::NameValue(_) => todo!(),}pub fn localize(path: syn::LitStr,ident: syn::Ident,variants: Punctuated<syn::Variant, syn::token::Comma>,) -> TokenStream {let group = attribute_groups(path);derive_enum(group, ident, variants) - replacement in fluent_embed/src/lib.rs at line 5
pub use group::Group;pub use parse_macro::{attribute_groups, derive_enum};[3.1387]pub use parse_macro::localize;