Skip to content

Commit a029296

Browse files
committed
New feature rustdoc_use_unstable to use unstable rustdoc features
Generate documentation about supported platforms automatically if the feature is enabled. Don't pass `--cfg docsrs` to rustdoc for docs.rs builds, it's already passed.
1 parent 0ae0c3a commit a029296

File tree

6 files changed

+4
-569
lines changed

6 files changed

+4
-569
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ include = [
2929

3030
[package.metadata.docs.rs]
3131
all-features = true
32-
rustdoc-args = ["--cfg", "docsrs"]
3332
targets = ["aarch64-apple-ios", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-unknown-fuchsia", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-freebsd", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-linux-musl", "x86_64-unknown-netbsd", "x86_64-unknown-redox", "armv7-linux-androideabi", "i686-linux-android"]
3433

3534
[package.metadata.playground]
@@ -51,3 +50,5 @@ features = [
5150
[features]
5251
# Enable all API, even ones not available on all OSs.
5352
all = []
53+
# Use unstable Rust features for better documentation.
54+
rustdoc_use_unstable = []

src/lib.rs

Lines changed: 2 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@
5151
//! that are not available on all OSs.
5252
5353
#![deny(missing_docs, missing_debug_implementations, rust_2018_idioms)]
54-
// Show required OS/features on docs.rs.
55-
#![cfg_attr(docsrs, feature(doc_cfg))]
54+
// Automatically generate required OS/features in documentation
55+
#![cfg_attr(feature = "rustdoc_use_unstable", feature(doc_auto_cfg))]
5656
// Disallow warnings when running tests.
5757
#![cfg_attr(test, deny(warnings))]
5858
// Disallow warnings in examples.
@@ -266,20 +266,14 @@ impl Type {
266266
///
267267
/// Used for the DCCP protocol.
268268
#[cfg(all(feature = "all", target_os = "linux"))]
269-
#[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))]
270269
pub const DCCP: Type = Type(sys::SOCK_DCCP);
271270

272271
/// Type corresponding to `SOCK_SEQPACKET`.
273272
#[cfg(all(feature = "all", not(target_os = "espidf")))]
274-
#[cfg_attr(docsrs, doc(cfg(all(feature = "all", not(target_os = "espidf")))))]
275273
pub const SEQPACKET: Type = Type(sys::SOCK_SEQPACKET);
276274

277275
/// Type corresponding to `SOCK_RAW`.
278276
#[cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf"))))]
279-
#[cfg_attr(
280-
docsrs,
281-
doc(cfg(all(feature = "all", not(any(target_os = "redox", target_os = "espidf")))))
282-
)]
283277
pub const RAW: Type = Type(sys::SOCK_RAW);
284278
}
285279

@@ -324,7 +318,6 @@ impl Protocol {
324318

325319
/// Protocol corresponding to `DCCP`.
326320
#[cfg(all(feature = "all", target_os = "linux"))]
327-
#[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))]
328321
pub const DCCP: Protocol = Protocol(sys::IPPROTO_DCCP);
329322

330323
/// Protocol corresponding to `SCTP`.
@@ -364,7 +357,6 @@ impl From<Protocol> for c_int {
364357
///
365358
/// Flags provide additional information about incoming messages.
366359
#[cfg(not(target_os = "redox"))]
367-
#[cfg_attr(docsrs, doc(cfg(not(target_os = "redox"))))]
368360
#[derive(Copy, Clone, Eq, PartialEq)]
369361
pub struct RecvFlags(c_int);
370362

@@ -523,24 +515,6 @@ impl TcpKeepalive {
523515
target_os = "watchos",
524516
target_os = "windows",
525517
))]
526-
#[cfg_attr(
527-
docsrs,
528-
doc(cfg(any(
529-
target_os = "android",
530-
target_os = "dragonfly",
531-
target_os = "freebsd",
532-
target_os = "fuchsia",
533-
target_os = "illumos",
534-
target_os = "ios",
535-
target_os = "visionos",
536-
target_os = "linux",
537-
target_os = "macos",
538-
target_os = "netbsd",
539-
target_os = "tvos",
540-
target_os = "watchos",
541-
target_os = "windows",
542-
)))
543-
)]
544518
pub const fn with_interval(self, interval: Duration) -> Self {
545519
Self {
546520
interval: Some(interval),
@@ -569,26 +543,6 @@ impl TcpKeepalive {
569543
target_os = "watchos",
570544
)
571545
))]
572-
#[cfg_attr(
573-
docsrs,
574-
doc(cfg(all(
575-
feature = "all",
576-
any(
577-
target_os = "android",
578-
target_os = "dragonfly",
579-
target_os = "freebsd",
580-
target_os = "fuchsia",
581-
target_os = "illumos",
582-
target_os = "ios",
583-
target_os = "visionos",
584-
target_os = "linux",
585-
target_os = "macos",
586-
target_os = "netbsd",
587-
target_os = "tvos",
588-
target_os = "watchos",
589-
)
590-
)))
591-
)]
592546
pub const fn with_retries(self, retries: u32) -> Self {
593547
Self {
594548
retries: Some(retries),

0 commit comments

Comments
 (0)