Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format code in doc comments #1899

Merged
merged 7 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 7 additions & 17 deletions components/calendar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ for working with dates, encompassing information about the day, month, year,
as well as the calendar type.

```rust
use icu_calendar::{Date,
DateDuration,
DateDurationUnit,
types::IsoWeekday};
use icu_calendar::{types::IsoWeekday, Date, DateDuration, DateDurationUnit};

// Creating ISO date: 1992-09-02.
let mut date_iso = Date::new_iso_date_from_integers(1992, 9, 2)
Expand Down Expand Up @@ -72,9 +69,7 @@ assert_eq!(mutated_date_iso.day_of_month().0, 27);
Example of converting an ISO date across Indian and Buddhist calendars.

```rust
use icu_calendar::{Date,
buddhist::Buddhist,
indian::Indian};
use icu_calendar::{buddhist::Buddhist, indian::Indian, Date};

// Creating ISO date: 1992-09-02.
let mut date_iso = Date::new_iso_date_from_integers(1992, 9, 2)
Expand Down Expand Up @@ -103,14 +98,10 @@ year, and calendar type. Additionally, `DateTime` objects contain an accessible
`Time` object, including granularity of hour, minute, second, and nanosecond.

```rust
use icu_calendar::{DateTime,
DateDuration,
types::IsoWeekday,
types::IsoHour,
types::IsoMinute,
types::IsoSecond,
types::NanoSecond,
types::Time};
use icu_calendar::{
types::IsoHour, types::IsoMinute, types::IsoSecond, types::IsoWeekday, types::NanoSecond,
types::Time, DateDuration, DateTime,
};

// Creating ISO date: 1992-09-02 8:59
let mut datetime_iso = DateTime::new_iso_datetime_from_integers(1992, 9, 2, 8, 59, 0)
Expand All @@ -128,8 +119,7 @@ assert_eq!(datetime_iso.time.nanosecond, NanoSecond::new_unchecked(0));
// Advancing date by 1 year, 2 months, 3 weeks, 4 days.
datetime_iso.date.add(DateDuration::new(1, 2, 3, 4));
// New time of 14:30
datetime_iso.time = Time::try_new(14, 30, 0, 0)
.expect("Failed to initialize Time instance.");
datetime_iso.time = Time::try_new(14, 30, 0, 0).expect("Failed to initialize Time instance.");

assert_eq!(datetime_iso.date.year().number, 1993);
assert_eq!(datetime_iso.date.month().number, 11);
Expand Down
15 changes: 6 additions & 9 deletions components/calendar/src/buddhist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
//! This module contains types and implementations for the Buddhist calendar.
//!
//! ```rust
//! use icu::calendar::{Date, DateTime,
//! types::IsoHour, types::IsoMinute, types::IsoSecond,
//! buddhist::Buddhist};
//! use icu::calendar::{
//! buddhist::Buddhist, types::IsoHour, types::IsoMinute, types::IsoSecond, Date, DateTime,
//! };
//!
//! // `Date` type
//! let date_iso = Date::new_iso_date_from_integers(1970, 1, 2)
Expand Down Expand Up @@ -133,8 +133,8 @@ impl Date<Buddhist> {
/// use icu::calendar::Date;
/// use std::convert::TryFrom;
///
/// let date_buddhist = Date::new_buddhist_date(1970, 1, 2)
/// .expect("Failed to initialize Buddhist Date instance.");
/// let date_buddhist =
/// Date::new_buddhist_date(1970, 1, 2).expect("Failed to initialize Buddhist Date instance.");
///
/// assert_eq!(date_buddhist.year().number, 1970);
/// assert_eq!(date_buddhist.month().number, 1);
Expand All @@ -156,10 +156,7 @@ impl DateTime<Buddhist> {
/// Years are specified as BE years.
///
/// ```rust
/// use icu::calendar::{DateTime,
/// types::IsoHour,
/// types::IsoMinute,
/// types::IsoSecond};
/// use icu::calendar::{types::IsoHour, types::IsoMinute, types::IsoSecond, DateTime};
///
/// let datetime_buddhist = DateTime::new_buddhist_datetime(1970, 1, 2, 13, 1, 0)
/// .expect("Failed to initialize Buddhist DateTime instance.");
Expand Down
15 changes: 6 additions & 9 deletions components/calendar/src/coptic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
//! This module contains types and implementations for the Coptic calendar.
//!
//! ```rust
//! use icu::calendar::{Date, DateTime,
//! types::IsoHour, types::IsoMinute, types::IsoSecond,
//! coptic::Coptic};
//! use icu::calendar::{
//! coptic::Coptic, types::IsoHour, types::IsoMinute, types::IsoSecond, Date, DateTime,
//! };
//!
//! // `Date` type
//! let date_iso = Date::new_iso_date_from_integers(1970, 1, 2)
Expand Down Expand Up @@ -204,8 +204,8 @@ impl Date<Coptic> {
/// ```rust
/// use icu::calendar::Date;
///
/// let date_coptic = Date::new_coptic_date(1686, 5, 6)
/// .expect("Failed to initialize Coptic Date instance.");
/// let date_coptic =
/// Date::new_coptic_date(1686, 5, 6).expect("Failed to initialize Coptic Date instance.");
///
/// assert_eq!(date_coptic.year().number, 1686);
/// assert_eq!(date_coptic.month().number, 5);
Expand All @@ -232,10 +232,7 @@ impl DateTime<Coptic> {
/// Construct a new Coptic datetime from integers.
///
/// ```rust
/// use icu::calendar::{DateTime,
/// types::IsoHour,
/// types::IsoMinute,
/// types::IsoSecond};
/// use icu::calendar::{types::IsoHour, types::IsoMinute, types::IsoSecond, DateTime};
///
/// let datetime_coptic = DateTime::new_coptic_datetime(1686, 5, 6, 13, 1, 0)
/// .expect("Failed to initialize Coptic DateTime instance.");
Expand Down
15 changes: 6 additions & 9 deletions components/calendar/src/ethiopic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
//! This module contains types and implementations for the Ethiopic calendar.
//!
//! ```rust
//! use icu::calendar::{Date, DateTime,
//! types::IsoHour, types::IsoMinute, types::IsoSecond,
//! ethiopic::Ethiopic};
//! use icu::calendar::{
//! ethiopic::Ethiopic, types::IsoHour, types::IsoMinute, types::IsoSecond, Date, DateTime,
//! };
//!
//! // `Date` type
//! let date_iso = Date::new_iso_date_from_integers(1970, 1, 2)
Expand Down Expand Up @@ -218,8 +218,8 @@ impl Date<Ethiopic> {
/// ```rust
/// use icu::calendar::Date;
///
/// let date_ethiopic = Date::new_ethiopic_date(2014, 8, 25)
/// .expect("Failed to initialize Ethopic Date instance.");
/// let date_ethiopic =
/// Date::new_ethiopic_date(2014, 8, 25).expect("Failed to initialize Ethopic Date instance.");
///
/// assert_eq!(date_ethiopic.year().number, 2014);
/// assert_eq!(date_ethiopic.month().number, 8);
Expand Down Expand Up @@ -254,10 +254,7 @@ impl DateTime<Ethiopic> {
/// Construct a new Ethiopic datetime from integers.
///
/// ```rust
/// use icu::calendar::{DateTime,
/// types::IsoHour,
/// types::IsoMinute,
/// types::IsoSecond};
/// use icu::calendar::{types::IsoHour, types::IsoMinute, types::IsoSecond, DateTime};
///
/// let datetime_ethiopic = DateTime::new_ethiopic_datetime(2014, 8, 25, 13, 1, 0, 0)
/// .expect("Failed to initialize Ethiopic DateTime instance.");
Expand Down
27 changes: 10 additions & 17 deletions components/calendar/src/gregorian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
//! This module contains types and implementations for the Gregorian calendar.
//!
//! ```rust
//! use icu::calendar::{Date, DateTime,
//! types::IsoHour, types::IsoMinute, types::IsoSecond,
//! gregorian::Gregorian};
//! use icu::calendar::{
//! gregorian::Gregorian, types::IsoHour, types::IsoMinute, types::IsoSecond, Date, DateTime,
//! };
//!
//! // `Date` type
//! let date_iso = Date::new_iso_date_from_integers(1970, 1, 2)
Expand Down Expand Up @@ -125,17 +125,12 @@ impl Date<Gregorian> {
/// Years are specified as ISO years.
///
/// ```rust
/// use icu::calendar::{Date,
/// iso::IsoYear,
/// iso::IsoMonth,
/// iso::IsoDay};
/// use icu::calendar::{iso::IsoDay, iso::IsoMonth, iso::IsoYear, Date};
/// use std::convert::TryFrom;
///
/// let iso_year = IsoYear(1970);
/// let iso_month = IsoMonth::try_from(1)
/// .expect("Failed to initialize IsoMonth instance.");
/// let iso_day = IsoDay::try_from(2)
/// .expect("Failed to initialize IsoDay instance.");
/// let iso_month = IsoMonth::try_from(1).expect("Failed to initialize IsoMonth instance.");
/// let iso_day = IsoDay::try_from(2).expect("Failed to initialize IsoDay instance.");
///
/// // Conversion from ISO to Gregorian
/// let date_gregorian = Date::new_gregorian_date(iso_year, iso_month, iso_day)
Expand All @@ -160,13 +155,11 @@ impl DateTime<Gregorian> {
/// Years are specified as ISO years.
///
/// ```rust
/// use icu::calendar::{DateTime,
/// types::IsoHour,
/// types::IsoMinute,
/// types::IsoSecond};
/// use icu::calendar::{types::IsoHour, types::IsoMinute, types::IsoSecond, DateTime};
///
/// let datetime_gregorian = DateTime::new_gregorian_datetime_from_integers(1970, 1, 2, 13, 1, 0, 0)
/// .expect("Failed to initialize Gregorian DateTime instance.");
/// let datetime_gregorian =
/// DateTime::new_gregorian_datetime_from_integers(1970, 1, 2, 13, 1, 0, 0)
/// .expect("Failed to initialize Gregorian DateTime instance.");
///
/// assert_eq!(datetime_gregorian.date.year().number, 1970);
/// assert_eq!(datetime_gregorian.date.month().number, 1);
Expand Down
15 changes: 6 additions & 9 deletions components/calendar/src/indian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
//! This module contains types and implementations for the Indian national calendar.
//!
//! ```rust
//! use icu::calendar::{Date, DateTime,
//! types::IsoHour, types::IsoMinute, types::IsoSecond,
//! indian::Indian};
//! use icu::calendar::{
//! indian::Indian, types::IsoHour, types::IsoMinute, types::IsoSecond, Date, DateTime,
//! };
//!
//! // `Date` type
//! let date_iso = Date::new_iso_date_from_integers(1970, 1, 2)
Expand Down Expand Up @@ -187,8 +187,8 @@ impl Date<Indian> {
/// ```rust
/// use icu::calendar::Date;
///
/// let date_indian = Date::new_indian_date(1891, 10, 12)
/// .expect("Failed to initialize Indian Date instance.");
/// let date_indian =
/// Date::new_indian_date(1891, 10, 12).expect("Failed to initialize Indian Date instance.");
///
/// assert_eq!(date_indian.year().number, 1891);
/// assert_eq!(date_indian.month().number, 10);
Expand All @@ -215,10 +215,7 @@ impl DateTime<Indian> {
/// Construct a new Indian datetime from integers.
///
/// ```rust
/// use icu::calendar::{DateTime,
/// types::IsoHour,
/// types::IsoMinute,
/// types::IsoSecond};
/// use icu::calendar::{types::IsoHour, types::IsoMinute, types::IsoSecond, DateTime};
///
/// let datetime_indian = DateTime::new_indian_datetime(1891, 10, 12, 13, 1, 0)
/// .expect("Failed to initialize Indian DateTime instance.");
Expand Down
15 changes: 5 additions & 10 deletions components/calendar/src/iso.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
//! This module contains types and implementations for the ISO calendar.
//!
//! ```rust
//! use icu::calendar::{Date, DateTime,
//! types::IsoHour, types::IsoMinute, types::IsoSecond};
//! use icu::calendar::{types::IsoHour, types::IsoMinute, types::IsoSecond, Date, DateTime};
//!
//! // `Date` type
//! let date_iso = Date::new_iso_date_from_integers(1970, 1, 2)
Expand Down Expand Up @@ -331,15 +330,12 @@ impl Date<Iso> {
/// Construct a new ISO Date.
///
/// ```rust
/// use icu::calendar::{Date,
/// iso::IsoYear, iso::IsoMonth, iso::IsoDay};
/// use icu::calendar::{iso::IsoDay, iso::IsoMonth, iso::IsoYear, Date};
/// use std::convert::TryFrom;
///
/// let iso_year = IsoYear(1996);
/// let iso_month = IsoMonth::try_from(2)
/// .expect("Failed to initialize IsoMonth instance.");
/// let iso_day = IsoDay::try_from(3)
/// .expect("Failed to initialize IsoDay instance.");
/// let iso_month = IsoMonth::try_from(2).expect("Failed to initialize IsoMonth instance.");
/// let iso_day = IsoDay::try_from(3).expect("Failed to initialize IsoDay instance.");
///
/// // Creation of ISO date
/// let date_iso = Date::new_iso_date(iso_year, iso_month, iso_day)
Expand Down Expand Up @@ -389,8 +385,7 @@ impl DateTime<Iso> {
/// Construct a new ISO date from integers.
///
/// ```rust
/// use icu::calendar::{DateTime,
/// types::IsoHour, types::IsoMinute, types::IsoSecond};
/// use icu::calendar::{types::IsoHour, types::IsoMinute, types::IsoSecond, DateTime};
///
/// let datetime_iso = DateTime::new_iso_datetime_from_integers(1970, 1, 2, 13, 1, 0)
/// .expect("Failed to initialize ISO DateTime instance.");
Expand Down
15 changes: 9 additions & 6 deletions components/calendar/src/japanese.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
//! This module contains types and implementations for the Japanese calendar.
//!
//! ```rust
//! use icu::calendar::{Date, DateTime,
//! types::IsoHour, types::IsoMinute, types::IsoSecond, types::Era,
//! japanese::Japanese};
//! use icu::calendar::{
//! japanese::Japanese, types::Era, types::IsoHour, types::IsoMinute, types::IsoSecond, Date,
//! DateTime,
//! };
//! use tinystr::tinystr;
//!
//! // `icu_testdata::get_provider` contains information specifying era dates.
//! // Production code should probably use its own data provider
//! let provider = icu_testdata::get_provider();
//! let japanese_calendar = Japanese::try_new(&provider)
//! .expect("Cannot load japanese data");
//! let japanese_calendar = Japanese::try_new(&provider).expect("Cannot load japanese data");
//!
//! // `Date` type
//! let date_iso = Date::new_iso_date_from_integers(1970, 1, 2)
Expand All @@ -36,7 +36,10 @@
//! assert_eq!(datetime_japanese.date.year().number, 45);
//! assert_eq!(datetime_japanese.date.month().number, 1);
//! assert_eq!(datetime_japanese.date.day_of_month().0, 2);
//! assert_eq!(datetime_japanese.date.year().era, Era(tinystr!(16, "showa")));
//! assert_eq!(
//! datetime_japanese.date.year().era,
//! Era(tinystr!(16, "showa"))
//! );
//! assert_eq!(datetime_japanese.time.hour, IsoHour::new_unchecked(13));
//! assert_eq!(datetime_japanese.time.minute, IsoMinute::new_unchecked(1));
//! assert_eq!(datetime_japanese.time.second, IsoSecond::new_unchecked(0));
Expand Down
15 changes: 6 additions & 9 deletions components/calendar/src/julian.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
//! This module contains types and implementations for the Julian calendar.
//!
//! ```rust
//! use icu::calendar::{Date, DateTime,
//! types::IsoHour, types::IsoMinute, types::IsoSecond,
//! julian::Julian};
//! use icu::calendar::{
//! julian::Julian, types::IsoHour, types::IsoMinute, types::IsoSecond, Date, DateTime,
//! };
//!
//! // `Date` type
//! let date_iso = Date::new_iso_date_from_integers(1970, 1, 2)
Expand Down Expand Up @@ -233,8 +233,8 @@ impl Date<Julian> {
/// ```rust
/// use icu::calendar::Date;
///
/// let date_julian = Date::new_julian_date(1969, 12, 20)
/// .expect("Failed to initialize Julian Date instance.");
/// let date_julian =
/// Date::new_julian_date(1969, 12, 20).expect("Failed to initialize Julian Date instance.");
///
/// assert_eq!(date_julian.year().number, 1969);
/// assert_eq!(date_julian.month().number, 12);
Expand Down Expand Up @@ -263,10 +263,7 @@ impl DateTime<Julian> {
/// Construct a new Julian datetime from integers.
///
/// ```rust
/// use icu::calendar::{DateTime,
/// types::IsoHour,
/// types::IsoMinute,
/// types::IsoSecond};
/// use icu::calendar::{types::IsoHour, types::IsoMinute, types::IsoSecond, DateTime};
///
/// let datetime_julian = DateTime::new_julian_datetime(1969, 12, 20, 13, 1, 0)
/// .expect("Failed to initialize Julian DateTime instance.");
Expand Down
Loading