Repository: oxidecomputer/typify
Pull request #476 (2024-01-06 09:00:08)

add docs to generated mods


Patch:
diff --git a/typify-impl/src/output.rs b/typify-impl/src/output.rs
index cfa57ac..7527a90 100644
--- a/typify-impl/src/output.rs
+++ b/typify-impl/src/output.rs
@@ -1,4 +1,4 @@
-// Copyright 2022 Oxide Computer Company
+// Copyright 2024 Oxide Computer Company
 
 use std::collections::BTreeMap;
 
@@ -48,16 +48,19 @@ impl OutputSpace {
                 #items
             },
             OutputSpaceMod::Builder => quote! {
+                /// Types for composing complex structures.
                 pub mod builder {
                     #items
                 }
             },
             OutputSpaceMod::Defaults => quote! {
+                /// Generation of default values for serde.
                 pub mod defaults {
                     #items
                 }
             },
             OutputSpaceMod::Error => quote! {
+                /// Error types.
                 pub mod error {
                     #items
                 }


Test patch:
diff --git a/cargo-typify/tests/outputs/builder.rs b/cargo-typify/tests/outputs/builder.rs
index dd7ab50..93992c1 100644
--- a/cargo-typify/tests/outputs/builder.rs
+++ b/cargo-typify/tests/outputs/builder.rs
@@ -5,6 +5,7 @@
 
 use serde::{Deserialize, Serialize};
 
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);
@@ -198,6 +199,7 @@ impl Veggies {
         Default::default()
     }
 }
