From 291c082cbbb0c838c886f38040e54424c55d9618 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Tue, 6 Aug 2024 20:04:21 +0200 Subject: [PATCH] Improve Pallet UI doc test (#5264) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Test currently failing, therefore improving to include a file from the same crate to not trip up the caching. R0 silent since this is only modifying unpublished crates. --------- Signed-off-by: Oliver Tale-Yazdi Co-authored-by: Dónal Murray --- .../frame/support/test/example-pallet-doc.md | 1 + .../frame/support/test/example-readme.md | 1 + substrate/frame/support/test/tests/pallet.rs | 19 +++++++++++-------- 3 files changed, 13 insertions(+), 8 deletions(-) create mode 100644 substrate/frame/support/test/example-pallet-doc.md create mode 100644 substrate/frame/support/test/example-readme.md diff --git a/substrate/frame/support/test/example-pallet-doc.md b/substrate/frame/support/test/example-pallet-doc.md new file mode 100644 index 000000000000..3935e7e8eaed --- /dev/null +++ b/substrate/frame/support/test/example-pallet-doc.md @@ -0,0 +1 @@ +This is the best pallet diff --git a/substrate/frame/support/test/example-readme.md b/substrate/frame/support/test/example-readme.md new file mode 100644 index 000000000000..fdee294df9dd --- /dev/null +++ b/substrate/frame/support/test/example-readme.md @@ -0,0 +1 @@ +Very important information :D diff --git a/substrate/frame/support/test/tests/pallet.rs b/substrate/frame/support/test/tests/pallet.rs index 6f8af949cc31..eed8a22e8e79 100644 --- a/substrate/frame/support/test/tests/pallet.rs +++ b/substrate/frame/support/test/tests/pallet.rs @@ -114,8 +114,8 @@ impl SomeAssociation2 for u64 { #[frame_support::pallet] /// Pallet documentation // Comments should not be included in the pallet documentation -#[pallet_doc("../../README.md")] -#[doc = include_str!("../../README.md")] +#[pallet_doc("../example-pallet-doc.md")] +#[doc = include_str!("../example-readme.md")] pub mod pallet { use super::*; use frame_support::pallet_prelude::*; @@ -1408,8 +1408,9 @@ fn metadata() { use codec::Decode; use frame_metadata::{v15::*, *}; - let readme = "Support code for the runtime.\n\nLicense: Apache-2.0\n"; - let expected_pallet_doc = vec![" Pallet documentation", readme, readme]; + let readme = "Very important information :D\n"; + let pallet_doc = "This is the best pallet\n"; + let expected_pallet_doc = vec![" Pallet documentation", readme, pallet_doc]; let pallets = vec![ PalletMetadata { @@ -1911,8 +1912,9 @@ fn metadata_ir_pallet_runtime_docs() { .find(|pallet| pallet.name == "Example") .expect("Pallet should be present"); - let readme = "Support code for the runtime.\n\nLicense: Apache-2.0\n"; - let expected = vec![" Pallet documentation", readme, readme]; + let readme = "Very important information :D\n"; + let pallet_doc = "This is the best pallet\n"; + let expected = vec![" Pallet documentation", readme, pallet_doc]; assert_eq!(pallet.docs, expected); } @@ -1941,8 +1943,9 @@ fn extrinsic_metadata_ir_types() { #[test] fn test_pallet_runtime_docs() { let docs = crate::pallet::Pallet::::pallet_documentation_metadata(); - let readme = "Support code for the runtime.\n\nLicense: Apache-2.0\n"; - let expected = vec![" Pallet documentation", readme, readme]; + let readme = "Very important information :D\n"; + let pallet_doc = "This is the best pallet\n"; + let expected = vec![" Pallet documentation", readme, pallet_doc]; assert_eq!(docs, expected); }