Add a ruff_textwrap crate (#4731)

This commit is contained in:
Charlie Marsh 2023-05-31 12:35:23 -04:00 committed by GitHub
parent 35cd57d0fc
commit 399eb84d5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 397 additions and 68 deletions

View file

@ -10,8 +10,9 @@ proc-macro = true
doctest = false
[dependencies]
ruff_textwrap = { path = "../ruff_textwrap" }
proc-macro2 = { workspace = true }
quote = { workspace = true }
syn = { workspace = true, features = ["derive", "parsing", "extra-traits", "full"] }
textwrap = { workspace = true }
itertools = { workspace = true }

View file

@ -1,3 +1,5 @@
use ruff_textwrap::dedent;
use quote::{quote, quote_spanned};
use syn::parse::{Parse, ParseStream};
use syn::spanned::Spanned;
@ -126,7 +128,7 @@ fn handle_option(
docs: Vec<&Attribute>,
) -> syn::Result<proc_macro2::TokenStream> {
// Convert the list of `doc` attributes into a single string.
let doc = textwrap::dedent(
let doc = dedent(
&docs
.into_iter()
.map(parse_doc)
@ -179,7 +181,7 @@ impl Parse for FieldAttributes {
Ok(Self {
default,
value_type,
example: textwrap::dedent(&example).trim_matches('\n').to_string(),
example: dedent(&example).trim_matches('\n').to_string(),
})
}
}