Skip to content

Commit 9e635bd

Browse files
committed
refactor: improve cargo doc features
1 parent 680c8aa commit 9e635bd

File tree

7 files changed

+29
-2
lines changed

7 files changed

+29
-2
lines changed

src/compression.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ pub fn auto(
115115
/// Create a wrapping handler that compresses the Body of a [`Response`](hyper::Response)
116116
/// using gzip, adding `content-encoding: gzip` to the Response's [`HeaderMap`](hyper::HeaderMap)
117117
#[cfg(feature = "compression-gzip")]
118+
#[cfg_attr(docsrs, doc(cfg(feature = "compression-gzip")))]
118119
pub fn gzip(
119120
mut head: http::response::Parts,
120121
body: CompressableBody<Body, hyper::Error>,
@@ -131,6 +132,7 @@ pub fn gzip(
131132
/// Create a wrapping handler that compresses the Body of a [`Response`](hyper::Response)
132133
/// using deflate, adding `content-encoding: deflate` to the Response's [`HeaderMap`](hyper::HeaderMap)
133134
#[cfg(feature = "compression-deflate")]
135+
#[cfg_attr(docsrs, doc(cfg(feature = "compression-deflate")))]
134136
pub fn deflate(
135137
mut head: http::response::Parts,
136138
body: CompressableBody<Body, hyper::Error>,
@@ -152,6 +154,7 @@ pub fn deflate(
152154
/// Create a wrapping handler that compresses the Body of a [`Response`](hyper::Response)
153155
/// using brotli, adding `content-encoding: br` to the Response's [`HeaderMap`](hyper::HeaderMap)
154156
#[cfg(feature = "compression-brotli")]
157+
#[cfg_attr(docsrs, doc(cfg(feature = "compression-brotli")))]
155158
pub fn brotli(
156159
mut head: http::response::Parts,
157160
body: CompressableBody<Body, hyper::Error>,
@@ -171,6 +174,7 @@ pub fn brotli(
171174
/// Create a wrapping handler that compresses the Body of a [`Response`](hyper::Response)
172175
/// using zstd, adding `content-encoding: zstd` to the Response's [`HeaderMap`](hyper::HeaderMap)
173176
#[cfg(feature = "compression-zstd")]
177+
#[cfg_attr(docsrs, doc(cfg(feature = "compression-zstd")))]
174178
pub fn zstd(
175179
mut head: http::response::Parts,
176180
body: CompressableBody<Body, hyper::Error>,

src/directory_listing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
//! It provides directory listig and auto-index support.
77
//!
88
9-
#![allow(missing_docs)]
10-
119
use chrono::{DateTime, Local, NaiveDateTime, Utc};
1210
use clap::ValueEnum;
1311
use futures_util::future::Either;
@@ -29,7 +27,9 @@ use crate::{exts::http::MethodExt, Context, Result};
2927
#[serde(rename_all = "lowercase")]
3028
/// Directory listing output format for file entries.
3129
pub enum DirListFmt {
30+
/// HTML format to display (default).
3231
Html,
32+
/// JSON format to display.
3333
Json,
3434
}
3535

src/handler.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@ pub struct RequestHandlerOpts {
4242
pub compression_static: bool,
4343
/// Directory listing feature.
4444
#[cfg(feature = "directory-listing")]
45+
#[cfg_attr(docsrs, doc(cfg(feature = "directory-listing")))]
4546
pub dir_listing: bool,
4647
/// Directory listing order feature.
4748
#[cfg(feature = "directory-listing")]
49+
#[cfg_attr(docsrs, doc(cfg(feature = "directory-listing")))]
4850
pub dir_listing_order: u8,
4951
#[cfg(feature = "directory-listing")]
52+
#[cfg_attr(docsrs, doc(cfg(feature = "directory-listing")))]
5053
/// Directory listing format feature.
5154
pub dir_listing_format: DirListFmt,
5255
/// CORS feature.
@@ -65,6 +68,7 @@ pub struct RequestHandlerOpts {
6568
pub page_fallback: Vec<u8>,
6669
/// Basic auth feature.
6770
#[cfg(feature = "basic-auth")]
71+
#[cfg_attr(docsrs, doc(cfg(feature = "basic-auth")))]
6872
pub basic_auth: String,
6973
/// Log remote address feature.
7074
pub log_remote_address: bool,

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,15 @@ pub mod server;
138138
pub mod service;
139139
pub mod settings;
140140
#[cfg(any(unix, windows))]
141+
#[cfg_attr(docsrs, doc(cfg(any(unix, windows))))]
141142
pub mod signals;
142143
pub mod static_files;
143144
#[cfg(feature = "http2")]
144145
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
145146
pub mod tls;
146147
pub mod transport;
147148
#[cfg(windows)]
149+
#[cfg_attr(docsrs, doc(cfg(windows)))]
148150
pub mod winservice;
149151
#[macro_use]
150152
pub mod error;

src/settings/file.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,25 +135,32 @@ pub struct General {
135135

136136
/// HTTP/2 + TLS.
137137
#[cfg(feature = "http2")]
138+
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
138139
pub http2: Option<bool>,
139140
/// Http2 tls certificate feature.
140141
#[cfg(feature = "http2")]
142+
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
141143
pub http2_tls_cert: Option<PathBuf>,
142144
/// Http2 tls key feature.
143145
#[cfg(feature = "http2")]
146+
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
144147
pub http2_tls_key: Option<PathBuf>,
145148

146149
/// Redirect all HTTP requests to HTTPS.
147150
#[cfg(feature = "http2")]
151+
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
148152
pub https_redirect: Option<bool>,
149153
/// HTTP host port where the redirect server will listen for requests to redirect them to HTTPS.
150154
#[cfg(feature = "http2")]
155+
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
151156
pub https_redirect_host: Option<String>,
152157
/// Host port for redirecting HTTP requests to HTTPS.
153158
#[cfg(feature = "http2")]
159+
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
154160
pub https_redirect_from_port: Option<u16>,
155161
/// List of host names or IPs allowed to redirect from.
156162
#[cfg(feature = "http2")]
163+
#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
157164
pub https_redirect_from_hosts: Option<String>,
158165

159166
/// Security headers.
@@ -168,15 +175,20 @@ pub struct General {
168175

169176
/// Directory listing feature.
170177
#[cfg(feature = "directory-listing")]
178+
#[cfg_attr(docsrs, doc(cfg(feature = "directory-listing")))]
171179
pub directory_listing: Option<bool>,
172180
/// Directory listing order feature.
173181
#[cfg(feature = "directory-listing")]
182+
#[cfg_attr(docsrs, doc(cfg(feature = "directory-listing")))]
174183
pub directory_listing_order: Option<u8>,
175184
/// Directory listing format feature.
176185
#[cfg(feature = "directory-listing")]
186+
#[cfg_attr(docsrs, doc(cfg(feature = "directory-listing")))]
177187
pub directory_listing_format: Option<DirListFmt>,
178188

179189
/// Basich Authentication feature.
190+
#[cfg(feature = "basic-auth")]
191+
#[cfg_attr(docsrs, doc(cfg(feature = "basic-auth")))]
180192
pub basic_auth: Option<String>,
181193

182194
/// File descriptor binding feature.

src/signals.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use {
1818
use {std::sync::Arc, tokio::sync::watch::Receiver, tokio::sync::Mutex};
1919

2020
#[cfg(unix)]
21+
#[cfg_attr(docsrs, doc(cfg(unix)))]
2122
/// It creates a common list of signals stream for `SIGTERM`, `SIGINT` and `SIGQUIT` to be observed.
2223
pub fn create_signals() -> Result<Signals> {
2324
Ok(Signals::new([SIGHUP, SIGTERM, SIGINT, SIGQUIT])?)
@@ -58,6 +59,7 @@ async fn delay_graceful_shutdown(grace_period_secs: u8) {
5859
}
5960

6061
#[cfg(windows)]
62+
#[cfg_attr(docsrs, doc(cfg(windows)))]
6163
/// It waits for an incoming `ctrl+c` signal on Windows.
6264
pub async fn wait_for_ctrl_c(cancel_recv: Arc<Mutex<Option<Receiver<()>>>>, grace_period_secs: u8) {
6365
if let Some(receiver) = &mut *cancel_recv.lock().await {

src/static_files.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,15 @@ pub struct HandleOpts<'a> {
5050
pub uri_query: Option<&'a str>,
5151
/// Directory listing feature.
5252
#[cfg(feature = "directory-listing")]
53+
#[cfg_attr(docsrs, doc(cfg(feature = "directory-listing")))]
5354
pub dir_listing: bool,
5455
/// Directory listing order feature.
5556
#[cfg(feature = "directory-listing")]
57+
#[cfg_attr(docsrs, doc(cfg(feature = "directory-listing")))]
5658
pub dir_listing_order: u8,
5759
/// Directory listing format feature.
5860
#[cfg(feature = "directory-listing")]
61+
#[cfg_attr(docsrs, doc(cfg(feature = "directory-listing")))]
5962
pub dir_listing_format: &'a DirListFmt,
6063
/// Redirect trailing slash feature.
6164
pub redirect_trailing_slash: bool,

0 commit comments

Comments
 (0)