Fix `cargo doc` warnings + add `cargo doc` to CI (#360)
* Add cargo doc to CI * Fix cargo doc warnings
Delta semántico
Ninguna definición cambió: el cambio es de texto, documentación o datos.
13 archivos · +49 −35
- .github/workflows/ci.yml +18 −0
- src/axis.rs +1 −1
- src/compute/flexbox.rs +0 −2
- src/compute/grid/mod.rs +1 −1
- src/compute/grid/placement.rs +1 −1
- src/compute/grid/track_sizing.rs +1 −1
- src/geometry.rs +2 −2
- src/layout.rs +1 −1
- src/node.rs +7 −9
- src/style/dimension.rs +2 −2
- src/style/grid.rs +11 −11
- src/style/mod.rs +1 −1
- src/style_helpers.rs +3 −3
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e3f46a1a4..d6bbf0ce6 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -114,6 +114,24 @@ jobs:
command: clippy
args: --workspace -- -D warnings
+ doc:
+ name: Documentation
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - uses: actions-rs/toolchain@v1
+ with:
+ profile: minimal
+ toolchain: stable
+ override: true
+ - run: rustup component add clippy
+ - uses: actions-rs/cargo@v1
+ with:
+ command: doc
+ env:
+ RUSTDOCFLAGS: "-D warnings"
+
+
markdownlint:
name: Markdown Lint
runs-on: ubuntu-latest
diff --git a/src/axis.rs b/src/axis.rs
index df52c902d..153924911 100644
--- a/src/axis.rs
+++ b/src/axis.rs
@@ -45,7 +45,7 @@ impl<T: Add> Rect<T> {
}
/// The CSS abstract axis
-/// https://www.w3.org/TR/css-writing-modes-3/#abstract-axes
+/// <https://www.w3.org/TR/css-writing-modes-3/#abstract-axes>
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum AbstractAxis {
/// The axis in the inline dimension, i.e. the horizontal axis in horizontal writing modes and the vertical axis in vertical writing modes.
diff --git a/src/compute/flexbox.rs b/src/compute/flexbox.rs
index 82c07611b..4d408cbfd 100644
--- a/src/compute/flexbox.rs
+++ b/src/compute/flexbox.rs
@@ -1,6 +1,4 @@
//! Computes the [flexbox](https://css-tricks.com/snippets/css/a-guide-to-flexbox/) layout algorithm on [`Taffy`](crate::Taffy) according to the [spec](https://www.w3.org/TR/css-flexbox-1/)
-//!
-//! Note that some minor steps appear to be missing: see https://github.com/DioxusLabs/taffy/issues for more information.
use core::f32;
use crate::compute::common::alignment::compute_alignment_offset;
diff --git a/src/compute/grid/mod.rs b/src/compute/grid/mod.rs
index 87841eb7c..4e691eae5 100644
--- a/src/compute/grid/mod.rs
+++ b/src/compute/grid/mod.rs
@@ -1,5 +1,5 @@
//! This module is a partial implementation of the CSS Grid Level 1 specification
-//! https://www.w3.org/TR/css-grid-1/
+//! <https://www.w3.org/TR/css-grid-1>
use crate::axis::{AbsoluteAxis, AbstractAxis, InBothAbsAxis};
use crate::geometry::{Line, Point, Rect, Size};
use crate::layout::{Layout, RunMode, SizeAndBaselines, SizingMode};
diff --git a/src/compute/grid/placement.rs b/src/compute/grid/placement.rs
index 52cfbf8d7..d02e7af8e 100644
--- a/src/compute/grid/placement.rs
+++ b/src/compute/grid/placement.rs
@@ -1,5 +1,5 @@
//! Implements placing items in the grid and resolving the implicit grid.
-//! https://www.w3.org/TR/css-grid-1/#placement
+//! <https://www.w3.org/TR/css-grid-1/#placement>
use super::types::{CellOccupancyMatrix, CellOccupancyState, GridItem};
use super::OriginZeroLine;
use crate::axis::{AbsoluteAxis, InBothAbsAxis};
diff --git a/src/compute/grid/track_sizing.rs b/src/compute/grid/track_sizing.rs
index 1d63c190f..7d1994dd7 100644
--- a/src/compute/grid/track_sizing.rs
+++ b/src/compute/grid/track_sizing.rs
@@ -1,5 +1,5 @@
//! Implements the track sizing algorithm
-//! https://www.w3.org/TR/css-grid-1/#layout-algorithm
+//! <https://www.w3.org/TR/css-grid-1/#layout-algorithm>
use super::types::{GridItem, GridTrack, TrackCounts};
use crate::axis::AbstractAxis;
use crate::compute::{GenericAlgorithm, LayoutAlgorithm};
diff --git a/src/geometry.rs b/src/geometry.rs
index ac4db54c9..942cdd479 100644
--- a/src/geometry.rs
+++ b/src/geometry.rs
@@ -85,12 +85,12 @@ impl<T> Rect<T> {
Rect { top: f(self.top), bottom: f(self.bottom), left: f(self.left), right: f(self.right) }
}
- /// Returns a Line<T> representing the left and right properties of the Rect
+ /// Returns a `Line<T>` representing the left and right properties of the Rect
pub fn horizontal_components(self) -> Line<T> {
Line { start: self.left, end: self.right }
}
- /// Returns a Line<T> containing the top and bottom properties of the Rect
+ /// Returns a `Line<T>` containing the top and bottom properties of the Rect
pub fn vertical_components(self) -> Line<T> {
Line { start: self.top, end: self.bottom }
}
diff --git a/src/layout.rs b/src/layout.rs
index 522cce1bd..dbadcbcb7 100644
--- a/src/layout.rs
+++ b/src/layout.rs
@@ -25,7 +25,7 @@ pub enum SizingMode {
/// A struct containing both the size of a node and it's first baseline in each dimension (if it has any)
///
/// A baseline is the line on which text sits. Your node likely has a baseline if it is a text node, or contains
-/// children that may be text nodes. See https://www.w3.org/TR/css-writing-modes-3/#intro-baselines for details.
+/// children that may be text nodes. See <https://www.w3.org/TR/css-writing-modes-3/#intro-baselines> for details.
/// If your node does not have a baseline (or you are unsure how to compute it), then simply return `Point::NONE`
/// for the first_baselines field
#[derive(Debug, Copy, Clone)]
diff --git a/src/node.rs b/src/node.rs
index fd6ce46b5..433ea39b8 100644
--- a/src/node.rs
+++ b/src/node.rs
@@ -37,7 +37,7 @@ pub struct Taffy {
/// The [`NodeData`] for each node stored in this tree
pub(crate) nodes: SlotMap<Node, NodeData>,
- /// The mapping from the Size<AvailableSpace> (in real units) to Size<f32> (in points) for this node
+ /// Functions/closures that compute the intrinsic size of leaf nodes
pub(crate) measure_funcs: SparseSecondaryMap<Node, MeasureFunc>,
/// The children of each node
@@ -143,7 +143,7 @@ impl Taffy {
}
}
- /// Creates and adds a new unattached leaf node to the tree, and returns the [`NodeId`] of the new node
+ /// Creates and adds a new unattached leaf node to the tree, and returns the [`Node`] of the new node
pub fn new_leaf(&mut self, layout: Style) -> TaffyResult<Node> {
let id = self.nodes.insert(NodeData::new(layout));
let _ = self.children.insert(new_vec_with_capacity(0));
@@ -152,7 +152,7 @@ impl Taffy {
Ok(id)
}
- /// Creates and adds a new unattached leaf node to the tree, and returns the [`NodeId`] of the new node
+ /// Creates and adds a new unattached leaf node to the tree, and returns the [`Node`] of the new node
///
/// Creates and adds a new leaf node with a supplied [`MeasureFunc`]
pub fn new_leaf_with_measure(&mut self, layout: Style, measure: MeasureFunc) -> TaffyResult<Node> {
@@ -182,18 +182,16 @@ impl Taffy {
Ok(id)
}
- /// Removes all nodes
- ///
- /// All associated [`Id`] will be rendered invalid.
+ /// Drops all nodes in the tree
pub fn clear(&mut self) {
self.nodes.clear();
self.children.clear();
self.parents.clear();
}
- /// Remove a specific [`Node`] from the tree
+ /// Remove a specific [`Node`] from the tree and drops it
///
- /// Its [`Id`] is marked as invalid. Returns the id of the node removed.
+ /// Returns the id of the node removed.
pub fn remove(&mut self, node: Node) -> TaffyResult<Node> {
if let Some(parent) = self.parents[node] {
if let Some(children) = self.children.get_mut(parent) {
@@ -309,7 +307,7 @@ impl Taffy {
Ok(self.children[parent].len())
}
- /// Returns a list of children that belong to the [`Parent`]
+ /// Returns a list of children that belong to the parent [`Node`]
pub fn children(&self, parent: Node) -> TaffyResult<Vec<Node>> {
Ok(self.children[parent].iter().copied().collect::<_>())
}
diff --git a/src/style/dimension.rs b/src/style/dimension.rs
index b2c98c618..21e3d7f1c 100644
--- a/src/style/dimension.rs
+++ b/src/style/dimension.rs
@@ -175,7 +175,7 @@ impl Rect<Dimension> {
}
/// The amount of space available to a node in a given axis
-/// https://www.w3.org/TR/css-sizing-3/#available
+/// <https://www.w3.org/TR/css-sizing-3/#available>
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum AvailableSpace {
/// The amount of space available is the specified number of pixels
@@ -301,7 +301,7 @@ impl From<Option<f32>> for AvailableSpace {
}
impl Size<AvailableSpace> {
- /// Convert Size<AvailableSpace> into Size<Option<f32>>
+ /// Convert `Size<AvailableSpace>` into `Size<Option<f32>>`
pub fn into_options(self) -> Size<Option<f32>> {
Size { width: self.width.into_option(), height: self.height.into_option() }
}
diff --git a/src/style/grid.rs b/src/style/grid.rs
index 215ac4a8f..4e84589d5 100644
--- a/src/style/grid.rs
+++ b/src/style/grid.rs
@@ -36,7 +36,7 @@ impl Default for GridAutoFlow {
impl GridAutoFlow {
/// Whether grid auto placement uses the sparse placement algorithm or the dense placement algorithm
- /// See: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow#values
+ /// See: <https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow#values>
pub fn is_dense(&self) -> bool {
match self {
Self::Row | Self::Column => false,
@@ -45,7 +45,7 @@ impl GridAutoFlow {
}
/// Whether grid auto placement fills areas row-wise or column-wise
- /// See: https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow#values
+ /// See: <https://developer.mozilla.org/en-US/docs/Web/CSS/grid-auto-flow#values>
pub fn primary_axis(&self) -> AbsoluteAxis {
match self {
Self::Row | Self::RowDense => AbsoluteAxis::Horizontal,
@@ -77,7 +77,7 @@ pub(crate) type OriginZeroGridPlacement = GenericGridPlacement<OriginZeroLine>;
/// A grid line placement specification. Used for grid-[row/column]-[start/end]. Named tracks are not implemented.
///
-/// Defaults to [`GridLine::Auto`]
+/// Defaults to `GridPlacement::Auto`
///
/// [Specification](https://www.w3.org/TR/css3-grid-layout/#typedef-grid-row-start-grid-line)
pub type GridPlacement = GenericGridPlacement<GridLine>;
@@ -236,7 +236,7 @@ impl Default for Line<GridPlacement> {
///
/// Specifies the maximum size of a grid track. A grid track will automatically size between it's minimum and maximum size based
/// on the size of it's contents, the amount of available space, and the sizing constraint the grid is being size under.
-/// See https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns
+/// See <https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns>
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum MaxTrackSizingFunction {
/// Track maximum size should be a fixed points or percentage value
@@ -251,7 +251,7 @@ pub enum MaxTrackSizingFunction {
Auto,
/// The dimension as a fraction of the total available grid space (`fr` units in CSS)
/// Specified value is the numerator of the fraction. Denominator is the sum of all fraction specified in that grid dimension
- /// Spec: https://www.w3.org/TR/css3-grid-layout/#fr-unit
+ /// Spec: <https://www.w3.org/TR/css3-grid-layout/#fr-unit>
Fraction(f32),
}
impl TaffyAuto for MaxTrackSizingFunction {
@@ -296,7 +296,7 @@ impl MaxTrackSizingFunction {
/// Returns true if the max track sizing function is `MaxContent`, `FitContent` or `Auto` else false.
/// "In all cases, treat auto and fit-content() as max-content, except where specified otherwise for fit-content()."
- /// See: https://www.w3.org/TR/css-grid-1/#algo-terms
+ /// See: <https://www.w3.org/TR/css-grid-1/#algo-terms>
#[inline(always)]
pub fn is_max_content_alike(&self) -> bool {
matches!(self, Self::MaxContent | Self::FitContent(_) | Self::Auto)
@@ -360,7 +360,7 @@ impl MaxTrackSizingFunction {
///
/// Specifies the minimum size of a grid track. A grid track will automatically size between it's minimum and maximum size based
/// on the size of it's contents, the amount of available space, and the sizing constraint the grid is being size under.
-/// See https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns
+/// See <https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns>
#[derive(Copy, Clone, PartialEq, Debug)]
pub enum MinTrackSizingFunction {
/// Track minimum size should be a fixed points or percentage value
@@ -489,15 +489,15 @@ impl FromFlex for NonRepeatedTrackSizingFunction {
/// The first argument to a repeated track definition. This type represents the type of automatic repetition to perform.
///
-/// See https://www.w3.org/TR/css-grid-1/#auto-repeat for an explanation of how auto-repeated track definitions work
+/// See <https://www.w3.org/TR/css-grid-1/#auto-repeat> for an explanation of how auto-repeated track definitions work
/// and the difference between AutoFit and AutoFill.
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum GridTrackRepetition {
/// Auto-repeating tracks should be generated to fit the container
- /// See: https://developer.mozilla.org/en-US/docs/Web/CSS/repeat#auto-fill
+ /// See: <https://developer.mozilla.org/en-US/docs/Web/CSS/repeat#auto-fill>
AutoFill,
/// Auto-repeating tracks should be generated to fit the container
- /// See: https://developer.mozilla.org/en-US/docs/Web/CSS/repeat#auto-fit
+ /// See: <https://developer.mozilla.org/en-US/docs/Web/CSS/repeat#auto-fit>
AutoFit,
/// The specified tracks should be repeated exacts N times
Count(u16),
@@ -532,7 +532,7 @@ impl<'a> TryFrom<&'a str> for GridTrackRepetition {
}
/// The sizing function for a grid track (row/column)
-/// See https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns
+/// See <https://developer.mozilla.org/en-US/docs/Web/CSS/grid-template-columns>
#[derive(Clone, PartialEq, Debug)]
pub enum TrackSizingFunction {
/// A single non-repeated track
diff --git a/src/style/mod.rs b/src/style/mod.rs
index a424bd702..b0cf1c238 100644
--- a/src/style/mod.rs
+++ b/src/style/mod.rs
@@ -52,7 +52,7 @@ impl Default for Display {
/// WARNING: this enum follows the behavior of [CSS's `position` property](https://developer.mozilla.org/en-US/docs/Web/CSS/position),
/// which can be unintuitive.
///
-/// [`PositionType::Relative`] is the default value, in contrast to the default behavior in CSS.
+/// [`Position::Relative`] is the default value, in contrast to the default behavior in CSS.
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum Position {
diff --git a/src/style_helpers.rs b/src/style_helpers.rs
index 83f51f086..94f262b9f 100644
--- a/src/style_helpers.rs
+++ b/src/style_helpers.rs
@@ -333,7 +333,7 @@ pub fn points<Input: Into<f32> + Copy, T: FromPoints>(points: Input) -> T {
/// Trait to create constant points values from plain numbers
pub trait FromPoints {
- /// Converts into an Into<f32> into Self
+ /// Converts into an `Into<f32>` into Self
fn from_points<Input: Into<f32> + Copy>(points: Input) -> Self;
}
impl FromPoints for f32 {
@@ -395,7 +395,7 @@ pub fn percent<Input: Into<f32> + Copy, T: FromPercent>(percent: Input) -> T {
/// Trait to create constant percent values from plain numbers
pub trait FromPercent {
- /// Converts into an Into<f32> into Self
+ /// Converts into an `Into<f32>` into Self
fn from_percent<Input: Into<f32> + Copy>(percent: Input) -> Self;
}
impl FromPercent for f32 {
@@ -457,6 +457,6 @@ pub fn fr<Input: Into<f32> + Copy, T: FromFlex>(flex: Input) -> T {
/// Trait to create constant percent values from plain numbers
pub trait FromFlex {
- /// Converts into an Into<f32> into Self
+ /// Converts into an `Into<f32>` into Self
fn from_flex<Input: Into<f32> + Copy>(flex: Input) -> Self;
}