Use the name and description fields to generate better documentation.
This commit is contained in:
parent
6a09f1f754
commit
557ac4b485
@ -332,6 +332,10 @@ impl ToTokens for Api {
|
||||
}
|
||||
};
|
||||
|
||||
let endpoint_doc = format!("The `{}` API endpoint.\n\n{}", name, description);
|
||||
let request_doc = format!("Data for a request to the `{}` API endpoint.", name);
|
||||
let response_doc = format!("Data in the response from the `{}` API endpoint.", name);
|
||||
|
||||
let api = quote! {
|
||||
#[allow(unused_imports)]
|
||||
use ::futures::{Future as _, IntoFuture as _, Stream as _};
|
||||
@ -341,10 +345,11 @@ impl ToTokens for Api {
|
||||
|
||||
use ::std::convert::{TryInto as _};
|
||||
|
||||
/// The API endpoint.
|
||||
#[doc = #endpoint_doc]
|
||||
#[derive(Debug)]
|
||||
pub struct Endpoint;
|
||||
|
||||
#[doc = #request_doc]
|
||||
#request_types
|
||||
|
||||
impl ::std::convert::TryFrom<::http::Request<Vec<u8>>> for Request {
|
||||
@ -412,6 +417,7 @@ impl ToTokens for Api {
|
||||
}
|
||||
}
|
||||
|
||||
#[doc = #response_doc]
|
||||
#response_types
|
||||
|
||||
impl ::std::convert::TryFrom<Response> for ::http::Response<::hyper::Body> {
|
||||
@ -457,7 +463,7 @@ impl ToTokens for Api {
|
||||
type Request = Request;
|
||||
type Response = Response;
|
||||
|
||||
/// Metadata for this endpoint.
|
||||
/// Metadata for the `#name` endpoint.
|
||||
const METADATA: ::ruma_api::Metadata = ::ruma_api::Metadata {
|
||||
description: #description,
|
||||
method: ::http::Method::#method,
|
||||
|
@ -250,7 +250,6 @@ impl From<Vec<Field>> for Request {
|
||||
impl ToTokens for Request {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let request_struct_header = quote! {
|
||||
/// Data for a request to this API endpoint.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Request
|
||||
};
|
||||
|
@ -236,7 +236,6 @@ impl From<Vec<Field>> for Response {
|
||||
impl ToTokens for Response {
|
||||
fn to_tokens(&self, tokens: &mut TokenStream) {
|
||||
let response_struct_header = quote! {
|
||||
/// Data in the response from this API endpoint.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Response
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user