Skip to content

Commit ddfcc9a

Browse files
Makes README and lib doc 1:1 equivalent
1 parent db42770 commit ddfcc9a

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ for network parsing.
122122
zerocopy_derive::FromBytes`).
123123

124124
- **`serde`**
125-
Provides [`serde`](https://github.com/serde-rs/serde) `Serialize` and `Deserialize` impls for
125+
Provides [`serde`](https://github.com/serde-rs/serde) `Serialize` and `Deserialize` impls for
126126
the `byteorder` numeric wrappers by delegating to their underlying primitive types.
127127

128128
- **`simd`**

src/lib.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -121,18 +121,9 @@
121121
//! derives as `use zerocopy_derive::*` rather than by name (e.g., `use
122122
//! zerocopy_derive::FromBytes`).
123123
//!
124-
#![cfg_attr(
125-
feature = "serde",
126-
doc = " - **`serde`**
127-
Provides [`serde::Serialize`] and [`serde::Deserialize`] impls for the [`byteorder`] numeric
128-
wrappers by delegating to their underlying primitive types."
129-
)]
130-
#![cfg_attr(
131-
not(feature = "serde"),
132-
doc = " - **`serde`**
133-
Provides `serde` `Serialize` and `Deserialize` impls for the [`byteorder`] numeric
134-
wrappers by delegating to their underlying primitive types."
135-
)]
124+
//! - **`serde`**
125+
//! Provides [`serde`](https://github.com/serde-rs/serde) `Serialize` and `Deserialize` impls for
126+
//! the `byteorder` numeric wrappers by delegating to their underlying primitive types.
136127
//!
137128
//! - **`simd`**
138129
//! When the `simd` feature is enabled, [`FromZeros`], [`FromBytes`], and

tools/generate-readme/src/main.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,23 @@ fn main() {
3737

3838
let readme = String::from_utf8(output.stdout).unwrap();
3939

40-
// This regex is used to strip code links like:
40+
// This regex is used to strip code links without url after, like:
4141
//
4242
// /// Here is a link to [`Vec`].
4343
//
4444
// These links don't work in a Markdown file, and so we remove the `[` and `]`
4545
// characters to convert them to non-link code snippets.
46-
let body = Regex::new(r"\[(`[^`]*`)\]")
47-
.unwrap()
48-
.replace_all(&readme, |caps: &Captures| caps[1].to_string());
46+
let re = Regex::new(r"\[(`[^`]*`)\](\([^)]*\))?").unwrap();
47+
48+
let body = re.replace_all(&readme, |caps: &Captures| {
49+
if caps.get(2).is_some() {
50+
// There is a following `(...)`: keep the whole original text
51+
caps[0].to_string()
52+
} else {
53+
// No `(...)`: strip the surrounding [ ]
54+
caps[1].to_string()
55+
}
56+
});
4957

5058
println!("{}\n\n{}\n{}", COPYRIGHT_HEADER, body, DISCLAIMER_FOOTER);
5159
}

0 commit comments

Comments
 (0)