Add docs and remove unused code/imports.

This commit is contained in:
Jimmy Cuadra 2017-05-13 01:41:33 -07:00
parent 55d6b72a77
commit b1be0f411f
2 changed files with 8 additions and 14 deletions

View File

@ -1,3 +1,6 @@
//! Crate `ruma-api-macros` provides a procedural macro for easily generating `ruma-api` endpoints.
#![deny(missing_debug_implementations)]
#![feature(proc_macro)]
extern crate proc_macro;
@ -9,12 +12,13 @@ extern crate syn;
use proc_macro::TokenStream;
use quote::{ToTokens, Tokens};
use syn::{Expr, Field, Ident, Item};
use syn::{Expr, Field, Ident};
use parse::{Entry, parse_entries};
mod parse;
/// Generates a `ruma-api` endpoint.
#[proc_macro]
pub fn ruma_api(input: TokenStream) -> TokenStream {
let entries = parse_entries(&input.to_string()).expect("ruma_api! failed to parse input");

View File

@ -1,16 +1,13 @@
//! Implementation details of parsing proc macro input.
use syn::{
Attribute,
AttrStyle,
Expr,
Field,
Ident,
Item,
Lit,
MetaItem,
NestedMetaItem,
StrStyle,
Token,
TokenTree,
Visibility,
};
use syn::parse::{expr, ident, lit, ty};
@ -64,16 +61,9 @@ named!(struct_init_field -> (Ident, Expr), do_parse!(
(ident, expr)
));
named!(pub struct_like_body -> Vec<Field>, do_parse!(
punct!("{") >>
fields: terminated_list!(punct!(","), struct_field) >>
punct!("}") >>
(fields)
));
named!(struct_field -> Field, do_parse!(
attrs: many0!(outer_attr) >>
vis: visibility >>
visibility >>
id: ident >>
punct!(":") >>
ty: ty >>