Skip to content

Commit ba6d943

Browse files
committed
Remove requirements for users to import other crates.
1 parent 5efba23 commit ba6d943

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

macros/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,13 @@ define_proc_macros! {
6767
}).collect();
6868

6969
let mut map = phf_codegen::Map::new();
70+
map.phf_path("::cssparser::phf");
7071
for &(ref key, ref value) in &pairs {
7172
map.entry(&**key, &**value);
7273
}
7374

7475
let mut tokens = quote! {
75-
static MAP: ::phf::Map<&'static str, #value_type> =
76+
static MAP: ::cssparser::phf::Map<&'static str, #value_type> =
7677
};
7778
let mut initializer_bytes = Vec::new();
7879
map.build(&mut initializer_bytes).unwrap();

src/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,15 @@ fn parse_border_spacing(_context: &ParserContext, input: &mut Parser)
7171
#[macro_use] extern crate cssparser_macros;
7272
#[macro_use] extern crate matches;
7373
#[macro_use] extern crate procedural_masquarade;
74-
extern crate phf;
74+
pub extern crate phf;
7575
#[cfg(test)] extern crate encoding_rs;
7676
#[cfg(test)] extern crate tempdir;
7777
#[cfg(test)] extern crate rustc_serialize;
7878
#[cfg(feature = "serde")] extern crate serde;
7979
#[cfg(feature = "heapsize")] #[macro_use] extern crate heapsize;
8080

81+
pub use cssparser_macros::*;
82+
8183
pub use tokenizer::{Token, NumericValue, PercentageValue, SourceLocation};
8284
pub use rules_and_declarations::{parse_important};
8385
pub use rules_and_declarations::{DeclarationParser, DeclarationListParser, parse_one_declaration};
@@ -90,8 +92,12 @@ pub use serializer::{ToCss, CssStringWriter, serialize_identifier, serialize_str
9092
pub use parser::{Parser, Delimiter, Delimiters, SourcePosition};
9193
pub use unicode_range::UnicodeRange;
9294

95+
// For macros
9396
#[doc(hidden)] pub use macros::_internal__to_lowercase;
9497

98+
// For macros when used in this crate. Unsure how $crate works with procedural-masquarade.
99+
mod cssparser { pub use phf; }
100+
95101
#[macro_use]
96102
mod macros;
97103

src/macros.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,12 @@ define_invoke_proc_macro!(cssparser_internal__invoke_proc_macro);
77
/// Expands to an expression equivalent to a `match` with string patterns,
88
/// but matching is case-insensitive in the ASCII range.
99
///
10-
/// Requirements:
11-
///
12-
/// * The `cssparser_macros` crate must also be imported at the crate root
13-
/// * The patterns must not contain ASCII upper case letters. (They must be already be lower-cased.)
10+
/// The patterns must not contain ASCII upper case letters. (They must be already be lower-cased.)
1411
///
1512
/// # Example
1613
///
1714
/// ```rust
1815
/// #[macro_use] extern crate cssparser;
19-
/// #[macro_use] extern crate cssparser_macros;
2016
///
2117
/// # fn main() {} // Make doctest not wrap everythig in its own main
2218
/// # fn dummy(function_name: &String) { let _ =
@@ -62,14 +58,10 @@ macro_rules! match_ignore_ascii_case {
6258
/// and returns a reference to the corresponding value.
6359
/// Matching is case-insensitive in the ASCII range.
6460
///
65-
/// The `phf` and `cssparser_macros` crates must also be imported at the crate root
66-
///
6761
/// ## Example:
6862
///
6963
/// ```rust
70-
/// extern crate phf;
7164
/// #[macro_use] extern crate cssparser;
72-
/// #[macro_use] extern crate cssparser_macros;
7365
///
7466
/// # fn main() {} // Make doctest not wrap everythig in its own main
7567
///

0 commit comments

Comments
 (0)