Add doc comment functionality

This commit is contained in:
Tim Kuehn
2016-01-12 23:09:59 -08:00
parent 0d77959625
commit 7c34e06959
3 changed files with 25 additions and 10 deletions

View File

@@ -12,7 +12,7 @@ extern crate serde;
rpc! {
mod hello_service {
service {
hello(name: String) -> String;
rpc hello(name: String) -> String;
}
}
}

View File

@@ -11,8 +11,8 @@
//! rpc! {
//! mod my_server {
//! service {
//! hello(name: String) -> String;
//! add(x: i32, y: i32) -> i32;
//! rpc hello(name: String) -> String;
//! rpc add(x: i32, y: i32) -> i32;
//! }
//! }
//! }

View File

@@ -54,7 +54,10 @@ macro_rules! rpc {
mod $server:ident {
service {
$( $fn_name:ident( $( $arg:ident : $in_:ty ),* ) -> $out:ty;)*
$(
$(#[$attr:meta])*
rpc $fn_name:ident( $( $arg:ident : $in_:ty ),* ) -> $out:ty;
)*
}
}
) => {
@@ -63,7 +66,12 @@ macro_rules! rpc {
items { }
service { $( $fn_name($($arg: $in_),*) -> $out;)* }
service {
$(
$(#[$attr])*
rpc $fn_name($($arg: $in_),*) -> $out;
)*
}
}
}
};
@@ -81,7 +89,12 @@ macro_rules! rpc {
items { $($i:item)* }
// List any rpc methods: rpc foo(arg1: Arg1, ..., argN: ArgN) -> Out
service { $( $fn_name:ident( $( $arg:ident : $in_:ty ),* ) -> $out:ty;)* }
service {
$(
$(#[$attr:meta])*
rpc $fn_name:ident( $( $arg:ident : $in_:ty ),* ) -> $out:ty;
)*
}
}
) => {
#[doc="A module containing an rpc service and client stub."]
@@ -92,6 +105,7 @@ macro_rules! rpc {
#[doc="The provided RPC service."]
pub trait Service: Send + Sync {
$(
$(#[$attr])*
fn $fn_name(&self, $($arg:$in_),*) -> $out;
)*
}
@@ -161,8 +175,8 @@ mod test {
}
service {
hello(foo: Foo) -> Foo;
add(x: i32, y: i32) -> i32;
rpc hello(foo: Foo) -> Foo;
rpc add(x: i32, y: i32) -> i32;
}
}
}
@@ -197,7 +211,7 @@ mod test {
rpc! {
mod foo {
service {
hello() -> String;
rpc hello() -> String;
}
}
}
@@ -210,7 +224,8 @@ mod test {
}
service {
baz(s: String) -> HashMap<String, String>;
#[doc="Hello bob"]
rpc baz(s: String) -> HashMap<String, String>;
}
}
}