From 3502cf6378aefc4c357f80926d2d0579edc8710e Mon Sep 17 00:00:00 2001 From: Mumulhl Date: Sat, 17 Aug 2024 11:48:27 +0800 Subject: [PATCH] docs: move usage to example --- README.md | 53 +---------------------------------------- README_CN.md | 53 +---------------------------------------- example/README.md | 56 ++++++++++++++++++++++++++++++++++++++++++++ example/README_CN.md | 56 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 114 insertions(+), 104 deletions(-) create mode 100644 example/README.md create mode 100644 example/README_CN.md diff --git a/README.md b/README.md index fdc76ac..b4db0e8 100644 --- a/README.md +++ b/README.md @@ -23,55 +23,4 @@ dart pub add dict_reader ## Usage -### Read Data Directly - -```dart -import 'package:dict_reader/dict_reader.dart'; - -void main() async { - final dictReader = DictReader("MDX FILE PATH"); - await dictReader.init(); - - await for (final (keyText, data) in dictReader.read(true)) { - print("$keyText, $data"); - } -} -``` - -### Read Data Offset, Read Data Later - -```dart -import 'package:dict_reader/dict_reader.dart'; - -void main() async { - final dictReader = DictReader("MDX FILE PATH"); - await dictReader.init(); - - final map = {}; - await for (final (keyText, offset) in dictReader.read()) { - map[keyText] = offset; - } - - final offset = map["go"]; - print(await dictReader.readOne(offset!.$1, offset.$2, offset.$3, offset.$4)); -} -``` - -### Read Data After Stored Data Offset - -```dart -import 'package:dict_reader/dict_reader.dart'; - -// ... - -void main() async { - // ... - - final dictReader = DictReader("MDX FILE PATH"); - // Pass false to reduce initialization time - await dictReader.init(false); - - final offset = map["go"]; - print(await dictReader.readOne(offset!.$1, offset.$2, offset.$3, offset.$4)); -} -``` +See [Example](./example/README.md). diff --git a/README_CN.md b/README_CN.md index 464564c..8e1ac10 100644 --- a/README_CN.md +++ b/README_CN.md @@ -23,55 +23,4 @@ dart pub add dict_reader ## 使用 -### 直接读取数据 - -```dart -import 'package:dict_reader/dict_reader.dart'; - -void main() async { - final dictReader = DictReader("MDX FILE PATH"); - await dictReader.init(); - - await for (final (keyText, data) in dictReader.read(true)) { - print("$keyText, $data"); - } -} -``` - -### 读取数据 offset,之后读取数据 - -```dart -import 'package:dict_reader/dict_reader.dart'; - -void main() async { - final dictReader = DictReader("MDX FILE PATH"); - await dictReader.init(); - - final map = {}; - await for (final (keyText, offset) in dictReader.read()) { - map[keyText] = offset; - } - - final offset = map["go"]; - print(await dictReader.readOne(offset!.$1, offset.$2, offset.$3, offset.$4)); -} -``` - -### 当已保存数据 offset,读取数据 - -```dart -import 'package:dict_reader/dict_reader.dart'; - -// ... - -void main() async { - // ... - - final dictReader = DictReader("MDX FILE PATH"); - // Pass false to reduce initialization time - await dictReader.init(false); - - final offset = map["go"]; - print(await dictReader.readOne(offset!.$1, offset.$2, offset.$3, offset.$4)); -} -``` +见 [示例](./example/README_CN.md)。 diff --git a/example/README.md b/example/README.md new file mode 100644 index 0000000..f0e20f7 --- /dev/null +++ b/example/README.md @@ -0,0 +1,56 @@ +# Example + +English | [中文](./README_CN.md) + +## Read Data Directly + +```dart +import 'package:dict_reader/dict_reader.dart'; + +void main() async { + final dictReader = DictReader("MDX FILE PATH"); + await dictReader.init(); + + await for (final (keyText, data) in dictReader.read(true)) { + print("$keyText, $data"); + } +} +``` + +## Read Data Offset, Read Data Later + +```dart +import 'package:dict_reader/dict_reader.dart'; + +void main() async { + final dictReader = DictReader("MDX FILE PATH"); + await dictReader.init(); + + final map = {}; + await for (final (keyText, offset) in dictReader.read()) { + map[keyText] = offset; + } + + final offset = map["go"]; + print(await dictReader.readOne(offset!.$1, offset.$2, offset.$3, offset.$4)); +} +``` + +## Read Data After Stored Data Offset + +```dart +import 'package:dict_reader/dict_reader.dart'; + +// ... + +void main() async { + // ... + + final dictReader = DictReader("MDX FILE PATH"); + // Pass false to reduce initialization time + await dictReader.init(false); + + final offset = map["go"]; + print(await dictReader.readOne(offset!.$1, offset.$2, offset.$3, offset.$4)); +} +``` diff --git a/example/README_CN.md b/example/README_CN.md new file mode 100644 index 0000000..5577368 --- /dev/null +++ b/example/README_CN.md @@ -0,0 +1,56 @@ +# 示例 + +[English](./README.md) | 中文 + +## 直接读取数据 + +```dart +import 'package:dict_reader/dict_reader.dart'; + +void main() async { + final dictReader = DictReader("MDX FILE PATH"); + await dictReader.init(); + + await for (final (keyText, data) in dictReader.read(true)) { + print("$keyText, $data"); + } +} +``` + +## 读取数据 offset,之后读取数据 + +```dart +import 'package:dict_reader/dict_reader.dart'; + +void main() async { + final dictReader = DictReader("MDX FILE PATH"); + await dictReader.init(); + + final map = {}; + await for (final (keyText, offset) in dictReader.read()) { + map[keyText] = offset; + } + + final offset = map["go"]; + print(await dictReader.readOne(offset!.$1, offset.$2, offset.$3, offset.$4)); +} +``` + +## 当已保存数据 offset,读取数据 + +```dart +import 'package:dict_reader/dict_reader.dart'; + +// ... + +void main() async { + // ... + + final dictReader = DictReader("MDX FILE PATH"); + // Pass false to reduce initialization time + await dictReader.init(false); + + final offset = map["go"]; + print(await dictReader.readOne(offset!.$1, offset.$2, offset.$3, offset.$4)); +} +```