File tree Expand file tree Collapse file tree 3 files changed +16
-17
lines changed
tools/generate-readme/src Expand file tree Collapse file tree 3 files changed +16
-17
lines changed Original file line number Diff line number Diff 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 ` **
Original file line number Diff line number Diff line change 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
Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments