Skip to content

Commit 279e0f0

Browse files
k-nasayoshuawuyts
authored andcommitted
Add doc comment (#250)
* doc: Add doc comment to tide-core * doc: Add documantation to tide-cookie * doc: Add doc to tide-compression * doc: Add doc comment * fix doc links * fix path * doc: Add doc comment
1 parent 3a0e592 commit 279e0f0

File tree

12 files changed

+44
-9
lines changed

12 files changed

+44
-9
lines changed

src/lib.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
nonstandard_style,
66
rust_2018_idioms,
77
future_incompatible,
8-
missing_debug_implementations
8+
missing_debug_implementations,
9+
missing_docs
910
)]
1011

1112
//!
@@ -41,6 +42,8 @@ pub use tide_core::{
4142
};
4243

4344
pub mod error {
45+
//! Module to export tide_core errors
46+
4447
pub use tide_core::error::{
4548
EndpointResult, Error, ResponseExt, ResultDynErrExt, ResultExt, StringError,
4649
};
@@ -50,6 +53,8 @@ pub use tide_forms as forms;
5053
pub use tide_querystring as querystring;
5154

5255
pub mod middleware {
56+
//! Module to export tide_core middleware
57+
5358
// Core
5459
pub use tide_core::middleware::{Middleware, Next};
5560

tide-compression/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
nonstandard_style,
99
rust_2018_idioms,
1010
future_incompatible,
11-
missing_debug_implementations
11+
missing_debug_implementations,
12+
missing_docs
1213
)]
1314

15+
//! Compression-related middleware for Tide
16+
1417
pub use accept_encoding::Encoding;
1518
use async_compression::stream;
1619
use futures::future::BoxFuture;

tide-cookies/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
nonstandard_style,
77
rust_2018_idioms,
88
future_incompatible,
9-
missing_debug_implementations
9+
missing_debug_implementations,
10+
missing_docs
1011
)]
1112

13+
//! Cookie management for Tide web framework
14+
1215
mod data;
1316
mod middleware;
1417

tide-cookies/src/middleware.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,21 @@ use tide_core::{
1010

1111
/// Middleware to work with cookies.
1212
///
13-
/// [`CookiesMiddleware`] along with [`ContextExt`](crate::data::ContextExt) provide smooth
13+
/// [`CookiesMiddleware`] along with [`ContextExt`] provide smooth
1414
/// access to request cookies and setting/removing cookies from response. This leverages the
1515
/// [cookie](https://crates.io/crates/cookie) crate.
1616
/// This middleware parses cookies from request and caches them in the extension. Once the request
1717
/// is processed by endpoints and other middlewares, all the added and removed cookies are set on
1818
/// on the response. You will need to add this middle before any other middlewares that might need
1919
/// to access Cookies.
20+
///
21+
/// [`CookiesMiddleware`]: crate::middleware::CookiesMiddleware
22+
/// [`ContextExt`]: ../../tide/cookies/trait.ContextExt.html
2023
#[derive(Clone, Default, Debug)]
2124
pub struct CookiesMiddleware {}
2225

2326
impl CookiesMiddleware {
27+
/// CookieMiddleware constructor
2428
pub fn new() -> Self {
2529
Self {}
2630
}

tide-core/src/app.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ impl<State: Send + Sync + 'static> App<State> {
220220
///
221221
/// Middleware can only be added at the "top level" of an application,
222222
/// and is processed in the order in which it is applied.
223+
///
224+
/// [`Middleware`]: crate::middleware::Middleware
223225
pub fn middleware(&mut self, m: impl Middleware<State>) -> &mut Self {
224226
self.middleware.push(Arc::new(m));
225227
self
@@ -270,6 +272,8 @@ impl<State: Send + Sync + 'static> App<State> {
270272
///
271273
/// This type is useful only in conjunction with the [`HttpService`] trait,
272274
/// i.e. for hosting a Tide app within some custom HTTP server.
275+
///
276+
/// [`HttpService`]: http_service::HttpService
273277
#[derive(Clone)]
274278
#[allow(missing_debug_implementations)]
275279
pub struct Server<State> {

tide-core/src/endpoint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::{response::IntoResponse, Context, Response};
99
/// directly by Tide users.
1010
///
1111
/// In practice, endpoints are functions that take a `Context<State>` as an argument and
12-
/// return a type `T` that implements [`IntoResponse`].
12+
/// return a type `T` that implements [`IntoResponse`](crate::response::IntoResponse).
1313
///
1414
/// # Examples
1515
///

tide-core/src/error.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1-
use http::{HttpTryFrom, Response, StatusCode};
2-
use http_service::Body;
1+
//! Error and Result module
32
43
use crate::response::IntoResponse;
4+
use http::{HttpTryFrom, Response, StatusCode};
5+
use http_service::Body;
56

67
#[derive(Debug)]
8+
/// A string error, which can be display
79
pub struct StringError(pub String);
810
impl std::error::Error for StringError {}
911

@@ -14,6 +16,7 @@ impl std::fmt::Display for StringError {
1416
}
1517

1618
#[macro_export]
19+
/// Macro that generates StringError immediately
1720
macro_rules! err_fmt {
1821
{$($t:tt)*} => {
1922
$crate::error::StringError(format!($($t)*))

tide-core/src/lib.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@
55
nonstandard_style,
66
rust_2018_idioms,
77
future_incompatible,
8-
missing_debug_implementations
8+
missing_debug_implementations,
9+
missing_docs
910
)]
1011
// TODO: Remove this after clippy bug due to async await is resolved.
1112
// ISSUE: https://github.com/rust-lang/rust-clippy/issues/3988
1213
#![allow(clippy::needless_lifetimes)]
1314

15+
//!
16+
//! Tide core api document
17+
//!
18+
//! The [`App`] docs are a good place to get started.
19+
//!
20+
1421
mod app;
1522
mod context;
1623
mod endpoint;

tide-core/src/middleware.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
//! Middlewares
2+
13
use crate::{endpoint::DynEndpoint, Context, Response};
24
use futures::future::BoxFuture;
3-
45
use std::sync::Arc;
56

67
/// Middleware that wraps around remaining middleware chain.

tide-core/src/response.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
//! Multiple types of response modules
2+
13
use http_service::Body;
24

5+
/// An Http response
36
pub type Response = http_service::Response;
47

58
/// Serialize `t` into a JSON-encoded response.

tide-core/src/route.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ impl<'a, State: 'static> Route<'a, State> {
3737
}
3838
}
3939

40+
/// Add endpoint nested routes
4041
pub fn nest(&mut self, f: impl FnOnce(&mut Route<'a, State>)) -> &mut Self {
4142
f(self);
4243
self

tide-querystring/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use tide_core::{error::Error, Context};
1515

1616
/// An extension trait for `Context`, providing query string deserialization.
1717
pub trait ContextExt<'de> {
18+
/// Analyze url and extract query parameters
1819
fn url_query<T: Deserialize<'de>>(&'de self) -> Result<T, Error>;
1920
}
2021

0 commit comments

Comments
 (0)