Skip to content

doc: display feture flags in docs.rs #338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ derive = ["tskit-derive", "serde", "serde_json", "bincode"]

[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "doc_cfg"]

# Not run during tests
[[example]]
Expand Down
3 changes: 2 additions & 1 deletion src/_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,8 @@ macro_rules! migration_table_add_row_with_metadata {
};
}

#[cfg(any(doc, feature = "provenance"))]
#[cfg(feature = "provenance")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "provenance")))]
macro_rules! provenance_table_add_row {
($(#[$attr:meta])* => $name: ident, $self: ident, $table: expr) => {
$(#[$attr])*
Expand Down
9 changes: 6 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
//! Some features are optional, and are activated by requesting them in your `Cargo.toml` file.
//!
//! * `provenance`
//! * Enables [`provenance`]
//! * Enables `provenance`
//! * `derive` enables the following derive macros:
//! * [`crate::metadata::MutationMetadata`]
//! * [`crate::metadata::IndividualMetadata`]
Expand Down Expand Up @@ -72,6 +72,7 @@
#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![cfg_attr(doc_cfg, feature(doc_cfg))]

#[allow(deref_nullptr)]
#[allow(rustdoc::broken_intra_doc_links)]
Expand Down Expand Up @@ -444,10 +445,12 @@ pub use tree_interface::{NodeTraversalOrder, TreeInterface};
pub use trees::{Tree, TreeSequence};

// Optional features
#[cfg(any(feature = "provenance", doc))]
#[cfg(feature = "provenance")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "provenance")))]
pub mod provenance;

#[cfg(any(feature = "provenance", doc))]
#[cfg(feature = "provenance")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "provenance")))]
/// A provenance ID
///
/// This is an integer referring to a row of a [``provenance::ProvenanceTable``].
Expand Down
4 changes: 3 additions & 1 deletion src/provenance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ build_owned_table_type!(
/// # Examples
///
/// ```rust
/// # #[cfg(any(doc, feature = "provenance"))] {
/// # #[cfg(feature = "provenance")]
/// # #[cfg_attr(doc_cfg, doc(cfg(feature = "provenance")))]
/// {
/// use tskit::provenance::OwnedProvenanceTable;
/// let mut provenances = OwnedProvenanceTable::default();
/// let id = provenances.add_row("message").unwrap();
Expand Down
9 changes: 6 additions & 3 deletions src/table_collection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,8 @@ impl TableCollection {
handle_tsk_return_value!(rv)
}

#[cfg(any(feature = "provenance", doc))]
#[cfg(feature = "provenance")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "provenance")))]
provenance_table_add_row!(
/// Add provenance record with a time stamp.
///
Expand Down Expand Up @@ -1159,7 +1160,8 @@ impl TableCollection {
handle_tsk_return_value!(rv)
}

#[cfg(any(doc, feature = "provenance"))]
#[cfg(feature = "provenance")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "provenance")))]
/// Set the provenance table from an
/// [`OwnedProvenanceTable`](`crate::provenance::OwnedProvenanceTable`)
///
Expand Down Expand Up @@ -1231,7 +1233,8 @@ impl TableAccess for TableCollection {
PopulationTable::new_from_table(&self.inner.populations)
}

#[cfg(any(feature = "provenance", doc))]
#[cfg(feature = "provenance")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "provenance")))]
fn provenances(&self) -> crate::provenance::ProvenanceTable {
crate::provenance::ProvenanceTable::new_from_table(&self.inner.provenances)
}
Expand Down
6 changes: 4 additions & 2 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,13 @@ pub trait TableAccess {
Box::new(make_table_iterator::<IndividualTable>(self.individuals()))
}

#[cfg(any(feature = "provenance", doc))]
#[cfg(feature = "provenance")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "provenance")))]
/// Get reference to the [``ProvenanceTable``](crate::provenance::ProvenanceTable)
fn provenances(&self) -> crate::provenance::ProvenanceTable;

#[cfg(any(feature = "provenance", doc))]
#[cfg(feature = "provenance")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "provenance")))]
/// Return an iterator over provenances
fn provenances_iter(
&self,
Expand Down
6 changes: 4 additions & 2 deletions src/trees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,8 @@ impl TreeSequence {
)
}

#[cfg(any(feature = "provenance", doc))]
#[cfg(feature = "provenance")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "provenance")))]
/// Add provenance record with a time stamp.
///
/// All implementation of this trait provided by `tskit` use
Expand Down Expand Up @@ -540,7 +541,8 @@ impl TableAccess for TreeSequence {
PopulationTable::new_from_table(unsafe { &(*self.inner.tables).populations })
}

#[cfg(any(feature = "provenance", doc))]
#[cfg(feature = "provenance")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "provenance")))]
fn provenances(&self) -> crate::provenance::ProvenanceTable {
crate::provenance::ProvenanceTable::new_from_table(unsafe {
&(*self.inner.tables).provenances
Expand Down