Skip to content

Commit

Permalink
Format docs for 2.0.0-beta1 release (#5863)
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc authored Nov 23, 2024
1 parent da2c1b3 commit c041712
Show file tree
Hide file tree
Showing 103 changed files with 1,051 additions and 791 deletions.
5 changes: 2 additions & 3 deletions components/calendar/src/buddhist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,8 @@ impl DateTime<Buddhist> {
/// ```rust
/// use icu::calendar::DateTime;
///
/// let datetime_buddhist =
/// DateTime::try_new_buddhist(1970, 1, 2, 13, 1, 0)
/// .expect("Failed to initialize Buddhist DateTime instance.");
/// let datetime_buddhist = DateTime::try_new_buddhist(1970, 1, 2, 13, 1, 0)
/// .expect("Failed to initialize Buddhist DateTime instance.");
///
/// assert_eq!(datetime_buddhist.date.year().era_year_or_extended(), 1970);
/// assert_eq!(datetime_buddhist.date.month().ordinal, 1);
Expand Down
19 changes: 8 additions & 11 deletions components/calendar/src/chinese.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,13 @@
//! let chinese = Ref(&chinese); // to avoid cloning
//!
//! // `Date` type
//! let chinese_date =
//! Date::try_new_chinese_with_calendar(4660, 6, 6, chinese)
//! .expect("Failed to initialize Chinese Date instance.");
//! let chinese_date = Date::try_new_chinese_with_calendar(4660, 6, 6, chinese)
//! .expect("Failed to initialize Chinese Date instance.");
//!
//! // `DateTime` type
//! let chinese_datetime = DateTime::try_new_chinese_with_calendar(
//! 4660, 6, 6, 13, 1, 0, chinese,
//! )
//! .expect("Failed to initialize Chinese DateTime instance");
//! let chinese_datetime =
//! DateTime::try_new_chinese_with_calendar(4660, 6, 6, 13, 1, 0, chinese)
//! .expect("Failed to initialize Chinese DateTime instance");
//!
//! // `Date` checks
//! assert_eq!(chinese_date.year().era_year_or_extended(), 4660);
Expand Down Expand Up @@ -364,10 +362,9 @@ impl<A: AsCalendar<Calendar = Chinese>> DateTime<A> {
///
/// let chinese = Chinese::new_always_calculating();
///
/// let chinese_datetime = DateTime::try_new_chinese_with_calendar(
/// 4660, 6, 11, 13, 1, 0, chinese,
/// )
/// .expect("Failed to initialize Chinese DateTime instance.");
/// let chinese_datetime =
/// DateTime::try_new_chinese_with_calendar(4660, 6, 11, 13, 1, 0, chinese)
/// .expect("Failed to initialize Chinese DateTime instance.");
///
/// assert_eq!(chinese_datetime.date.year().era_year_or_extended(), 4660);
/// assert_eq!(chinese_datetime.date.year().cyclic().unwrap().get(), 40);
Expand Down
5 changes: 2 additions & 3 deletions components/calendar/src/coptic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,8 @@ impl DateTime<Coptic> {
/// ```rust
/// use icu::calendar::DateTime;
///
/// let datetime_coptic =
/// DateTime::try_new_coptic(1686, 5, 6, 13, 1, 0)
/// .expect("Failed to initialize Coptic DateTime instance.");
/// let datetime_coptic = DateTime::try_new_coptic(1686, 5, 6, 13, 1, 0)
/// .expect("Failed to initialize Coptic DateTime instance.");
///
/// assert_eq!(datetime_coptic.date.year().era_year_or_extended(), 1686);
/// assert_eq!(datetime_coptic.date.month().ordinal, 5);
Expand Down
14 changes: 6 additions & 8 deletions components/calendar/src/dangi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,9 @@
//! .expect("Failed to initialize Dangi Date instance.");
//!
//! // `DateTime` type
//! let dangi_datetime = DateTime::try_new_dangi_with_calendar(
//! 4356, 6, 6, 13, 1, 0, dangi,
//! )
//! .expect("Failed to initialize Dangi DateTime instance.");
//! let dangi_datetime =
//! DateTime::try_new_dangi_with_calendar(4356, 6, 6, 13, 1, 0, dangi)
//! .expect("Failed to initialize Dangi DateTime instance.");
//!
//! // `Date` checks
//! assert_eq!(dangi_date.year().era_year_or_extended(), 4356);
Expand Down Expand Up @@ -343,10 +342,9 @@ impl<A: AsCalendar<Calendar = Dangi>> DateTime<A> {
///
/// let dangi = Dangi::new();
///
/// let dangi_datetime = DateTime::try_new_dangi_with_calendar(
/// 4356, 6, 6, 13, 1, 0, dangi,
/// )
/// .expect("Failed to initialize Dangi DateTime instance.");
/// let dangi_datetime =
/// DateTime::try_new_dangi_with_calendar(4356, 6, 6, 13, 1, 0, dangi)
/// .expect("Failed to initialize Dangi DateTime instance.");
///
/// assert_eq!(dangi_datetime.date.year().era_year_or_extended(), 4356);
/// assert_eq!(dangi_datetime.date.year().cyclic().unwrap().get(), 40);
Expand Down
10 changes: 3 additions & 7 deletions components/calendar/src/ethiopian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,9 @@ impl Date<Ethiopian> {
/// use icu::calendar::cal::EthiopianEraStyle;
/// use icu::calendar::Date;
///
/// let date_ethiopian = Date::try_new_ethiopian(
/// EthiopianEraStyle::AmeteMihret,
/// 2014,
/// 8,
/// 25,
/// )
/// .expect("Failed to initialize Ethopic Date instance.");
/// let date_ethiopian =
/// Date::try_new_ethiopian(EthiopianEraStyle::AmeteMihret, 2014, 8, 25)
/// .expect("Failed to initialize Ethopic Date instance.");
///
/// assert_eq!(date_ethiopian.year().era_year_or_extended(), 2014);
/// assert_eq!(date_ethiopian.month().ordinal, 8);
Expand Down
5 changes: 2 additions & 3 deletions components/calendar/src/gregorian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,9 +204,8 @@ impl DateTime<Gregorian> {
/// ```rust
/// use icu::calendar::DateTime;
///
/// let datetime_gregorian =
/// DateTime::try_new_gregorian(1970, 1, 2, 13, 1, 0)
/// .expect("Failed to initialize Gregorian DateTime instance.");
/// let datetime_gregorian = DateTime::try_new_gregorian(1970, 1, 2, 13, 1, 0)
/// .expect("Failed to initialize Gregorian DateTime instance.");
///
/// assert_eq!(datetime_gregorian.date.year().era_year_or_extended(), 1970);
/// assert_eq!(datetime_gregorian.date.month().ordinal, 1);
Expand Down
10 changes: 4 additions & 6 deletions components/calendar/src/hebrew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
//! .expect("Failed to initialize hebrew Date instance.");
//!
//! // `DateTime` type
//! let hebrew_datetime =
//! DateTime::try_new_hebrew(3425, 10, 11, 13, 1, 0)
//! .expect("Failed to initialize hebrew DateTime instance.");
//! let hebrew_datetime = DateTime::try_new_hebrew(3425, 10, 11, 13, 1, 0)
//! .expect("Failed to initialize hebrew DateTime instance.");
//!
//! // `Date` checks
//! assert_eq!(hebrew_date.year().era_year_or_extended(), 3425);
Expand Down Expand Up @@ -382,9 +381,8 @@ impl DateTime<Hebrew> {
/// ```rust
/// use icu::calendar::DateTime;
///
/// let datetime_hebrew =
/// DateTime::try_new_hebrew(4201, 10, 11, 13, 1, 0)
/// .expect("Failed to initialize Hebrew DateTime instance");
/// let datetime_hebrew = DateTime::try_new_hebrew(4201, 10, 11, 13, 1, 0)
/// .expect("Failed to initialize Hebrew DateTime instance");
///
/// assert_eq!(datetime_hebrew.date.year().era_year_or_extended(), 4201);
/// assert_eq!(datetime_hebrew.date.month().ordinal, 10);
Expand Down
5 changes: 2 additions & 3 deletions components/calendar/src/indian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,8 @@ impl DateTime<Indian> {
/// ```rust
/// use icu::calendar::DateTime;
///
/// let datetime_indian =
/// DateTime::try_new_indian(1891, 10, 12, 13, 1, 0)
/// .expect("Failed to initialize Indian DateTime instance.");
/// let datetime_indian = DateTime::try_new_indian(1891, 10, 12, 13, 1, 0)
/// .expect("Failed to initialize Indian DateTime instance.");
///
/// assert_eq!(datetime_indian.date.year().era_year_or_extended(), 1891);
/// assert_eq!(datetime_indian.date.month().ordinal, 10);
Expand Down
55 changes: 29 additions & 26 deletions components/calendar/src/islamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
//! let islamic = Ref(&islamic); // to avoid cloning
//!
//! // `Date` type
//! let islamic_date =
//! Date::try_new_observational_islamic_with_calendar(1348, 10, 11, islamic)
//! .expect("Failed to initialize islamic Date instance.");
//! let islamic_date = Date::try_new_observational_islamic_with_calendar(
//! 1348, 10, 11, islamic,
//! )
//! .expect("Failed to initialize islamic Date instance.");
//!
//! // `DateTime` type
//! let islamic_datetime = DateTime::try_new_observational_islamic_with_calendar(
//! 1348, 10, 11, 13, 1, 0, islamic,
//! )
//! .expect("Failed to initialize islamic DateTime instance.");
//! let islamic_datetime =
//! DateTime::try_new_observational_islamic_with_calendar(
//! 1348, 10, 11, 13, 1, 0, islamic,
//! )
//! .expect("Failed to initialize islamic DateTime instance.");
//!
//! // `Date` checks
//! assert_eq!(islamic_date.year().era_year_or_extended(), 1348);
Expand Down Expand Up @@ -602,10 +604,11 @@ impl<A: AsCalendar<Calendar = IslamicObservational>> DateTime<A> {
///
/// let islamic = IslamicObservational::new_always_calculating();
///
/// let datetime_islamic = DateTime::try_new_observational_islamic_with_calendar(
/// 474, 10, 11, 13, 1, 0, islamic,
/// )
/// .expect("Failed to initialize Islamic DateTime instance.");
/// let datetime_islamic =
/// DateTime::try_new_observational_islamic_with_calendar(
/// 474, 10, 11, 13, 1, 0, islamic,
/// )
/// .expect("Failed to initialize Islamic DateTime instance.");
///
/// assert_eq!(datetime_islamic.date.year().era_year_or_extended(), 474);
/// assert_eq!(datetime_islamic.date.month().ordinal, 10);
Expand Down Expand Up @@ -794,8 +797,9 @@ impl<A: AsCalendar<Calendar = IslamicUmmAlQura>> Date<A> {
///
/// let islamic = IslamicUmmAlQura::new_always_calculating();
///
/// let date_islamic = Date::try_new_ummalqura_with_calendar(1392, 4, 25, islamic)
/// .expect("Failed to initialize Islamic Date instance.");
/// let date_islamic =
/// Date::try_new_ummalqura_with_calendar(1392, 4, 25, islamic)
/// .expect("Failed to initialize Islamic Date instance.");
///
/// assert_eq!(date_islamic.year().era_year_or_extended(), 1392);
/// assert_eq!(date_islamic.month().ordinal, 4);
Expand Down Expand Up @@ -829,9 +833,10 @@ impl<A: AsCalendar<Calendar = IslamicUmmAlQura>> DateTime<A> {
///
/// let islamic = IslamicUmmAlQura::new_always_calculating();
///
/// let datetime_islamic =
/// DateTime::try_new_ummalqura_with_calendar(474, 10, 11, 13, 1, 0, islamic)
/// .expect("Failed to initialize Islamic DateTime instance.");
/// let datetime_islamic = DateTime::try_new_ummalqura_with_calendar(
/// 474, 10, 11, 13, 1, 0, islamic,
/// )
/// .expect("Failed to initialize Islamic DateTime instance.");
///
/// assert_eq!(datetime_islamic.date.year().era_year_or_extended(), 474);
/// assert_eq!(datetime_islamic.date.month().ordinal, 10);
Expand Down Expand Up @@ -1060,11 +1065,10 @@ impl<A: AsCalendar<Calendar = IslamicCivil>> DateTime<A> {
///
/// let islamic = IslamicCivil::new();
///
/// let datetime_islamic =
/// DateTime::try_new_islamic_civil_with_calendar(
/// 474, 10, 11, 13, 1, 0, islamic,
/// )
/// .expect("Failed to initialize Islamic DateTime instance.");
/// let datetime_islamic = DateTime::try_new_islamic_civil_with_calendar(
/// 474, 10, 11, 13, 1, 0, islamic,
/// )
/// .expect("Failed to initialize Islamic DateTime instance.");
///
/// assert_eq!(datetime_islamic.date.year().era_year_or_extended(), 474);
/// assert_eq!(datetime_islamic.date.month().ordinal, 10);
Expand Down Expand Up @@ -1292,11 +1296,10 @@ impl<A: AsCalendar<Calendar = IslamicTabular>> DateTime<A> {
///
/// let islamic = IslamicTabular::new();
///
/// let datetime_islamic =
/// DateTime::try_new_islamic_tabular_with_calendar(
/// 474, 10, 11, 13, 1, 0, islamic,
/// )
/// .expect("Failed to initialize Islamic DateTime instance.");
/// let datetime_islamic = DateTime::try_new_islamic_tabular_with_calendar(
/// 474, 10, 11, 13, 1, 0, islamic,
/// )
/// .expect("Failed to initialize Islamic DateTime instance.");
///
/// assert_eq!(datetime_islamic.date.year().era_year_or_extended(), 474);
/// assert_eq!(datetime_islamic.date.month().ordinal, 10);
Expand Down
6 changes: 4 additions & 2 deletions components/calendar/src/ixdtf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ impl DateTime<Iso> {
/// ```
/// use icu::calendar::DateTime;
///
/// let datetime = DateTime::try_iso_from_str("2024-07-17T16:01:17.045").unwrap();
/// let datetime =
/// DateTime::try_iso_from_str("2024-07-17T16:01:17.045").unwrap();
///
/// assert_eq!(datetime.date.year().era_year_or_extended(), 2024);
/// assert_eq!(
Expand Down Expand Up @@ -258,7 +259,8 @@ impl DateTime<AnyCalendar> {
/// ```
/// use icu::calendar::DateTime;
///
/// let datetime = DateTime::try_from_str("2024-07-17T16:01:17.045[u-ca=hebrew]").unwrap();
/// let datetime =
/// DateTime::try_from_str("2024-07-17T16:01:17.045[u-ca=hebrew]").unwrap();
///
/// assert_eq!(datetime.date.year().era_year_or_extended(), 5784);
/// assert_eq!(
Expand Down
30 changes: 22 additions & 8 deletions components/calendar/src/japanese.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
//! assert_eq!(date_japanese.year().era_year_or_extended(), 45);
//! assert_eq!(date_japanese.month().ordinal, 1);
//! assert_eq!(date_japanese.day_of_month().0, 2);
//! assert_eq!(date_japanese.year().standard_era().unwrap(), Era(tinystr!(16, "showa")));
//! assert_eq!(
//! date_japanese.year().standard_era().unwrap(),
//! Era(tinystr!(16, "showa"))
//! );
//!
//! // `DateTime` type
//! assert_eq!(datetime_japanese.date.year().era_year_or_extended(), 45);
Expand Down Expand Up @@ -430,8 +433,9 @@ impl Date<Japanese> {
///
/// let era = types::Era(tinystr!(16, "heisei"));
///
/// let date = Date::try_new_japanese_with_calendar(era, 14, 1, 2, japanese_calendar)
/// .expect("Constructing a date should succeed");
/// let date =
/// Date::try_new_japanese_with_calendar(era, 14, 1, 2, japanese_calendar)
/// .expect("Constructing a date should succeed");
///
/// assert_eq!(date.year().standard_era().unwrap(), era);
/// assert_eq!(date.year().era_year_or_extended(), 14);
Expand All @@ -446,8 +450,13 @@ impl Date<Japanese> {
///
/// // and for unknown eras
/// let fake_era = types::Era(tinystr!(16, "neko")); // 🐱
/// let fake_date =
/// Date::try_new_japanese_with_calendar(fake_era, 10, 1, 2, japanese_calendar);
/// let fake_date = Date::try_new_japanese_with_calendar(
/// fake_era,
/// 10,
/// 1,
/// 2,
/// japanese_calendar,
/// );
/// assert!(fake_date.is_err());
/// ```
pub fn try_new_japanese_with_calendar<A: AsCalendar<Calendar = Japanese>>(
Expand Down Expand Up @@ -484,9 +493,14 @@ impl Date<JapaneseExtended> {
///
/// let era = types::Era(tinystr!(16, "kansei-1789"));
///
/// let date =
/// Date::try_new_japanese_extended_with_calendar(era, 7, 1, 2, japanext_calendar)
/// .expect("Constructing a date should succeed");
/// let date = Date::try_new_japanese_extended_with_calendar(
/// era,
/// 7,
/// 1,
/// 2,
/// japanext_calendar,
/// )
/// .expect("Constructing a date should succeed");
///
/// assert_eq!(date.year().standard_era().unwrap(), era);
/// assert_eq!(date.year().era_year_or_extended(), 7);
Expand Down
5 changes: 2 additions & 3 deletions components/calendar/src/julian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,8 @@ impl DateTime<Julian> {
/// ```rust
/// use icu::calendar::DateTime;
///
/// let datetime_julian =
/// DateTime::try_new_julian(1969, 12, 20, 13, 1, 0)
/// .expect("Failed to initialize Julian DateTime instance.");
/// let datetime_julian = DateTime::try_new_julian(1969, 12, 20, 13, 1, 0)
/// .expect("Failed to initialize Julian DateTime instance.");
///
/// assert_eq!(datetime_julian.date.year().era_year_or_extended(), 1969);
/// assert_eq!(datetime_julian.date.month().ordinal, 12);
Expand Down
10 changes: 4 additions & 6 deletions components/calendar/src/persian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
//! .expect("Failed to initialize Persian Date instance.");
//!
//! // `DateTime` type
//! let persian_datetime =
//! DateTime::try_new_persian(1348, 10, 11, 13, 1, 0)
//! .expect("Failed to initialize Persian DateTime instance.");
//! let persian_datetime = DateTime::try_new_persian(1348, 10, 11, 13, 1, 0)
//! .expect("Failed to initialize Persian DateTime instance.");
//!
//! // `Date` checks
//! assert_eq!(persian_date.year().era_year_or_extended(), 1348);
Expand Down Expand Up @@ -262,9 +261,8 @@ impl DateTime<Persian> {
/// ```rust
/// use icu::calendar::DateTime;
///
/// let datetime_persian =
/// DateTime::try_new_persian(474, 10, 11, 13, 1, 0)
/// .expect("Failed to initialize Persian DateTime instance.");
/// let datetime_persian = DateTime::try_new_persian(474, 10, 11, 13, 1, 0)
/// .expect("Failed to initialize Persian DateTime instance.");
///
/// assert_eq!(datetime_persian.date.year().era_year_or_extended(), 474);
/// assert_eq!(datetime_persian.date.month().ordinal, 10);
Expand Down
11 changes: 9 additions & 2 deletions components/calendar/src/roc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,15 @@ impl DateTime<Roc> {
/// let datetime_roc = DateTime::try_new_roc(1, 2, 3, 13, 1, 0)
/// .expect("Failed to initialize ROC DateTime instance.");
///
/// assert_eq!(datetime_roc.date.year().standard_era().unwrap().0, tinystr!(16, "roc"));
/// assert_eq!(datetime_roc.date.year().era_year_or_extended(), 1, "ROC year check failed!");
/// assert_eq!(
/// datetime_roc.date.year().standard_era().unwrap().0,
/// tinystr!(16, "roc")
/// );
/// assert_eq!(
/// datetime_roc.date.year().era_year_or_extended(),
/// 1,
/// "ROC year check failed!"
/// );
/// assert_eq!(
/// datetime_roc.date.month().ordinal,
/// 2,
Expand Down
3 changes: 2 additions & 1 deletion components/collator/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c041712

Please sign in to comment.