Repository: paritytech/substrate
File: frame/support/procedural/src/pallet/expand/storage.rs (Rust)

Code before:
			} else if let Some(QueryKind::ResultQuery(error_path, _)) =
				storage_def.query_kind.as_ref()
			{
				args.args.push(syn::GenericArgument::Type(syn::parse_quote!(#error_path)))
			}

			// Here, we only need to check if OnEmpty is *not* specified, and if so, then we have to
			// generate a default OnEmpty struct for it.
			if on_empty_idx >= args.args.len() &&
				matches!(storage_def.query_kind.as_ref(), Some(QueryKind::ResultQuery(_, _)))
			{
				let value_ty = match args.args[value_idx].clone() {
					syn::GenericArgument::Type(ty) => ty,
					_ => unreachable!(),
				};
				let on_empty = default_on_empty(value_ty);
				args.args.push(syn::GenericArgument::Type(on_empty));
			}
		}
	}

	Ok(on_empty_struct_metadata)
}

fn augment_final_docs(def: &mut Def) {
	// expand the docs with a new line showing the storage type (value, map, double map etc), and if
	// the key/value type(s).
	let mut push_string_literal = |doc_line: &str, storage: &mut StorageDef| {
		let item = &mut def.item.content.as_mut().expect("Checked by def").1[storage.index];
		let typ_item = match item {
			syn::Item::Type(t) => t,
			_ => unreachable!("Checked by def"),
		};
		typ_item.attrs.push(syn::parse_quote!(#[doc = ""]));
		typ_item.attrs.push(syn::parse_quote!(#[doc = #doc_line]));
	};
	def.storages.iter_mut().for_each(|storage| match &storage.metadata {
		Metadata::Value { value } => {
			let doc_line = format!(
				"Storage type is [`StorageValue`] with value type `{}`.",
				value.to_token_stream()
			);
			push_string_literal(&doc_line, storage);
		},
		Metadata::Map { key, value } => {
			let doc_line = format!(
				"Storage type is [`StorageMap`] with key type `{}` and value type `{}`.",
				key.to_token_stream(),
				value.to_token_stream()
			);
			push_string_literal(&doc_line, storage);

Review comment (suggestion):
```suggestion
	// expand the docs with a new line showing the storage type (value, map, double map, etc), and
```

Code after:
			} else if let Some(QueryKind::ResultQuery(error_path, _)) =
				storage_def.query_kind.as_ref()
			{
				args.args.push(syn::GenericArgument::Type(syn::parse_quote!(#error_path)))
			}

			// Here, we only need to check if OnEmpty is *not* specified, and if so, then we have to
			// generate a default OnEmpty struct for it.
			if on_empty_idx >= args.args.len() &&
				matches!(storage_def.query_kind.as_ref(), Some(QueryKind::ResultQuery(_, _)))
			{
				let value_ty = match args.args[value_idx].clone() {
					syn::GenericArgument::Type(ty) => ty,
					_ => unreachable!(),
				};
				let on_empty = default_on_empty(value_ty);
				args.args.push(syn::GenericArgument::Type(on_empty));
			}
		}
	}

	Ok(on_empty_struct_metadata)
}

fn augment_final_docs(def: &mut Def) {
	// expand the docs with a new line showing the storage type (value, map, double map, etc), and
	// the key/value type(s).
	let mut push_string_literal = |doc_line: &str, storage: &mut StorageDef| {
		let item = &mut def.item.content.as_mut().expect("Checked by def").1[storage.index];
		let typ_item = match item {
			syn::Item::Type(t) => t,
			_ => unreachable!("Checked by def"),
		};
		typ_item.attrs.push(syn::parse_quote!(#[doc = ""]));
		typ_item.attrs.push(syn::parse_quote!(#[doc = #doc_line]));
	};
	def.storages.iter_mut().for_each(|storage| match &storage.metadata {
		Metadata::Value { value } => {
			let doc_line = format!(
				"Storage type is [`StorageValue`] with value type `{}`.",
				value.to_token_stream()
			);
			push_string_literal(&doc_line, storage);
		},
		Metadata::Map { key, value } => {
			let doc_line = format!(
				"Storage type is [`StorageMap`] with key type `{}` and value type `{}`.",
				key.to_token_stream(),
				value.to_token_stream()
			);
			push_string_literal(&doc_line, storage);