rocket_config_codegen/lib.rs
1#![feature(proc_macro_diagnostic)]
2#![recursion_limit="256"]
3
4//! # Rocket-Config - Code Generation
5//!
6//! This crate implements the code generation portions of Rocket-config.
7//! This includes procedural macros.
8//!
9//! ## Procedural Macros
10//!
11//! This crate implements the following procedural macros:
12//!
13//! * **configuration**
14//!
15//! The syntax for the `configuration` macro is:
16//!
17//! <pre>
18//! macro := configuration!(CONFIGURATION_FILE_STEM)
19//! </pre>
20//!
21//! ## Usage
22//!
23//! You **_should not_** directly depend on this library. To use the macros,
24//! it suffices to depend on `rocket-config` in `Cargo.toml`:
25//!
26//! ```toml
27//! [dependencies]
28//! rocket-config = "0.0.1"
29//! ```
30//!
31//! And to import the macros via `#[macro_use]` in the crate root:
32//!
33//! ```rust
34//! #![feature(proc_macro_hygiene, decl_macro)]
35//!
36//! #[macro_use] extern crate rocket_config;
37//!
38//! configuration!("test");
39//!
40//! // ...
41//! ```
42//!
43//! Or, alternatively, selectively import from the top-level scope:
44//!
45//! ```rust
46//! #![feature(proc_macro_hygiene, decl_macro)]
47//!
48//! extern crate rocket_config;
49//!
50//! use rocket_config::configuration;
51//!
52//! configuration!("test");
53//!
54//! // ...
55//! ```
56
57#![warn(rust_2018_idioms)]
58
59#[macro_use] extern crate quote;
60extern crate proc_macro;
61
62mod configuration;
63
64#[allow(unused_imports)]
65use proc_macro::TokenStream;
66
67/// The procedural macro for the `configuration` function-like macro.
68#[proc_macro]
69pub fn configuration(input: TokenStream) -> TokenStream {
70 configuration::configuration_function(input)
71}