Skip to content

Commit 4df7524

Browse files
committed
Add documents
1 parent 645fa20 commit 4df7524

4 files changed

Lines changed: 33 additions & 2 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
name = "sync-code"
99
readme = "README.md"
1010
repository = "https://github.com/mcu-rust/sync-code"
11-
version = "0.1.0"
11+
version = "0.1.1"
1212

1313
[lib]
14+
doc = true
1415
doctest = false
1516

1617
[dependencies]

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
Synchronize code blocks between different files.
44

5+
It can replace `macros` in certain scenarios. For example, when your code isn’t duplicated many times but the design is relatively complex (e.g., involving generics), using `sync-code` instead of a `macro` will give you much better readability and easier maintenance. Features like Go-to-definition and intelligent auto-completion also work properly without using `macros`.
6+
57
# Usage
68
`Cargo.toml`:
79
```toml
@@ -20,4 +22,14 @@ fn main() {
2022

2123
```
2224

23-
See also [tests](/tests)
25+
`your_code.rs`:
26+
```rust
27+
// $sync block_name
28+
29+
fn code_you_want_to_sync() {
30+
}
31+
32+
// $sync end
33+
```
34+
35+
See also [tests](/tests/test.rs)

src/lib.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
//! Synchronize code blocks between different files.
22
//!
3+
//! It can replace `macros` in certain scenarios.
4+
//! For example, when your code isn’t duplicated many times but the design is
5+
//! relatively complex (e.g., involving generics), using `sync-code` instead
6+
//! of a `macro` will give you much better readability and easier maintenance.
7+
//! Features like Go-to-definition and intelligent auto-completion also work
8+
//! properly without using `macros`.
9+
//!
310
//! # Usage
411
//! `Cargo.toml`:
512
//! ```toml
@@ -17,6 +24,16 @@
1724
//! }
1825
//!
1926
//! ```
27+
//!
28+
//! `your_code.rs`:
29+
//! ```rust
30+
//! // $sync block_name
31+
//!
32+
//! fn code_you_want_to_sync() {
33+
//! }
34+
//!
35+
//! // $sync end
36+
//! ```
2037
2138
mod sync;
2239

tests/test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ fn test_sync_code() {
66
sync_code::Builder::new()
77
.add("tests/data1/target.txt", "tests/data1/source.txt")
88
.add("tests/data2/target.txt", "tests/data2/source.txt")
9+
// Chain dependence
910
.add("tests/data3/source2.txt", "tests/data3/source.txt")
1011
.add("tests/data3/target.txt", "tests/data3/source2.txt")
1112
.sync();

0 commit comments

Comments
 (0)