Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f579f65

Browse files
Merge pull request #26 from echeran/add-2.0.0-docs
Replace 2.0 beta docs with final 2.0 docs
2 parents e7b194b + 6f13fef commit f579f65

File tree

9 files changed

+45
-41
lines changed

9 files changed

+45
-41
lines changed

astro.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import starlightLinksValidator from 'starlight-links-validator'
66

77
// !! UPDATE LATEST VERSION HERE !!
88
// format semver with underscores to make it look like a semver would in a URL
9-
var latest_display_name = 'Version 2.0 Beta';
10-
var latest_dir_name = '2_0_beta';
9+
var latest_display_name = 'Version 2.0';
10+
var latest_dir_name = '2_0';
1111

1212
// https://astro.build/config
1313
export default defineConfig({

src/content/docs/2_0_beta/quickstart.md renamed to src/content/docs/2_0/quickstart.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Introduction to ICU4X for Rust
2+
title: Quickstart
33
---
44

55

@@ -111,7 +111,7 @@ which is exposed through constructors such as `try_new`.
111111
```rust
112112
use icu::locale::{Locale, locale};
113113
use icu::calendar::Date;
114-
use icu::datetime::{DateTimeFormatter, Length, fieldsets::YMD};
114+
use icu::datetime::{DateTimeFormatter, fieldsets::YMD};
115115

116116
const LOCALE: Locale = locale!("ja"); // let's try some other language
117117

@@ -157,7 +157,7 @@ The way `ICU4X` handles data is one of its novelties, aimed at making the data m
157157

158158
`ICU4X` by default contains data for a a wide range of CLDR locales[^1], meaning that for most languages, the constructors can be considered infallible and you can `expect` or `unwrap` them, as we did above.
159159

160-
However, shipping the library with all locales will have a size impact on your binary. It also requires you to update your binary whenever CLDR data changes, which happens twice a year. To learn how to solve these problems, see our [data management](/2_0_beta/tutorials/data-management) tutorial.
160+
However, shipping the library with all locales will have a size impact on your binary. It also requires you to update your binary whenever CLDR data changes, which happens twice a year. To learn how to solve these problems, see our [data management](/2_0/tutorials/data-management) tutorial.
161161

162162
[^1]: All locales with coverage level `basic`, `moderate`, or `modern` in [`CLDR`](https://github.com/unicode-org/cldr-json/blob/main/cldr-json/cldr-core/coverageLevels.json)
163163

@@ -167,7 +167,7 @@ This concludes this introduction tutorial. With the help of `DateTimeFormat`, `L
167167

168168
Internationalization is a broad domain and there are many more components in `ICU4X`.
169169

170-
Next, learn how to [generate optimized data for your binary](/2_0_beta/tutorials/data-management), [configure your Cargo.toml file](/2_0_beta/tutorials/cargo), or continue exploring by reading [the docs](https://docs.rs/icu/2.0.0-beta2/).
170+
Next, learn how to [generate optimized data for your binary](/2_0/tutorials/data-management), [configure your Cargo.toml file](/2_0/tutorials/cargo), or continue exploring by reading [the docs](https://docs.rs/icu/2.0.0/).
171171

172172

173173

src/content/docs/2_0_beta/tutorials/cargo.md renamed to src/content/docs/2_0/tutorials/cargo.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ The most basic Cargo.toml to get you off the ground is the following:
1212

1313
```toml
1414
[dependencies]
15-
icu = "2.0.0-dev"
15+
icu = "2.0.0"
1616
```
1717

1818
In your main.rs, you can use all stable ICU4X components for the recommended set of locales, which get compiled into the library.
1919

20-
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/main/tutorials/./crates/default)
20+
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/release%2F2.0/tutorials/./crates/default)
2121

2222
## Cargo.toml with custom compiled data
2323

@@ -29,72 +29,72 @@ icu4x-datagen --format baked --markers all --locales ru --out baked_data
2929
ICU4X_DATA_DIR=$(pwd)/baked_data cargo build --release
3030
```
3131

32-
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/main/tutorials/./crates/custom_compiled)
32+
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/release%2F2.0/tutorials/./crates/custom_compiled)
3333

3434
## Cargo.toml with experimental modules
3535

3636
Experimental modules are published in a separate `icu_experimental` crate:
3737

3838
```toml
3939
[dependencies]
40-
icu = { version = "2.0.0-dev", features = ["experimental"] }
40+
icu = { version = "2.0.0", features = ["experimental"] }
4141
```
4242

4343
In your main.rs, you can now use e.g. the `icu_experimental::displaynames` module.
4444

45-
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/main/tutorials/./crates/experimental)
45+
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/release%2F2.0/tutorials/./crates/experimental)
4646

4747
## Cargo.toml with Buffer Provider
4848

4949
If you wish to generate your own data in blob format and pass it into ICU4X, enable the "serde" Cargo feature as follows:
5050

5151
```toml
5252
[dependencies]
53-
icu = { version = "2.0.0-dev", features = ["serde"] }
54-
icu_provider_blob = {version = "2.0.0-dev", features = ["alloc"] }
53+
icu = { version = "2.0.0", features = ["serde"] }
54+
icu_provider_blob = {version = "2.0.0", features = ["alloc"] }
5555
```
5656

57-
To learn about building ICU4X data, including whether to check in the data blob file to your repository, see [data-management.md](/2_0_beta/tutorials/data-management).
57+
To learn about building ICU4X data, including whether to check in the data blob file to your repository, see [data-management.md](/2_0/tutorials/data-management).
5858

59-
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/main/tutorials/./crates/buffer)
59+
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/release%2F2.0/tutorials/./crates/buffer)
6060

6161
## Cargo.toml with `Sync`
6262

6363
If you wish to share ICU4X objects between threads, you must enable the `"sync"` Cargo feature:
6464

6565
```toml
6666
[dependencies]
67-
icu = { version = "2.0.0-dev", features = ["sync"] }
67+
icu = { version = "2.0.0", features = ["sync"] }
6868
```
6969

7070
You can now use most ICU4X types when `Send + Sync` are required, such as when sharing across threads.
7171

72-
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/main/tutorials/./crates/sync)
72+
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/release%2F2.0/tutorials/./crates/sync)
7373

7474
## Cargo.toml with `build.rs` data generation
7575

7676
If you wish to use data generation in a `build.rs` script, you need to manually include the data and any dependencies (the `ICU4X_DATA_DIR` variable won't work as ICU4X cannot access your build script output).
7777

7878
```toml
7979
[dependencies]
80-
icu = { version = "2.0.0-dev", default-features = false } # turn off compiled_data
81-
icu_provider = "2.0.0-dev" # for databake
82-
icu_provider_baked = "2.0.0-dev" # for databake
80+
icu = { version = "2.0.0", default-features = false } # turn off compiled_data
81+
icu_provider = "2.0.0" # for databake
82+
icu_provider_baked = "2.0.0" # for databake
8383
zerovec = "0.9" # for databake
8484

8585
# for build.rs:
8686
[build-dependencies]
87-
icu = "2.0.0-dev"
88-
icu_provider_export = "2.0.0-dev"
89-
icu_provider_source = "2.0.0-dev"
87+
icu = "2.0.0"
88+
icu_provider_export = "2.0.0"
89+
icu_provider_source = "2.0.0"
9090
```
9191

9292
This example has an additional section for auto-generating the data in build.rs. In your build.rs, invoke the ICU4X Datagen API with the set of markers you require. Don't worry; if using databake, you will get a compiler error if you don't specify enough markers.
9393

9494
The build.rs approach has several downsides and should only be used if Cargo is the only build system you can use, and you cannot check in your data:
9595
* The build script with the whole of `icu_provider_source` in it is slow to build
9696
* If you're using networking features of `icu_provider_source` (behind the `networking` Cargo feature), the build script will access the network
97-
* Using the data requires ICU4X's [`_unstable`](https://docs.rs/icu_provider/2.0.0-beta2/icu_provider/constructors/index.html) APIs with a custom data provider, and that `icu_provider_source` is the same *minor* version as the `icu` crate.
97+
* Using the data requires ICU4X's [`_unstable`](https://docs.rs/icu_provider/2.0.0/icu_provider/constructors/index.html) APIs with a custom data provider, and that `icu_provider_source` is the same *minor* version as the `icu` crate.
9898
* `build.rs` output is not written to the console so it will appear that the build is hanging
9999

100-
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/main/tutorials/./crates/baked)
100+
[« Fully Working Example »](https://github.com/unicode-org/icu4x/tree/release%2F2.0/tutorials/./crates/baked)

src/content/docs/2_0_beta/tutorials/data-management.md renamed to src/content/docs/2_0/tutorials/data-management.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ If you're happy shipping your app with the recommended set of locales included i
1010

1111
## 1. Prerequisites
1212

13-
This tutorial assumes you have finished the [introductory tutorial](/2_0_beta/quickstart) and continues where that tutorial left off. In particular, you should still have the latest version of code for `myapp`.
13+
This tutorial assumes you have finished the [introductory tutorial](/2_0/quickstart) and continues where that tutorial left off. In particular, you should still have the latest version of code for `myapp`.
1414

1515
## 2. Generating data
1616

@@ -100,7 +100,7 @@ We can include the generate code with the `include!` macro. The `impl_data_provi
100100
extern crate alloc; // required as my-data is written for #[no_std]
101101
use icu::locale::{locale, Locale};
102102
use icu::calendar::Date;
103-
use icu::datetime::{DateTimeFormatter, Length};
103+
use icu::datetime::{DateTimeFormatter, fieldsets::YMD};
104104

105105
const LOCALE: Locale = locale!("ja");
106106

@@ -111,8 +111,12 @@ impl_data_provider!(MyDataProvider);
111111
fn main() {
112112
let baked_provider = MyDataProvider;
113113

114-
let dtf = DateTimeFormatter::try_new_unstable(&baked_provider, &LOCALE.into(), Length::Medium.into())
115-
.expect("ja data should be available");
114+
let dtf = DateTimeFormatter::try_new_unstable(
115+
&baked_provider,
116+
LOCALE.into(),
117+
YMD::medium()
118+
)
119+
.expect("ja data should be available");
116120

117121
let date = Date::try_new_iso(2020, 10, 14)
118122
.expect("date should be valid");
@@ -149,14 +153,14 @@ This will generate a `my_data_blob.postcard` file containing the serialized data
149153

150154
Unlike `BakedDataProvider`, `BlobDataProvider` (and `FsDataProvider`) does not perform locale fallbacking. For example, if `en-US` is requested but only `en` data is available, then the data request will fail. To enable fallback, we can wrap the provider in a `LocaleFallbackProvider`.
151155

152-
Note that fallback comes at a cost, as fallbacking code and data has to be included and executed on every request. If you don't need fallback (disclaimer: you probably do), you can use the `BlobDataProvider` directly (for baked data, see [`Options::skip_internal_fallback`](https://docs.rs/icu_provider_baked/2.0.0-beta2/icu_provider_baked/export/struct.Options.html)).
156+
Note that fallback comes at a cost, as fallbacking code and data has to be included and executed on every request. If you don't need fallback (disclaimer: you probably do), you can use the `BlobDataProvider` directly (for baked data, see [`Options::skip_internal_fallback`](https://docs.rs/icu_provider_baked/2.0.0/icu_provider_baked/export/struct.Options.html)).
153157

154158
We can then use the provider in our code:
155159

156160
```rust
157161
use icu::locale::{locale, Locale, fallback::LocaleFallbacker};
158162
use icu::calendar::Date;
159-
use icu::datetime::{DateTimeFormatter, Length, fieldsets::YMD};
163+
use icu::datetime::{DateTimeFormatter, fieldsets::YMD};
160164
use icu_provider_adapters::fallback::LocaleFallbackProvider;
161165
use icu_provider_blob::BlobDataProvider;
162166

@@ -209,7 +213,7 @@ We can instead use `FixedCalendarDateTimeFormatter<Gregorian>`, which only suppo
209213
```rust
210214
use icu::locale::{locale, Locale, fallback::LocaleFallbacker};
211215
use icu::calendar::{Date, Gregorian};
212-
use icu::datetime::{FixedCalendarDateTimeFormatter, fieldsets::YMD, Length};
216+
use icu::datetime::{FixedCalendarDateTimeFormatter, fieldsets::YMD};
213217
use icu_provider_adapters::fallback::LocaleFallbackProvider;
214218
use icu_provider_blob::BlobDataProvider;
215219

@@ -256,4 +260,4 @@ We have learned how to generate data and load it into our programs, optimize dat
256260

257261
For a deeper dive into configuring your data providers in code, see [data-provider-runtime.md].
258262

259-
You can learn more about datagen, including the Rust API which we have not used in this tutorial, by reading [the docs](https://docs.rs/icu_provider_export/2.0.0-beta2/).
263+
You can learn more about datagen, including the Rust API which we have not used in this tutorial, by reading [the docs](https://docs.rs/icu_provider_export/2.0.0/).

src/content/docs/2_0_beta/tutorials/data-provider-runtime.md renamed to src/content/docs/2_0/tutorials/data-provider-runtime.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ struct CacheKey<'a>(DataMarkerInfo, Cow<'a, DataLocale>);
101101
struct CacheKeyWrap(CacheKey<'static>);
102102

103103
// This impl enables a borrowed DataLocale to be used during cache retrieval.
104-
impl<'a> Borrow<CacheKey<'a>> for lru::KeyRef<CacheKeyWrap> {
104+
impl<'a> Borrow<CacheKey<'a>> for CacheKeyWrap {
105105
fn borrow(&self) -> &CacheKey<'a> {
106106
&Borrow::<CacheKeyWrap>::borrow(self).0
107107
}
File renamed without changes.

src/content/docs/2_0_beta/tutorials/date-picker.md renamed to src/content/docs/2_0/tutorials/date-picker.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ Now we can write the Rust code:
148148
```rust
149149
// At the top of the file:
150150
use icu::calendar::{Date, Iso};
151-
use icu::datetime::{DateTimeFormatter, Length, fieldsets::YMD};
151+
use icu::datetime::{DateTimeFormatter, fieldsets::YMD};
152152

153-
let locale = icu::locale::Locale::default(); // to make this example compile
153+
let locale = icu::locale::Locale::UNKNOWN; // to make this example compile
154154

155155
/// Helper function to create an ICU4X DateTime for the current local time:
156156
fn get_current_date() -> Date<Iso> {
@@ -228,7 +228,7 @@ Now we would also like to format the current time.
228228

229229
### Rust Part 4
230230

231-
Use the API documentation for [`icu::time::DateTime`](https://docs.rs/icu/2.0.0-beta2/icu/timezone/struct.DateTime.html) and [`icu::datetime::DateTimeFormatter`](https://docs.rs/icu/2.0.0-beta2/icu/datetime/struct.DateTimeFormatter.html) to expand your app to format both date and time.
231+
Use the API documentation for [`icu::time::DateTime`](https://docs.rs/icu/2.0.0/icu/timezone/struct.DateTime.html) and [`icu::datetime::DateTimeFormatter`](https://docs.rs/icu/2.0.0/icu/datetime/struct.DateTimeFormatter.html) to expand your app to format both date and time.
232232

233233
Hint: You can use `Default::default()` for the `DateTimeFormatterOptions` argument.
234234

src/content/docs/2_0_beta/tutorials/using-from-cpp.md renamed to src/content/docs/2_0/tutorials/using-from-cpp.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ICU4X's core functionality is completely available from C++, with headers genera
88

99
Typically C++ users can build ICU4X by building the `icu_capi` Rust crate, and linking the resultant static library to their C++ application. This crate contains all of the relevant [Diplomat]-generated `extern "C"` declarations, as well as an idiomatic C++ wrapper using these functions.
1010

11-
Using ICU4X in C++ is best demonstrated via the [examples](https://github.com/unicode-org/icu4x/tree/main/tutorials/cpp). For example, [here's an example showing off decimal formatting in ICU4X](https://github.com/unicode-org/icu4x/tree/main/tutorials/cpp/fixeddecimal.cpp), built with [this Makefile](https://github.com/unicode-org/icu4x/tree/main/tutorials/cpp/Makefile).
11+
Using ICU4X in C++ is best demonstrated via the [examples](https://github.com/unicode-org/icu4x/tree/release%2F2.0/tutorials/cpp). For example, [here's an example showing off decimal formatting in ICU4X](https://github.com/unicode-org/icu4x/tree/release%2F2.0/tutorials/cpp/fixeddecimal.cpp), built with [this Makefile](https://github.com/unicode-org/icu4x/tree/release%2F2.0/tutorials/cpp/Makefile).
1212

1313
_We are still working on improving the user experience of using ICU4X from other languages. As such, this tutorial may be a bit sparse, but we are happy to answer questions on our [discussions forum] and help you out_
1414

@@ -30,7 +30,7 @@ resolver = "2"
3030
path = "unused"
3131

3232
[dependencies]
33-
icu_capi = { version = "2.0.0-dev", default-features = false, features = [] }
33+
icu_capi = { version = "2.0.0", default-features = false, features = [] }
3434
```
3535

3636
Some of the keys are required by the parser, but won't be used by us.
@@ -47,7 +47,7 @@ Some of the keys are required by the parser, but won't be used by us.
4747
You can now set features by updating the `features` key in `Cargo.toml`:
4848

4949
```toml
50-
icu_capi = { version = "2.0.0-dev", default-features = false, features = ["default", "buffer_provider"] }
50+
icu_capi = { version = "2.0.0", default-features = false, features = ["default", "buffer_provider"] }
5151

5252
```
5353

@@ -124,7 +124,7 @@ C++ versions beyond C++17 are supported, as are other C++ compilers.
124124
Users wishing to use ICU4X on a `no_std` platform will need to provide an allocator and a panic hook in order to build a linkable library. The `icu_capi` crate can provide a looping panic handler, and a `malloc`-backed allocator, under the `looping_panic_handler` and `libc_alloc` features, respectively.
125125

126126
```toml
127-
icu_capi = { version = "2.0.0-dev", default-features = false, features = ["default_components", "buffer_provider", "looping_panic_handler", "libc_alloc"] }
127+
icu_capi = { version = "2.0.0", default-features = false, features = ["default_components", "buffer_provider", "looping_panic_handler", "libc_alloc"] }
128128

129129
```
130130

File renamed without changes.

0 commit comments

Comments
 (0)