Skip to content

Commit b2588ec

Browse files
committed
Use auto_doc_cfg
This makes it so one doesn't need to manually configure the documentation cfg for feature flags. rust-lang/rust#90502 Fixes pola-rs#6123
1 parent 45ad9e3 commit b2588ec

File tree

47 files changed

+10
-170
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+10
-170
lines changed

.github/workflows/docs-deploy.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838

3939
- name: Build Rust documentation
4040
env:
41-
RUSTFLAGS: --cfg docsrs
41+
RUSTDOCFLAGS: --cfg docsrs
4242
run: cargo doc --features=docs-selection --package polars
4343

4444
- name: Prepare deployment

polars/polars-algo/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg_attr(docsrs, feature(doc_cfg))]
1+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
22
mod algo;
33
pub use algo::*;
44
pub mod prelude;

polars/polars-core/src/chunked_array/mod.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,15 @@ mod from;
3030
pub(crate) mod list;
3131
pub(crate) mod logical;
3232
#[cfg(feature = "object")]
33-
#[cfg_attr(docsrs, doc(cfg(feature = "object")))]
3433
pub mod object;
3534
#[cfg(feature = "random")]
36-
#[cfg_attr(docsrs, doc(cfg(feature = "random")))]
3735
mod random;
3836
pub mod strings;
3937
#[cfg(any(
4038
feature = "temporal",
4139
feature = "dtype-datetime",
4240
feature = "dtype-date"
4341
))]
44-
#[cfg_attr(docsrs, doc(cfg(feature = "temporal")))]
4542
pub mod temporal;
4643
mod trusted_len;
4744
pub mod upstream_traits;