+#[doc = r" Types for composing complex structures."]
 pub mod builder {
     #[derive(Clone, Debug)]
     pub struct Veggie {
diff --git a/cargo-typify/tests/outputs/derive.rs b/cargo-typify/tests/outputs/derive.rs
index a09cb67..98cd6b1 100644
--- a/cargo-typify/tests/outputs/derive.rs
+++ b/cargo-typify/tests/outputs/derive.rs
@@ -5,6 +5,7 @@
 
 use serde::{Deserialize, Serialize};
 
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);
diff --git a/cargo-typify/tests/outputs/multi_derive.rs b/cargo-typify/tests/outputs/multi_derive.rs
index 8d61cbd..0ee6e25 100644
--- a/cargo-typify/tests/outputs/multi_derive.rs
+++ b/cargo-typify/tests/outputs/multi_derive.rs
@@ -5,6 +5,7 @@
 
 use serde::{Deserialize, Serialize};
 
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);
diff --git a/cargo-typify/tests/outputs/no-builder.rs b/cargo-typify/tests/outputs/no-builder.rs
index e60307b..fc57083 100644
--- a/cargo-typify/tests/outputs/no-builder.rs
+++ b/cargo-typify/tests/outputs/no-builder.rs
@@ -5,6 +5,7 @@
 
 use serde::{Deserialize, Serialize};
 
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);
diff --git a/typify-impl/tests/generator.out b/typify-impl/tests/generator.out
index a318722..344c1b5 100644
--- a/typify-impl/tests/generator.out
+++ b/typify-impl/tests/generator.out
@@ -1,4 +1,5 @@
 mod types {
+    #[doc = r" Error types."]
     pub mod error {
         #[doc = r" Error from a TryFrom or FromStr implementation."]
         pub struct ConversionError(std::borrow::Cow<'static, str>);
@@ -203,6 +204,7 @@ mod types {
             value.parse()
         }
     }
+    #[doc = r" Types for composing complex structures."]
     pub mod builder {
         #[derive(Clone, Debug)]
         pub struct AllTheTraits {
@@ -343,6 +345,7 @@ mod types {
             }
         }
     }
+    #[doc = r" Generation of default values for serde."]
     pub mod defaults {
         pub(super) fn pair_a() -> super::StringEnum {
             super::StringEnum::One
diff --git a/typify-impl/tests/github.out b/typify-impl/tests/github.out
index 5a74e83..58aeaff 100644
--- a/typify-impl/tests/github.out
+++ b/typify-impl/tests/github.out
@@ -1,3 +1,4 @@
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);
@@ -90191,6 +90192,7 @@ impl std::convert::TryFrom<String> for WorkflowStepInProgressStatus {
         value.parse()
     }
 }
+#[doc = r" Generation of default values for serde."]
 pub mod defaults {
     pub(super) fn default_bool<const V: bool>() -> bool {
         V
diff --git a/typify-impl/tests/vega.out b/typify-impl/tests/vega.out
index dca8637..0e8f457 100644
--- a/typify-impl/tests/vega.out
+++ b/typify-impl/tests/vega.out
@@ -1,3 +1,4 @@
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);
@@ -109930,6 +109931,7 @@ impl std::convert::TryFrom<String> for WordcloudTransformType {
         value.parse()
     }
 }
+#[doc = r" Generation of default values for serde."]
 pub mod defaults {
     pub(super) fn default_bool<const V: bool>() -> bool {
         V
diff --git a/typify/tests/schemas/arrays-and-tuples.rs b/typify/tests/schemas/arrays-and-tuples.rs
index 6417df8..78052e8 100644
--- a/typify/tests/schemas/arrays-and-tuples.rs
+++ b/typify/tests/schemas/arrays-and-tuples.rs
@@ -1,5 +1,6 @@
 #[allow(unused_imports)]
 use serde::{Deserialize, Serialize};
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);
diff --git a/typify/tests/schemas/deny-list.rs b/typify/tests/schemas/deny-list.rs
index c991887..966f562 100644
--- a/typify/tests/schemas/deny-list.rs
+++ b/typify/tests/schemas/deny-list.rs
@@ -1,5 +1,6 @@
 #[allow(unused_imports)]
 use serde::{Deserialize, Serialize};
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);
diff --git a/typify/tests/schemas/extraneous-enum.rs b/typify/tests/schemas/extraneous-enum.rs
index 00e077a..65c46a0 100644
--- a/typify/tests/schemas/extraneous-enum.rs
+++ b/typify/tests/schemas/extraneous-enum.rs
@@ -1,5 +1,6 @@
 #[allow(unused_imports)]
 use serde::{Deserialize, Serialize};
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);
diff --git a/typify/tests/schemas/id-or-name.rs b/typify/tests/schemas/id-or-name.rs
index e1f293b..c7fb933 100644
--- a/typify/tests/schemas/id-or-name.rs
+++ b/typify/tests/schemas/id-or-name.rs
@@ -1,5 +1,6 @@
 #[allow(unused_imports)]
 use serde::{Deserialize, Serialize};
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);
diff --git a/typify/tests/schemas/maps.rs b/typify/tests/schemas/maps.rs
index a7eb7e2..c3010e1 100644
--- a/typify/tests/schemas/maps.rs
+++ b/typify/tests/schemas/maps.rs
@@ -1,5 +1,6 @@
 #[allow(unused_imports)]
 use serde::{Deserialize, Serialize};
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);
diff --git a/typify/tests/schemas/merged-schemas.rs b/typify/tests/schemas/merged-schemas.rs
index 1508f8d..e90442c 100644
--- a/typify/tests/schemas/merged-schemas.rs
+++ b/typify/tests/schemas/merged-schemas.rs
@@ -1,5 +1,6 @@
 #[allow(unused_imports)]
 use serde::{Deserialize, Serialize};
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);
diff --git a/typify/tests/schemas/multiple-instance-types.rs b/typify/tests/schemas/multiple-instance-types.rs
index 337f400..c2c1764 100644
--- a/typify/tests/schemas/multiple-instance-types.rs
+++ b/typify/tests/schemas/multiple-instance-types.rs
@@ -1,5 +1,6 @@
 #[allow(unused_imports)]
 use serde::{Deserialize, Serialize};
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);
diff --git a/typify/tests/schemas/noisy-types.rs b/typify/tests/schemas/noisy-types.rs
index 713c5b4..b433026 100644
--- a/typify/tests/schemas/noisy-types.rs
+++ b/typify/tests/schemas/noisy-types.rs
@@ -1,5 +1,6 @@
 #[allow(unused_imports)]
 use serde::{Deserialize, Serialize};
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);
diff --git a/typify/tests/schemas/reflexive.rs b/typify/tests/schemas/reflexive.rs
index 27696ac..167cc03 100644
--- a/typify/tests/schemas/reflexive.rs
+++ b/typify/tests/schemas/reflexive.rs
@@ -1,5 +1,6 @@
 #[allow(unused_imports)]
 use serde::{Deserialize, Serialize};
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);
diff --git a/typify/tests/schemas/simple-types.rs b/typify/tests/schemas/simple-types.rs
index 87e90d5..3af58a3 100644
--- a/typify/tests/schemas/simple-types.rs
+++ b/typify/tests/schemas/simple-types.rs
@@ -1,5 +1,6 @@
 #[allow(unused_imports)]
 use serde::{Deserialize, Serialize};
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);
diff --git a/typify/tests/schemas/string-enum-with-default.rs b/typify/tests/schemas/string-enum-with-default.rs
index 4d040f8..9200ab0 100644
--- a/typify/tests/schemas/string-enum-with-default.rs
+++ b/typify/tests/schemas/string-enum-with-default.rs
@@ -1,5 +1,6 @@
 #[allow(unused_imports)]
 use serde::{Deserialize, Serialize};
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);
diff --git a/typify/tests/schemas/type-with-modified-generation.rs b/typify/tests/schemas/type-with-modified-generation.rs
index b423325..4927764 100644
--- a/typify/tests/schemas/type-with-modified-generation.rs
+++ b/typify/tests/schemas/type-with-modified-generation.rs
@@ -1,5 +1,6 @@
 #[allow(unused_imports)]
 use serde::{Deserialize, Serialize};
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);
diff --git a/typify/tests/schemas/types-with-defaults.rs b/typify/tests/schemas/types-with-defaults.rs
index 3ae3d24..6ea59fa 100644
--- a/typify/tests/schemas/types-with-defaults.rs
+++ b/typify/tests/schemas/types-with-defaults.rs
@@ -1,5 +1,6 @@
 #[allow(unused_imports)]
 use serde::{Deserialize, Serialize};
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);
@@ -71,6 +72,7 @@ impl From<&TestBed> for TestBed {
         value.clone()
     }
 }
