Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use backticks for the type name in generated comments #760

Merged
merged 1 commit into from
Feb 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cargo-typify/tests/outputs/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub mod error {
}
}
}
#[doc = "Fruit"]
#[doc = "`Fruit`"]
#[doc = r""]
#[doc = r" <details><summary>JSON schema</summary>"]
#[doc = r""]
Expand Down Expand Up @@ -72,7 +72,7 @@ impl ::std::convert::From<::std::collections::HashMap<::std::string::String, ::s
Self(value)
}
}
#[doc = "FruitOrVeg"]
#[doc = "`FruitOrVeg`"]
#[doc = r""]
#[doc = r" <details><summary>JSON schema</summary>"]
#[doc = r""]
Expand Down Expand Up @@ -120,7 +120,7 @@ impl ::std::convert::From<Fruit> for FruitOrVeg {
Self::Fruit(value)
}
}
#[doc = "Veggie"]
#[doc = "`Veggie`"]
#[doc = r""]
#[doc = r" <details><summary>JSON schema</summary>"]
#[doc = r""]
Expand Down
6 changes: 3 additions & 3 deletions cargo-typify/tests/outputs/custom_btree_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub mod error {
}
}
}
#[doc = "Fruit"]
#[doc = "`Fruit`"]
#[doc = r""]
#[doc = r" <details><summary>JSON schema</summary>"]
#[doc = r""]
Expand Down Expand Up @@ -73,7 +73,7 @@ impl
Self(value)
}
}
#[doc = "FruitOrVeg"]
#[doc = "`FruitOrVeg`"]
#[doc = r""]
#[doc = r" <details><summary>JSON schema</summary>"]
#[doc = r""]
Expand Down Expand Up @@ -121,7 +121,7 @@ impl ::std::convert::From<Fruit> for FruitOrVeg {
Self::Fruit(value)
}
}
#[doc = "Veggie"]
#[doc = "`Veggie`"]
#[doc = r""]
#[doc = r" <details><summary>JSON schema</summary>"]
#[doc = r""]
Expand Down
6 changes: 3 additions & 3 deletions cargo-typify/tests/outputs/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub mod error {
}
}
}
#[doc = "Fruit"]
#[doc = "`Fruit`"]
#[doc = r""]
#[doc = r" <details><summary>JSON schema</summary>"]
#[doc = r""]
Expand Down Expand Up @@ -72,7 +72,7 @@ impl ::std::convert::From<::std::collections::HashMap<::std::string::String, ::s
Self(value)
}
}
#[doc = "FruitOrVeg"]
#[doc = "`FruitOrVeg`"]
#[doc = r""]
#[doc = r" <details><summary>JSON schema</summary>"]
#[doc = r""]
Expand Down Expand Up @@ -120,7 +120,7 @@ impl ::std::convert::From<Fruit> for FruitOrVeg {
Self::Fruit(value)
}
}
#[doc = "Veggie"]
#[doc = "`Veggie`"]
#[doc = r""]
#[doc = r" <details><summary>JSON schema</summary>"]
#[doc = r""]
Expand Down
6 changes: 3 additions & 3 deletions cargo-typify/tests/outputs/multi_derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub mod error {
}
}
}
#[doc = "Fruit"]
#[doc = "`Fruit`"]
#[doc = r""]
#[doc = r" <details><summary>JSON schema</summary>"]
#[doc = r""]
Expand Down Expand Up @@ -74,7 +74,7 @@ impl ::std::convert::From<::std::collections::HashMap<::std::string::String, ::s
Self(value)
}
}
#[doc = "FruitOrVeg"]
#[doc = "`FruitOrVeg`"]
#[doc = r""]
#[doc = r" <details><summary>JSON schema</summary>"]
#[doc = r""]
Expand Down Expand Up @@ -124,7 +124,7 @@ impl ::std::convert::From<Fruit> for FruitOrVeg {
Self::Fruit(value)
}
}
#[doc = "Veggie"]
#[doc = "`Veggie`"]
#[doc = r""]
#[doc = r" <details><summary>JSON schema</summary>"]
#[doc = r""]
Expand Down
6 changes: 3 additions & 3 deletions cargo-typify/tests/outputs/no-builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub mod error {
}
}
}
#[doc = "Fruit"]
#[doc = "`Fruit`"]
#[doc = r""]
#[doc = r" <details><summary>JSON schema</summary>"]
#[doc = r""]
Expand Down Expand Up @@ -72,7 +72,7 @@ impl ::std::convert::From<::std::collections::HashMap<::std::string::String, ::s
Self(value)
}
}
#[doc = "FruitOrVeg"]
#[doc = "`FruitOrVeg`"]
#[doc = r""]
#[doc = r" <details><summary>JSON schema</summary>"]
#[doc = r""]
Expand Down Expand Up @@ -120,7 +120,7 @@ impl ::std::convert::From<Fruit> for FruitOrVeg {
Self::Fruit(value)
}
}
#[doc = "Veggie"]
#[doc = "`Veggie`"]
#[doc = r""]
#[doc = r" <details><summary>JSON schema</summary>"]
#[doc = r""]
Expand Down
4 changes: 2 additions & 2 deletions typify-impl/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1457,7 +1457,7 @@ mod tests {
let schema_json = serde_json::to_string_pretty(&original_schema).unwrap();
let schema_lines = schema_json.lines();
let expected = quote! {
#[doc = "ResultX"]
#[doc = "`ResultX`"]
///
/// <details><summary>JSON schema</summary>
///
Expand Down Expand Up @@ -1511,7 +1511,7 @@ mod tests {
type_entry.output(&type_space, &mut output);
let actual = output.into_stream();
let expected = quote! {
#[doc = "ResultX"]
#[doc = "`ResultX`"]
///
/// <details><summary>JSON schema</summary>
///
Expand Down
5 changes: 4 additions & 1 deletion typify-impl/src/type_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,10 @@ impl TypeEntry {
}

fn make_doc(name: &str, description: Option<&String>, schema: &Schema) -> TokenStream {
let desc = description.map_or(name, |desc| desc.as_str());
let desc = match description {
Some(desc) => desc,
None => &format!("`{}`", name),
};
let schema_json = serde_json::to_string_pretty(schema).unwrap();
let schema_lines = schema_json.lines();
quote! {
Expand Down
8 changes: 4 additions & 4 deletions typify-impl/tests/generator.out
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ mod types {
}
}
}
#[doc = "AllTheTraits"]
#[doc = "`AllTheTraits`"]
#[doc = r""]
#[doc = r" <details><summary>JSON schema</summary>"]
#[doc = r""]
Expand Down Expand Up @@ -69,7 +69,7 @@ mod types {
Default::default()
}
}
#[doc = "CompoundType"]
#[doc = "`CompoundType`"]
#[doc = r""]
#[doc = r" <details><summary>JSON schema</summary>"]
#[doc = r""]
Expand Down Expand Up @@ -109,7 +109,7 @@ mod types {
Default::default()
}
}
#[doc = "Pair"]
#[doc = "`Pair`"]
#[doc = r""]
#[doc = r" <details><summary>JSON schema</summary>"]
#[doc = r""]
Expand Down Expand Up @@ -155,7 +155,7 @@ mod types {
Default::default()
}
}
#[doc = "StringEnum"]
#[doc = "`StringEnum`"]
#[doc = r""]
#[doc = r" <details><summary>JSON schema</summary>"]
#[doc = r""]
Expand Down
Loading