polars/polars-core/src/chunked_array/ndarray.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ where
99
{
1010
/// If data is aligned in a single chunk and has no Null values a zero copy view is returned
1111
/// as an `ndarray`
12-
#[cfg_attr(docsrs, doc(cfg(feature = "ndarray")))]
1312
pub fn to_ndarray(&self) -> PolarsResult<ArrayView1<T::Native>> {
1413
let slice = self.cont_slice()?;
1514
Ok(aview1(slice))
@@ -18,7 +17,6 @@ where
1817

1918
impl ListChunked {
2019
/// If all nested `Series` have the same length, a 2 dimensional `ndarray::Array` is returned.
21-
#[cfg_attr(docsrs, doc(cfg(feature = "ndarray")))]
2220
pub fn to_ndarray<N>(&self) -> PolarsResult<Array2<N::Native>>
2321
where
2422
N: PolarsNumericType,
@@ -96,7 +94,6 @@ impl DataFrame {
9694
/// [2.0, 8.0],
9795
/// [3.0, 6.0]], shape=[3, 2], strides=[2, 1], layout=C (0x1), const ndim=2/
9896
/// ```
99-
#[cfg_attr(docsrs, doc(cfg(feature = "ndarray")))]
10097
pub fn to_ndarray<N>(&self) -> PolarsResult<Array2<N::Native>>
10198
where
10299
N: PolarsNumericType,

polars/polars-core/src/chunked_array/ops/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,6 @@ pub trait ChunkUnique<T: PolarsDataType> {
476476

477477
/// The most occurring value(s). Can return multiple Values
478478
#[cfg(feature = "mode")]
479-
#[cfg_attr(docsrs, doc(cfg(feature = "mode")))]
480479
fn mode(&self) -> PolarsResult<ChunkedArray<T>> {
481480
Err(PolarsError::InvalidOperation(
482481
"mode is not implemented for this dtype".into(),
@@ -728,7 +727,6 @@ pub trait ChunkPeaks {
728727

729728
/// Check if element is member of list array
730729
#[cfg(feature = "is_in")]
731-
#[cfg_attr(docsrs, doc(cfg(feature = "is_in")))]
732730
pub trait IsIn {
733731
/// Check if elements of this array are in the right Series, or List values of the right Series.
734732
fn is_in(&self, _other: &Series) -> PolarsResult<BooleanChunked> {
@@ -750,7 +748,6 @@ pub trait ArgAgg {
750748

751749
/// Repeat the values `n` times.
752750
#[cfg(feature = "repeat_by")]
753-
#[cfg_attr(docsrs, doc(cfg(feature = "repeat_by")))]
754751
pub trait RepeatBy {
755752
/// Repeat the values `n` times, where `n` is determined by the values in `by`.
756753
fn repeat_by(&self, _by: &IdxCa) -> ListChunked {
@@ -759,7 +756,6 @@ pub trait RepeatBy {
759756
}
760757

761758
#[cfg(feature = "is_first")]
762-
#[cfg_attr(docsrs, doc(cfg(feature = "is_first")))]
763759
/// Mask the first unique values as `true`
764760
pub trait IsFirst<T: PolarsDataType> {
765761
fn is_first(&self) -> PolarsResult<BooleanChunked> {
@@ -770,7 +766,6 @@ pub trait IsFirst<T: PolarsDataType> {
770766
}
771767

772768
#[cfg(feature = "is_first")]
773-
#[cfg_attr(docsrs, doc(cfg(feature = "is_first")))]
774769
/// Mask the last unique values as `true`
775770
pub trait IsLast<T: PolarsDataType> {
776771
fn is_last(&self) -> PolarsResult<BooleanChunked> {
@@ -781,7 +776,6 @@ pub trait IsLast<T: PolarsDataType> {
781776
}
782777

783778
#[cfg(feature = "concat_str")]
784-
#[cfg_attr(docsrs, doc(cfg(feature = "concat_str")))]
785779
/// Concat the values into a string array.
786780
pub trait StrConcat {
787781
/// Concat the values into a string array.

polars/polars-core/src/datatypes/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,11 @@ impl PolarsDataType for ListType {
119119
}
120120

121121
#[cfg(feature = "object")]
122-
#[cfg_attr(docsrs, doc(cfg(feature = "object")))]
123122
pub struct ObjectType<T>(T);
124123
#[cfg(feature = "object")]
125124
pub type ObjectChunked<T> = ChunkedArray<ObjectType<T>>;
126125

127126
#[cfg(feature = "object")]
128-
#[cfg_attr(docsrs, doc(cfg(feature = "object")))]
129127
impl<T: PolarsObject> PolarsDataType for ObjectType<T> {
130128
fn get_dtype() -> DataType {
131129
DataType::Object(T::type_name())

polars/polars-core/src/frame/asof_join/groups.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,6 @@ fn dispatch_join<T: PolarsNumericType>(
619619
}
620620

621621
impl DataFrame {
622-
#[cfg_attr(docsrs, doc(cfg(feature = "asof_join")))]
623622
#[allow(clippy::too_many_arguments)]
624623
#[doc(hidden)]
625624
pub fn _join_asof_by(
@@ -704,7 +703,6 @@ impl DataFrame {
704703
/// This is similar to a left-join except that we match on nearest key rather than equal keys.
705704
/// The keys must be sorted to perform an asof join. This is a special implementation of an asof join
706705
/// that searches for the nearest keys within a subgroup set by `by`.
707-
#[cfg_attr(docsrs, doc(cfg(feature = "asof_join")))]
708706
#[allow(clippy::too_many_arguments)]
709707
pub fn join_asof_by<I, S>(
710708
&self,

polars/polars-core/src/frame/asof_join/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,6 @@ impl DataFrame {
196196

197197
/// This is similar to a left-join except that we match on nearest key rather than equal keys.
198198
/// The keys must be sorted to perform an asof join
199-
#[cfg_attr(docsrs, doc(cfg(feature = "asof_join")))]
200199
pub fn join_asof(
201200
&self,
202201
other: &DataFrame,

polars/polars-core/src/frame/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2778,7 +2778,6 @@ impl DataFrame {
27782778

27792779
/// Aggregate the column horizontally to their min values.
27802780
#[cfg(feature = "zip_with")]
2781-
#[cfg_attr(docsrs, doc(cfg(feature = "zip_with")))]
27822781
pub fn hmin(&self) -> PolarsResult<Option<Series>> {
27832782
let min_fn = |acc: &Series, s: &Series| {
27842783
let mask = acc.lt(s)? & acc.is_not_null() | s.is_null();
@@ -2808,7 +2807,6 @@ impl DataFrame {
28082807

28092808
/// Aggregate the column horizontally to their max values.
28102809
#[cfg(feature = "zip_with")]
2811-
#[cfg_attr(docsrs, doc(cfg(feature = "zip_with")))]
28122810
pub fn hmax(&self) -> PolarsResult<Option<Series>> {
28132811
let max_fn = |acc: &Series, s: &Series| {
28142812
let mask = acc.gt(s)? & acc.is_not_null() | s.is_null();
@@ -3305,7 +3303,6 @@ impl DataFrame {
33053303

33063304
/// Split into multiple DataFrames partitioned by groups
33073305
#[cfg(feature = "partition_by")]
3308-
#[cfg_attr(docsrs, doc(cfg(feature = "partition_by")))]
33093306
pub fn partition_by(&self, cols: impl IntoVec<String>) -> PolarsResult<Vec<DataFrame>> {
33103307
let cols = cols.into_vec();
33113308
self._partition_by_impl(&cols, false)
@@ -3314,7 +3311,6 @@ impl DataFrame {
33143311
/// Split into multiple DataFrames partitioned by groups
33153312
/// Order of the groups are maintained.
33163313
#[cfg(feature = "partition_by")]
3317-
#[cfg_attr(docsrs, doc(cfg(feature = "partition_by")))]
33183314
pub fn partition_by_stable(&self, cols: impl IntoVec<String>) -> PolarsResult<Vec<DataFrame>> {
33193315
let cols = cols.into_vec();
33203316
self._partition_by_impl(&cols, true)
@@ -3323,7 +3319,6 @@ impl DataFrame {
33233319
/// Unnest the given `Struct` columns. This means that the fields of the `Struct` type will be
33243320
/// inserted as columns.
33253321
#[cfg(feature = "dtype-struct")]
3326-
#[cfg_attr(docsrs, doc(cfg(feature = "dtype-struct")))]
33273322
pub fn unnest<I: IntoVec<String>>(&self, cols: I) -> PolarsResult<DataFrame> {
33283323
let cols = cols.into_vec();
33293324
self.unnest_impl(cols.into_iter().collect())

polars/polars-core/src/frame/row.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ impl<'a> Row<'a> {
1818

1919
impl DataFrame {
2020
/// Get a row from a DataFrame. Use of this is discouraged as it will likely be slow.
21-
#[cfg_attr(docsrs, doc(cfg(feature = "rows")))]
2221
pub fn get_row(&self, idx: usize) -> PolarsResult<Row> {
2322
let values = self
2423
.columns
@@ -31,7 +30,6 @@ impl DataFrame {
3130
/// Amortize allocations by reusing a row.
3231
/// The caller is responsible to make sure that the row has at least the capacity for the number
3332
/// of columns in the DataFrame
34-
#[cfg_attr(docsrs, doc(cfg(feature = "rows")))]
3533
pub fn get_row_amortized<'a>(&'a self, idx: usize, row: &mut Row<'a>) -> PolarsResult<()> {
3634
for (s, any_val) in self.columns.iter().zip(&mut row.0) {
3735
*any_val = s.get(idx)?;
@@ -46,7 +44,6 @@ impl DataFrame {
4644
/// # Safety
4745
/// Does not do any bounds checking.
4846
#[inline]
49-
#[cfg_attr(docsrs, doc(cfg(feature = "rows")))]
5047
pub unsafe fn get_row_amortized_unchecked<'a>(&'a self, idx: usize, row: &mut Row<'a>) {
5148
self.columns
5249
.iter()
@@ -58,14 +55,12 @@ impl DataFrame {
5855

5956
/// Create a new DataFrame from rows. This should only be used when you have row wise data,
6057
/// as this is a lot slower than creating the `Series` in a columnar fashion
61-
#[cfg_attr(docsrs, doc(cfg(feature = "rows")))]
6258
pub fn from_rows_and_schema(rows: &[Row], schema: &Schema) -> PolarsResult<Self> {
6359
Self::from_rows_iter_and_schema(rows.iter(), schema)
6460
}
6561

6662
/// Create a new DataFrame from an iterator over rows. This should only be used when you have row wise data,
6763
/// as this is a lot slower than creating the `Series` in a columnar fashion
68-
#[cfg_attr(docsrs, doc(cfg(feature = "rows")))]
6964
pub fn from_rows_iter_and_schema<'a, I>(mut rows: I, schema: &Schema) -> PolarsResult<Self>
7065
where
7166
I: Iterator<Item = &'a Row<'a>>,
@@ -108,7 +103,6 @@ impl DataFrame {
108103

109104
/// Create a new DataFrame from rows. This should only be used when you have row wise data,
110105
/// as this is a lot slower than creating the `Series` in a columnar fashion
111-
#[cfg_attr(docsrs, doc(cfg(feature = "rows")))]
112106
pub fn from_rows(rows: &[Row]) -> PolarsResult<Self> {
113107
let schema = rows_to_schema_first_non_null(rows, Some(50));
114108
let has_nulls = schema
@@ -177,7 +171,6 @@ impl DataFrame {
177171
}
178172
}
179173

180-
#[cfg_attr(docsrs, doc(cfg(feature = "rows")))]
181174
/// Transpose a DataFrame. This is a very expensive operation.
182175
pub fn transpose(&self) -> PolarsResult<DataFrame> {
183176
let height = self.height();

polars/polars-core/src/functions.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ impl<'a> IterBroadCast<'a> {
136136
/// The concatenated strings are separated by a `delimiter`.
137137
/// If no `delimiter` is needed, an empty &str should be passed as argument.
138138
#[cfg(feature = "concat_str")]
139-
#[cfg_attr(docsrs, doc(cfg(feature = "concat_str")))]
140139
pub fn concat_str(s: &[Series], delimiter: &str) -> PolarsResult<Utf8Chunked> {
141140
if s.is_empty() {
142141
return Err(PolarsError::NoData(
@@ -212,7 +211,6 @@ pub fn concat_str(s: &[Series], delimiter: &str) -> PolarsResult<Utf8Chunked> {
212211

213212
/// Concat `[DataFrame]`s horizontally.
214213
#[cfg(feature = "horizontal_concat")]
215-
#[cfg_attr(docsrs, doc(cfg(feature = "horizontal_concat")))]
216214
/// Concat horizontally and extend with null values if lengths don't match
217215
pub fn hor_concat_df(dfs: &[DataFrame]) -> PolarsResult<DataFrame> {
218216
let max_len = dfs
@@ -253,7 +251,6 @@ pub fn hor_concat_df(dfs: &[DataFrame]) -> PolarsResult<DataFrame> {
253251

254252
/// Concat `[DataFrame]`s diagonally.
255253
#[cfg(feature = "diagonal_concat")]
256-
#[cfg_attr(docsrs, doc(cfg(feature = "diagonal_concat")))]
257254
/// Concat diagonally thereby combining different schemas.
258255
pub fn diag_concat_df(dfs: &[DataFrame]) -> PolarsResult<DataFrame> {
259256
// TODO! replace with lazy only?

polars/polars-core/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![cfg_attr(docsrs, feature(doc_cfg))]
1+
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
22
extern crate core;
33

44
#[macro_use]
@@ -17,7 +17,6 @@ mod named_from;
1717
pub mod prelude;
1818
pub mod schema;
1919
#[cfg(feature = "serde")]
20-
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
2120
pub mod serde;
2221
pub mod series;
2322
pub mod testing;

polars/polars-core/src/series/implementations/object.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ where
6363
.map(|ca| ca.into_series())
6464
}
6565
}
66-
#[cfg_attr(docsrs, doc(cfg(feature = "object")))]
6766
impl<T> SeriesTrait for SeriesWrap<ObjectChunked<T>>
6867
where
6968
T: PolarsObject,

polars/polars-core/src/series/mod.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ impl Series {
370370
/// Create a new ChunkedArray with values from self where the mask evaluates `true` and values
371371
/// from `other` where the mask evaluates `false`
372372
#[cfg(feature = "zip_with")]
373-
#[cfg_attr(docsrs, doc(cfg(feature = "zip_with")))]
374373
pub fn zip_with(&self, mask: &BooleanChunked, other: &Series) -> PolarsResult<Series> {
375374
let (lhs, rhs) = coerce_lhs_rhs(self, other)?;
376375
lhs.zip_with_same_type(mask, rhs.as_ref())
@@ -511,7 +510,6 @@ impl Series {
511510
}
512511

513512
#[cfg(feature = "dot_product")]
514-
#[cfg_attr(docsrs, doc(cfg(feature = "dot_product")))]
515513
pub fn dot(&self, other: &Series) -> Option<f64> {
516514
(self * other).sum::<f64>()
517515
}
@@ -536,7 +534,6 @@ impl Series {
536534
}
537535

538536
/// Get an array with the cumulative max computed at every element
539-
#[cfg_attr(docsrs, doc(cfg(feature = "cum_agg")))]
540537
pub fn cummax(&self, _reverse: bool) -> Series {
541538
#[cfg(feature = "cum_agg")]
542539
{
@@ -549,7 +546,6 @@ impl Series {
549546
}
550547

551548
/// Get an array with the cumulative min computed at every element
552-
#[cfg_attr(docsrs, doc(cfg(feature = "cum_agg")))]
553549
pub fn cummin(&self, _reverse: bool) -> Series {
554550
#[cfg(feature = "cum_agg")]
555551
{
@@ -565,7 +561,6 @@ impl Series {
565561
///
566562
/// If the [`DataType`] is one of `{Int8, UInt8, Int16, UInt16}` the `Series` is
567563
/// first cast to `Int64` to prevent overflow issues.
568-
#[cfg_attr(docsrs, doc(cfg(feature = "cum_agg")))]
569564
#[allow(unused_variables)]
570565
pub fn cumsum(&self, reverse: bool) -> Series {
571566
#[cfg(feature = "cum_agg")]
@@ -614,7 +609,6 @@ impl Series {
614609
///
615610
/// If the [`DataType`] is one of `{Int8, UInt8, Int16, UInt16, Int32, UInt32}` the `Series` is
616611
/// first cast to `Int64` to prevent overflow issues.
617-
#[cfg_attr(docsrs, doc(cfg(feature = "cum_agg")))]
618612
#[allow(unused_variables)]
619613
pub fn cumprod(&self, reverse: bool) -> Series {
620614
#[cfg(feature = "cum_agg")]
@@ -655,7 +649,6 @@ impl Series {
655649
///
656650
/// If the [`DataType`] is one of `{Int8, UInt8, Int16, UInt16}` the `Series` is
657651
/// first cast to `Int64` to prevent overflow issues.
658-
#[cfg_attr(docsrs, doc(cfg(feature = "product")))]
659652
pub fn product(&self) -> Series {
660653
#[cfg(feature = "product")]
661654
{
@@ -688,7 +681,6 @@ impl Series {
688681
}
689682

690683
#[cfg(feature = "rank")]
691-
#[cfg_attr(docsrs, doc(cfg(feature = "rank")))]
692684
pub fn rank(&self, options: RankOptions) -> Series {
693685
rank(self, options.method, options.descending)
694686
}
@@ -807,7 +799,6 @@ impl Series {
807799
}
808800

809801
#[cfg(feature = "abs")]
810-
#[cfg_attr(docsrs, doc(cfg(feature = "abs")))]
811802
/// convert numerical values to their absolute value
812803
pub fn abs(&self) -> PolarsResult<Series> {
813804
let a = self.to_physical_repr();

polars/polars-core/src/series/ops/diff.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use crate::prelude::*;
22
use crate::series::ops::NullBehavior;
33

44
impl Series {
5-
#[cfg_attr(docsrs, doc(cfg(feature = "diff")))]
65
pub fn diff(&self, n: usize, null_behavior: NullBehavior) -> Series {
76
use DataType::*;
87
let s = match self.dtype() {

polars/polars-core/src/series/ops/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
#[cfg(feature = "diff")]
2-
#[cfg_attr(docsrs, doc(cfg(feature = "diff")))]
32
pub mod diff;
43
mod downcast;
54
#[cfg(feature = "ewma")]
6-
#[cfg_attr(docsrs, doc(cfg(feature = "ewma")))]
75
mod ewm;
86
mod extend;
97
#[cfg(feature = "moment")]
10-
#[cfg_attr(docsrs, doc(cfg(feature = "moment")))]
118
pub mod moment;
129
mod null;
1310
#[cfg(feature = "pct_change")]
14-
#[cfg_attr(docsrs, doc(cfg(feature = "pct_change")))]
1511
pub mod pct_change;
1612
#[cfg(feature = "round_series")]
17-
#[cfg_attr(docsrs, doc(cfg(feature = "round_series")))]
1813
mod round;
1914
mod to_list;
2015
mod unique;

0 commit comments

Comments
 (0)