+#[doc = r" Generation of default values for serde."]
 pub mod defaults {
     pub(super) fn test_bed_any() -> Vec<serde_json::Value> {
         vec![
diff --git a/typify/tests/schemas/types-with-more-impls.rs b/typify/tests/schemas/types-with-more-impls.rs
index 583862b..8cda280 100644
--- a/typify/tests/schemas/types-with-more-impls.rs
+++ b/typify/tests/schemas/types-with-more-impls.rs
@@ -1,5 +1,6 @@
 #[allow(unused_imports)]
 use serde::{Deserialize, Serialize};
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);
diff --git a/typify/tests/schemas/untyped-enum-with-null.rs b/typify/tests/schemas/untyped-enum-with-null.rs
index 6188832..fb62063 100644
--- a/typify/tests/schemas/untyped-enum-with-null.rs
+++ b/typify/tests/schemas/untyped-enum-with-null.rs
@@ -1,5 +1,6 @@
 #[allow(unused_imports)]
 use serde::{Deserialize, Serialize};
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);
diff --git a/typify/tests/schemas/various-enums.rs b/typify/tests/schemas/various-enums.rs
index 57f72fe..c0c1333 100644
--- a/typify/tests/schemas/various-enums.rs
+++ b/typify/tests/schemas/various-enums.rs
@@ -1,5 +1,6 @@
 #[allow(unused_imports)]
 use serde::{Deserialize, Serialize};
+#[doc = r" Error types."]
 pub mod error {
     #[doc = r" Error from a TryFrom or FromStr implementation."]
     pub struct ConversionError(std::borrow::Cow<'static, str>);