Skip to content

Commit

Permalink
Improving error documentation (#3323)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbastian authored Apr 14, 2023
1 parent 37e5117 commit 0790ae3
Show file tree
Hide file tree
Showing 34 changed files with 50 additions and 27 deletions.
2 changes: 1 addition & 1 deletion components/calendar/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use writeable::Writeable;
#[cfg(feature = "std")]
impl std::error::Error for CalendarError {}

/// A list of error outcomes for various operations in the `icu_calendar` crate.
/// A list of error outcomes for various operations in this module.
///
/// Re-exported as [`Error`](crate::Error).
#[derive(Display, Debug, Copy, Clone, PartialEq)]
Expand Down
1 change: 0 additions & 1 deletion components/calendar/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,5 @@ pub use error::CalendarError;
pub use gregorian::Gregorian;
pub use iso::Iso;

/// Re-export of [`CalendarError`].
#[doc(no_inline)]
pub use CalendarError as Error;
2 changes: 1 addition & 1 deletion components/collator/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use displaydoc::Display;
use icu_properties::PropertiesError;
use icu_provider::prelude::DataError;

/// A list of error outcomes for various operations in the `icu_collator` crate.
/// A list of error outcomes for various operations in this module.
///
/// Re-exported as [`Error`](crate::Error).
#[derive(Display, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion components/collator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,5 +328,5 @@ pub use options::MaxVariable;
pub use options::Numeric;
pub use options::Strength;

#[doc(inline)]
#[doc(no_inline)]
pub use CollatorError as Error;
2 changes: 1 addition & 1 deletion components/collections/src/codepointinvlist/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@ pub enum CodePointInversionListError {
#[cfg(feature = "std")]
impl std::error::Error for CodePointInversionListError {}

#[doc(inline)]
#[doc(no_inline)]
pub use CodePointInversionListError as Error;
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ pub enum CodePointInversionListAndStringListError {
StringListNotSorted(String, String),
}

#[doc(inline)]
#[doc(no_inline)]
pub use CodePointInversionListAndStringListError as Error;

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion components/collections/src/codepointtrie/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ pub use cptrie::TrieType;
pub use cptrie::TrieValue;
pub use error::Error as CodePointTrieError;

#[doc(inline)]
#[doc(no_inline)]
pub use CodePointTrieError as Error;
2 changes: 1 addition & 1 deletion components/datetime/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use icu_provider::prelude::DataError;
#[cfg(feature = "std")]
impl std::error::Error for DateTimeError {}

/// A list of error outcomes for various operations in the `icu_datetime` crate.
/// A list of error outcomes for various operations in this module.
///
/// Re-exported as [`Error`](crate::Error).
#[derive(Display, Debug, Copy, Clone, PartialEq)]
Expand Down
2 changes: 1 addition & 1 deletion components/datetime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,5 @@ pub use format::zoned_datetime::FormattedZonedDateTime;
pub use options::DateTimeFormatterOptions;
pub use zoned_datetime::TypedZonedDateTimeFormatter;

#[doc(inline)]
#[doc(no_inline)]
pub use DateTimeError as Error;
2 changes: 1 addition & 1 deletion components/decimal/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use displaydoc::Display;

/// A list of error outcomes for various operations in the `icu_decimal` crate.
/// A list of error outcomes for various operations in this module.
///
/// Re-exported as [`Error`](crate::Error).
#[derive(Display, Debug, Copy, Clone, PartialEq)]
Expand Down
2 changes: 1 addition & 1 deletion components/decimal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub mod provider;
pub use error::DecimalError;
pub use format::FormattedFixedDecimal;

#[doc(inline)]
#[doc(no_inline)]
pub use DecimalError as Error;

use alloc::string::String;
Expand Down
2 changes: 1 addition & 1 deletion components/list/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use icu_provider::prelude::DataError;
#[cfg(feature = "std")]
impl std::error::Error for ListError {}

/// A list of error outcomes for various operations in the `icu_timezone` crate.
/// A list of error outcomes for various operations in this module.
///
/// Re-exported as [`Error`](crate::Error).
#[derive(Display, Debug, Copy, Clone, PartialEq)]
Expand Down
2 changes: 1 addition & 1 deletion components/list/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ pub use list_formatter::*;

pub use error::ListError;

#[doc(inline)]
#[doc(no_inline)]
pub use ListError as Error;

/// Represents the style of a list. See the
Expand Down
3 changes: 3 additions & 0 deletions components/locid/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ pub use locale::Locale;
pub use ordering::SubtagOrderingResult;
pub use parser::errors::ParserError;

#[doc(no_inline)]
pub use ParserError as Error;

pub mod extensions;
pub mod subtags;
pub mod zerovec;
Expand Down
2 changes: 2 additions & 0 deletions components/locid/src/parser/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use displaydoc::Display;
/// List of parser errors that can be generated
/// while parsing [`LanguageIdentifier`](crate::LanguageIdentifier), [`Locale`](crate::Locale),
/// [`subtags`](crate::subtags) or [`extensions`](crate::extensions).
///
/// Re-exported as [`Error`](crate::Error).
#[derive(Display, Debug, PartialEq, Copy, Clone)]
#[non_exhaustive]
pub enum ParserError {
Expand Down
2 changes: 1 addition & 1 deletion components/locid_transform/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use icu_provider::prelude::DataError;
#[cfg(feature = "std")]
impl std::error::Error for LocaleTransformError {}

/// A list of error outcomes for various operations in the `icu_timezone` crate.
/// A list of error outcomes for various operations in this module.
///
/// Re-exported as [`Error`](crate::Error).
#[derive(Display, Debug, Copy, Clone, PartialEq)]
Expand Down
2 changes: 1 addition & 1 deletion components/locid_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,5 @@ pub enum TransformResult {
Unmodified,
}

#[doc(inline)]
#[doc(no_inline)]
pub use LocaleTransformError as Error;
4 changes: 3 additions & 1 deletion components/normalizer/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ use displaydoc::Display;
use icu_properties::PropertiesError;
use icu_provider::prelude::DataError;

/// Normalizer-specific error
/// A list of error outcomes for various operations in this module.
///
/// Re-exported as [`Error`](crate::Error).
#[derive(Display, Debug)]
#[non_exhaustive]
pub enum NormalizerError {
Expand Down
3 changes: 3 additions & 0 deletions components/normalizer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ pub mod provider;

pub use crate::error::NormalizerError;

#[doc(no_inline)]
pub use NormalizerError as Error;

use crate::provider::CanonicalDecompositionDataV1Marker;
use crate::provider::CompatibilityDecompositionSupplementV1Marker;
use crate::provider::DecompositionDataV1;
Expand Down
2 changes: 1 addition & 1 deletion components/plurals/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::rules::reference::parser::ParserError;
use displaydoc::Display;
use icu_provider::prelude::DataError;

/// A list of error outcomes for various operations in the `icu_plurals` crate.
/// A list of error outcomes for various operations in this module.
///
/// Re-exported as [`Error`](crate::Error).
#[derive(Display, Debug, Clone, Copy, PartialEq)]
Expand Down
2 changes: 1 addition & 1 deletion components/plurals/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ use provider::ErasedPluralRulesV1Marker;
use provider::OrdinalV1Marker;
use rules::runtime::test_rule;

#[doc(inline)]
#[doc(no_inline)]
pub use PluralsError as Error;

/// A type of a plural rule which can be associated with the [`PluralRules`] struct.
Expand Down
2 changes: 1 addition & 1 deletion components/properties/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::Script;
#[cfg(feature = "std")]
impl std::error::Error for PropertiesError {}

/// A list of error outcomes for various operations in the `icu_properties` crate.
/// A list of error outcomes for various operations in this module.
///
/// Re-exported as [`Error`](crate::Error).
#[derive(Display, Debug, Copy, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion components/properties/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,5 +121,5 @@ pub mod names {

pub use error::PropertiesError;

#[doc(inline)]
#[doc(no_inline)]
pub use PropertiesError as Error;
2 changes: 1 addition & 1 deletion components/segmenter/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use icu_provider::prelude::DataError;
#[cfg(feature = "std")]
impl std::error::Error for SegmenterError {}

/// A list of error outcomes for various operations in the `icu_segmenter` crate.
/// A list of error outcomes for various operations in this module.
///
/// Re-exported as [`Error`](crate::Error).
#[derive(Display, Debug, Copy, Clone, PartialEq)]
Expand Down
2 changes: 1 addition & 1 deletion components/segmenter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,5 @@ pub use crate::word::WordBreakIteratorUtf8;

pub use error::SegmenterError;

#[doc(inline)]
#[doc(no_inline)]
pub use SegmenterError as Error;
2 changes: 1 addition & 1 deletion components/timezone/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use icu_provider::prelude::DataError;
#[cfg(feature = "std")]
impl std::error::Error for TimeZoneError {}

/// A list of error outcomes for various operations in the `icu_timezone` crate.
/// A list of error outcomes for various operations in this module.
///
/// Re-exported as [`Error`](crate::Error).
#[derive(Display, Debug, Copy, Clone, PartialEq)]
Expand Down
2 changes: 1 addition & 1 deletion components/timezone/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,5 +132,5 @@ pub use provider::{MetazoneId, TimeZoneBcp47Id};
pub use time_zone::CustomTimeZone;
pub use types::{GmtOffset, ZoneVariant};

#[doc(inline)]
#[doc(no_inline)]
pub use TimeZoneError as Error;
3 changes: 2 additions & 1 deletion experimental/casemapping/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ use core::char::DecodeUtf16Error;
use displaydoc::Display;
use icu_collections::codepointtrie::CodePointTrieError;

/// A list of possible errors for the [`CaseMapping`](crate::CaseMapping) struct
/// A list of error outcomes for various operations in this module.
///
/// Re-exported as [`Error`](crate::Error).
/// <div class="stab unstable">
/// 🚧 This code is experimental; it may change at any time, in breaking or non-breaking ways,
/// including in SemVer minor releases. It can be enabled with the "experimental" Cargo feature
Expand Down
2 changes: 2 additions & 0 deletions experimental/casemapping/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ pub use casemapping::CaseMapping;
pub use error::Error as CaseMappingError;
#[cfg(feature = "datagen")]
pub use internals::CaseMappingInternals;
#[doc(no_inline)]
pub use CaseMappingError as Error;
4 changes: 3 additions & 1 deletion experimental/compactdecimal/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use icu_decimal::DecimalError;
use icu_plurals::PluralsError;
use icu_provider::DataError;

/// A list of error outcomes for various operations in the `icu_compactdecimal` crate.
/// A list of error outcomes for various operations in this module.
///
/// Re-exported as [`Error`](crate::Error).
#[derive(Display, Debug, Copy, Clone, PartialEq)]
#[non_exhaustive]
pub enum CompactDecimalError {
Expand Down
2 changes: 2 additions & 0 deletions experimental/compactdecimal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ pub mod provider;

pub use compactdecimal::CompactDecimalFormatter;
pub use error::CompactDecimalError;
#[doc(no_inline)]
pub use CompactDecimalError as Error;
4 changes: 3 additions & 1 deletion experimental/relativetime/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ use icu_decimal::DecimalError;
use icu_plurals::PluralsError;
use icu_provider::DataError;

/// A list of error outcomes for various operations in the `icu_relativetime` crate.
/// A list of error outcomes for various operations in this module.
///
/// Re-exported as [`Error`](crate::Error).
#[derive(Display, Debug, Copy, Clone, PartialEq)]
#[non_exhaustive]
pub enum RelativeTimeError {
Expand Down
2 changes: 2 additions & 0 deletions experimental/relativetime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ pub use error::RelativeTimeError;
pub use format::FormattedRelativeTime;
pub use options::RelativeTimeFormatterOptions;
pub use relativetime::RelativeTimeFormatter;
#[doc(no_inline)]
pub use RelativeTimeError as Error;
3 changes: 3 additions & 0 deletions tools/ffi_coverage/src/allowlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,13 +305,16 @@ lazy_static::lazy_static! {

// Re-exports of errors
"icu::calendar::Error",
"icu::compactdecimal::Error",
"icu::datetime::Error",
"icu::decimal::Error",
"icu::list::Error",
"icu::locid::Error",
"icu::locid_transform::Error",
"icu::normalizer::Error",
"icu::plurals::Error",
"icu::properties::Error",
"icu::relativetime::Error",
"icu::segmenter::Error",
"icu::timezone::Error",
"icu::collator::Error",
Expand Down

0 comments on commit 0790ae3

Please sign in to comment.