Skip to content

Commit ca0f987

Browse files
Publish docs for optional features on docs.rs (parcel-bundler#407)
1 parent ba77213 commit ca0f987

File tree

18 files changed

+60
-2
lines changed

18 files changed

+60
-2
lines changed

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ edition = "2021"
1616
keywords = [ "CSS", "minifier", "Parcel" ]
1717
repository = "https://github.com/parcel-bundler/lightningcss"
1818

19+
[package.metadata.docs.rs]
20+
all-features = true
21+
rustdoc-args = ["--cfg", "docsrs"]
22+
1923
[[bin]]
2024
name = "lightningcss"
2125
path = "src/main.rs"

src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
//! style sheet. See the individual module documentation for more details and examples.
1616

1717
#![deny(missing_docs)]
18+
#![cfg_attr(docsrs, feature(doc_cfg))]
1819

1920
#[cfg(feature = "bundler")]
21+
#[cfg_attr(docsrs, doc(cfg(feature = "bundler")))]
2022
pub mod bundler;
2123
mod compat;
2224
mod context;
@@ -39,6 +41,7 @@ pub mod traits;
3941
pub mod values;
4042
pub mod vendor_prefix;
4143
#[cfg(feature = "visitor")]
44+
#[cfg_attr(docsrs, doc(cfg(feature = "visitor")))]
4245
pub mod visitor;
4346

4447
#[cfg(feature = "serde")]
@@ -10181,7 +10184,7 @@ mod tests {
1018110184
@bottom-left-corner {
1018210185
content: "Foo";
1018310186
}
10184-
10187+
1018510188
@bottom-right-corner {
1018610189
content: "Bar";
1018710190
}
@@ -19670,7 +19673,7 @@ mod tests {
1967019673
color: green;
1967119674
& { color: blue; }
1967219675
color: red;
19673-
}
19676+
}
1967419677
"#,
1967519678
indoc! {r#"
1967619679
article {

src/media_query.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ impl<'i> Parse<'i> for MediaType<'i> {
208208
}
209209

210210
#[cfg(feature = "jsonschema")]
211+
#[cfg_attr(docsrs, doc(cfg(feature = "jsonschema")))]
211212
impl<'a> schemars::JsonSchema for MediaType<'a> {
212213
fn is_referenceable() -> bool {
213214
true

src/parser.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ impl crate::traits::ToCss for DefaultAtRule {
114114
}
115115

116116
#[cfg(feature = "visitor")]
117+
#[cfg_attr(docsrs, doc(cfg(feature = "visitor")))]
117118
impl<'i, V: Visitor<'i, DefaultAtRule>> Visit<'i, DefaultAtRule, V> for DefaultAtRule {
118119
const CHILD_TYPES: VisitTypes = VisitTypes::empty();
119120
fn visit_children(&mut self, _: &mut V) -> Result<(), V::Error> {

src/printer.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub struct PrinterOptions<'a> {
1717
pub minify: bool,
1818
/// An optional reference to a source map to write mappings into.
1919
#[cfg(feature = "sourcemap")]
20+
#[cfg_attr(docsrs, doc(cfg(feature = "sourcemap")))]
2021
pub source_map: Option<&'a mut SourceMap>,
2122
/// An optional project root path, used to generate relative paths for sources used in CSS module hashes.
2223
pub project_root: Option<&'a str>,
@@ -65,8 +66,10 @@ pub struct Printer<'a, 'b, 'c, W> {
6566
pub(crate) sources: Option<&'c Vec<String>>,
6667
dest: &'a mut W,
6768
#[cfg(feature = "sourcemap")]
69+
#[cfg_attr(docsrs, doc(cfg(feature = "sourcemap")))]
6870
pub(crate) source_map: Option<&'a mut SourceMap>,
6971
#[cfg(feature = "sourcemap")]
72+
#[cfg_attr(docsrs, doc(cfg(feature = "sourcemap")))]
7073
pub(crate) source_maps: Vec<Option<SourceMap>>,
7174
pub(crate) loc: Location,
7275
indent: u8,
@@ -216,6 +219,7 @@ impl<'a, 'b, 'c, W: std::fmt::Write + Sized> Printer<'a, 'b, 'c, W> {
216219

217220
/// Adds a mapping to the source map, if any.
218221
#[cfg(feature = "sourcemap")]
222+
#[cfg_attr(docsrs, doc(cfg(feature = "sourcemap")))]
219223
pub fn add_mapping(&mut self, loc: Location) {
220224
self.loc = loc;
221225

src/properties/custom.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ impl<'i> ToCss for CustomPropertyName<'i> {
111111
}
112112

113113
#[cfg(feature = "serde")]
114+
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
114115
impl<'i, 'de: 'i> serde::Deserialize<'de> for CustomPropertyName<'i> {
115116
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
116117
where
@@ -177,6 +178,7 @@ impl<'i> UnparsedProperty<'i> {
177178

178179
/// Substitutes variables and re-parses the property.
179180
#[cfg(feature = "substitute_variables")]
181+
#[cfg_attr(docsrs, doc(cfg(feature = "substitute_variables")))]
180182
pub fn substitute_variables<'x>(
181183
mut self,
182184
vars: &std::collections::HashMap<&str, TokenList<'i>>,
@@ -994,6 +996,7 @@ impl<'i> TokenList<'i> {
994996

995997
/// Substitutes variables with the provided values.
996998
#[cfg(feature = "substitute_variables")]
999+
#[cfg_attr(docsrs, doc(cfg(feature = "substitute_variables")))]
9971000
pub fn substitute_variables(&mut self, vars: &std::collections::HashMap<&str, TokenList<'i>>) {
9981001
self.visit(&mut VarInliner { vars }).unwrap()
9991002
}

src/properties/grid.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,6 +1043,7 @@ enum AutoFlowDirection {
10431043
}
10441044

10451045
#[cfg(feature = "jsonschema")]
1046+
#[cfg_attr(docsrs, doc(cfg(feature = "jsonschema")))]
10461047
impl<'a> schemars::JsonSchema for GridAutoFlow {
10471048
fn is_referenceable() -> bool {
10481049
true

src/properties/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,7 @@ macro_rules! define_properties {
498498
}
499499

500500
#[cfg(feature = "serde")]
501+
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
501502
impl<'i> serde::Serialize for PropertyId<'i> {
502503
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
503504
where
@@ -522,6 +523,7 @@ macro_rules! define_properties {
522523
}
523524

524525
#[cfg(feature = "serde")]
526+
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
525527
impl<'i, 'de: 'i> serde::Deserialize<'de> for PropertyId<'i> {
526528
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
527529
where
@@ -572,6 +574,7 @@ macro_rules! define_properties {
572574
}
573575

574576
#[cfg(feature = "jsonschema")]
577+
#[cfg_attr(docsrs, doc(cfg(feature = "jsonschema")))]
575578
impl<'i> schemars::JsonSchema for PropertyId<'i> {
576579
fn is_referenceable() -> bool {
577580
true
@@ -896,6 +899,7 @@ macro_rules! define_properties {
896899
}
897900

898901
#[cfg(feature = "serde")]
902+
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
899903
impl<'i> serde::Serialize for Property<'i> {
900904
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
901905
where
@@ -950,6 +954,7 @@ macro_rules! define_properties {
950954
}
951955

952956
#[cfg(feature = "serde")]
957+
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
953958
impl<'i, 'de: 'i> serde::Deserialize<'de> for Property<'i> {
954959
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
955960
where
@@ -1053,6 +1058,7 @@ macro_rules! define_properties {
10531058
}
10541059

10551060
#[cfg(feature = "jsonschema")]
1061+
#[cfg_attr(docsrs, doc(cfg(feature = "jsonschema")))]
10561062
impl<'i> schemars::JsonSchema for Property<'i> {
10571063
fn is_referenceable() -> bool {
10581064
true
@@ -1322,34 +1328,49 @@ define_properties! {
13221328
"flex-preferred-size": FlexPreferredSize(LengthPercentageOrAuto, VendorPrefix) / Ms unprefixed: false,
13231329

13241330
#[cfg(feature = "grid")]
1331+
#[cfg_attr(docsrs, doc(cfg(feature = "grid")))]
13251332
"grid-template-columns": GridTemplateColumns(TrackSizing<'i>),
13261333
#[cfg(feature = "grid")]
1334+
#[cfg_attr(docsrs, doc(cfg(feature = "grid")))]
13271335
"grid-template-rows": GridTemplateRows(TrackSizing<'i>),
13281336
#[cfg(feature = "grid")]
1337+
#[cfg_attr(docsrs, doc(cfg(feature = "grid")))]
13291338
"grid-auto-columns": GridAutoColumns(TrackSizeList),
13301339
#[cfg(feature = "grid")]
1340+
#[cfg_attr(docsrs, doc(cfg(feature = "grid")))]
13311341
"grid-auto-rows": GridAutoRows(TrackSizeList),
13321342
#[cfg(feature = "grid")]
1343+
#[cfg_attr(docsrs, doc(cfg(feature = "grid")))]
13331344
"grid-auto-flow": GridAutoFlow(GridAutoFlow),
13341345
#[cfg(feature = "grid")]
1346+
#[cfg_attr(docsrs, doc(cfg(feature = "grid")))]
13351347
"grid-template-areas": GridTemplateAreas(GridTemplateAreas),
13361348
#[cfg(feature = "grid")]
1349+
#[cfg_attr(docsrs, doc(cfg(feature = "grid")))]
13371350
"grid-template": GridTemplate(GridTemplate<'i>) shorthand: true,
13381351
#[cfg(feature = "grid")]
1352+
#[cfg_attr(docsrs, doc(cfg(feature = "grid")))]
13391353
"grid": Grid(Grid<'i>) shorthand: true,
13401354
#[cfg(feature = "grid")]
1355+
#[cfg_attr(docsrs, doc(cfg(feature = "grid")))]
13411356
"grid-row-start": GridRowStart(GridLine<'i>),
13421357
#[cfg(feature = "grid")]
1358+
#[cfg_attr(docsrs, doc(cfg(feature = "grid")))]
13431359
"grid-row-end": GridRowEnd(GridLine<'i>),
13441360
#[cfg(feature = "grid")]
1361+
#[cfg_attr(docsrs, doc(cfg(feature = "grid")))]
13451362
"grid-column-start": GridColumnStart(GridLine<'i>),
13461363
#[cfg(feature = "grid")]
1364+
#[cfg_attr(docsrs, doc(cfg(feature = "grid")))]
13471365
"grid-column-end": GridColumnEnd(GridLine<'i>),
13481366
#[cfg(feature = "grid")]
1367+
#[cfg_attr(docsrs, doc(cfg(feature = "grid")))]
13491368
"grid-row": GridRow(GridRow<'i>) shorthand: true,
13501369
#[cfg(feature = "grid")]
1370+
#[cfg_attr(docsrs, doc(cfg(feature = "grid")))]
13511371
"grid-column": GridColumn(GridColumn<'i>) shorthand: true,
13521372
#[cfg(feature = "grid")]
1373+
#[cfg_attr(docsrs, doc(cfg(feature = "grid")))]
13531374
"grid-area": GridArea(GridArea<'i>) shorthand: true,
13541375

13551376
"margin-top": MarginTop(LengthPercentageOrAuto) [logical_group: Margin, category: Physical],

src/properties/text.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ impl From<SerializedTextTransformOther> for TextTransformOther {
131131
}
132132

133133
#[cfg(feature = "jsonschema")]
134+
#[cfg_attr(docsrs, doc(cfg(feature = "jsonschema")))]
134135
impl<'a> schemars::JsonSchema for TextTransformOther {
135136
fn is_referenceable() -> bool {
136137
true
@@ -655,6 +656,7 @@ impl From<SerializedTextDecorationLine> for TextDecorationLine {
655656
}
656657

657658
#[cfg(feature = "jsonschema")]
659+
#[cfg_attr(docsrs, doc(cfg(feature = "jsonschema")))]
658660
impl<'a> schemars::JsonSchema for TextDecorationLine {
659661
fn is_referenceable() -> bool {
660662
true

src/properties/ui.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ impl<'i> ToCss for Appearance<'i> {
378378
}
379379

380380
#[cfg(feature = "serde")]
381+
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
381382
impl<'i> serde::Serialize for Appearance<'i> {
382383
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
383384
where
@@ -388,6 +389,7 @@ impl<'i> serde::Serialize for Appearance<'i> {
388389
}
389390

390391
#[cfg(feature = "serde")]
392+
#[cfg_attr(docsrs, doc(cfg(feature = "serde")))]
391393
impl<'i, 'de: 'i> serde::Deserialize<'de> for Appearance<'i> {
392394
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
393395
where
@@ -399,6 +401,7 @@ impl<'i, 'de: 'i> serde::Deserialize<'de> for Appearance<'i> {
399401
}
400402

401403
#[cfg(feature = "jsonschema")]
404+
#[cfg_attr(docsrs, doc(cfg(feature = "jsonschema")))]
402405
impl<'a> schemars::JsonSchema for Appearance<'a> {
403406
fn is_referenceable() -> bool {
404407
true

0 commit comments

Comments
 (0)