Skip to content

Commit 882103e

Browse files
committed
More rust docs
1 parent c45c229 commit 882103e

File tree

13 files changed

+574
-91
lines changed

13 files changed

+574
-91
lines changed

src/macros.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,23 @@ pub(crate) use enum_property;
117117

118118
macro_rules! shorthand_property {
119119
(
120-
$name: ident$(<$l: lifetime>)?
121-
{ $first_key: ident: $first_type: ty, $( $key: ident: $type: ty, )* }
120+
$(#[$outer:meta])*
121+
$vis:vis struct $name: ident$(<$l: lifetime>)? {
122+
$(#[$first_meta: meta])*
123+
$first_key: ident: $first_type: ty,
124+
$(
125+
$(#[$meta: meta])*
126+
$key: ident: $type: ty,
127+
)*
128+
}
122129
) => {
130+
$(#[$outer])*
123131
#[derive(Debug, Clone, PartialEq)]
124132
pub struct $name$(<$l>)? {
133+
$(#[$first_meta])*
125134
pub $first_key: $first_type,
126135
$(
136+
$(#[$meta])*
127137
pub $key: $type,
128138
)*
129139
}

src/properties/css_modules.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Properties related to CSS modules.
2+
13
use crate::error::{ParserError, PrinterError};
24
use crate::printer::Printer;
35
use crate::traits::{Parse, ToCss};
@@ -6,18 +8,25 @@ use crate::values::string::CowArcStr;
68
use cssparser::*;
79
use smallvec::SmallVec;
810

9-
/// The `composes` property from CSS modules.
10-
/// https://github.com/css-modules/css-modules/#dependencies
11+
/// A value for the [composes](https://github.com/css-modules/css-modules/#dependencies) property from CSS modules.
1112
#[derive(Debug, Clone, PartialEq)]
1213
pub struct Composes<'i> {
14+
/// A list of class names to compose.
1315
pub names: CustomIdentList<'i>,
16+
/// Where the class names are composed from.
1417
pub from: Option<ComposesFrom<'i>>,
18+
/// The source location of the `composes` property.
1519
pub loc: SourceLocation,
1620
}
1721

22+
/// Defines where the class names referenced in the `composes` property are located.
23+
///
24+
/// See [Composes](Composes).
1825
#[derive(Debug, Clone, PartialEq)]
1926
pub enum ComposesFrom<'i> {
27+
/// The class name is global.
2028
Global,
29+
/// The class name comes from the specified file.
2130
File(CowArcStr<'i>),
2231
}
2332

src/properties/display.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! CSS properties related to display.
2+
13
use super::custom::UnparsedProperty;
24
use super::{Property, PropertyId};
35
use crate::context::PropertyHandlerContext;
@@ -12,13 +14,15 @@ use crate::vendor_prefix::VendorPrefix;
1214
use cssparser::*;
1315

1416
enum_property! {
17+
/// A [`<display-outside>`](https://drafts.csswg.org/css-display-3/#typedef-display-outside) value.
1518
pub enum DisplayOutside {
1619
"block": Block,
1720
"inline": Inline,
1821
"run-in": RunIn,
1922
}
2023
}
2124

25+
/// A [`<display-inside>`](https://drafts.csswg.org/css-display-3/#typedef-display-inside) value.
2226
#[derive(Debug, Clone, PartialEq)]
2327
pub enum DisplayInside {
2428
Flow,
@@ -91,10 +95,16 @@ impl DisplayInside {
9195
}
9296
}
9397

98+
/// A pair of inside and outside display values, as used in the `display` property.
99+
///
100+
/// See [Display](Display).
94101
#[derive(Debug, Clone, PartialEq)]
95102
pub struct DisplayPair {
103+
/// The outside display value.
96104
pub outside: DisplayOutside,
105+
/// The inside display value.
97106
pub inside: DisplayInside,
107+
/// Whether this is a list item.
98108
pub is_list_item: bool,
99109
}
100110

@@ -277,6 +287,9 @@ impl ToCss for DisplayPair {
277287
}
278288

279289
enum_property! {
290+
/// A `display` keyword.
291+
///
292+
/// See [Display](Display).
280293
pub enum DisplayKeyword {
281294
"none": None,
282295
"contents": Contents,
@@ -295,9 +308,12 @@ enum_property! {
295308
}
296309
}
297310

311+
/// A value for the [display](https://drafts.csswg.org/css-display-3/#the-display-properties) property.
298312
#[derive(Debug, Clone, PartialEq)]
299313
pub enum Display {
314+
/// A display keyword.
300315
Keyword(DisplayKeyword),
316+
/// The inside and outside display values.
301317
Pair(DisplayPair),
302318
}
303319

@@ -325,10 +341,13 @@ impl ToCss for Display {
325341
}
326342

327343
enum_property! {
328-
/// https://drafts.csswg.org/css-display-3/#visibility
344+
/// A value for the [visibility](https://drafts.csswg.org/css-display-3/#visibility) property.
329345
pub enum Visibility {
346+
/// The element is visible.
330347
Visible,
348+
/// The element is hidden.
331349
Hidden,
350+
/// The element is collapsed.
332351
Collapse,
333352
}
334353
}

0 commit comments

Comments
 (0)