diff --git a/examples/crd_apply.rs b/examples/crd_apply.rs index 10562046f..7a3411af9 100644 --- a/examples/crd_apply.rs +++ b/examples/crd_apply.rs @@ -1,3 +1,5 @@ +//! Generated types support documentation +#![deny(missing_docs)] use schemars::JsonSchema; use serde::{Deserialize, Serialize}; use tracing::*; @@ -11,10 +13,7 @@ use kube::{ Client, CustomResource, CustomResourceExt, }; -// NB: This example uses server side apply and beta1 customresources -// Please test against Kubernetes 1.16.X! - -// Own custom resource +/// Spec object for Foo #[derive(CustomResource, Deserialize, Serialize, Clone, Debug, JsonSchema)] #[kube(group = "clux.dev", version = "v1", kind = "Foo", namespaced)] #[kube(status = "FooStatus")] @@ -25,6 +24,7 @@ pub struct FooSpec { replicas: isize, } +/// Status object for Foo #[derive(Deserialize, Serialize, Clone, Debug, Default, JsonSchema)] pub struct FooStatus { is_bad: bool, diff --git a/kube-derive/src/custom_resource.rs b/kube-derive/src/custom_resource.rs index 1179bc93e..20adff5fe 100644 --- a/kube-derive/src/custom_resource.rs +++ b/kube-derive/src/custom_resource.rs @@ -241,6 +241,8 @@ pub(crate) fn derive(input: proc_macro2::TokenStream) -> proc_macro2::TokenStrea let docstr = format!(" Auto-generated derived type for {} via `CustomResource`", ident); let root_obj = quote! { #[doc = #docstr] + #[automatically_derived] + #[allow(missing_docs)] #[derive(#(#derive_paths),*)] #[serde(rename_all = "camelCase")] #visibility struct #rootident { @@ -250,6 +252,7 @@ pub(crate) fn derive(input: proc_macro2::TokenStream) -> proc_macro2::TokenStrea #status_field } impl #rootident { + /// Spec based constructor for derived custom resource pub fn new(name: &str, spec: #ident) -> Self { Self { metadata: #k8s_openapi::apimachinery::pkg::apis::meta::v1::ObjectMeta {