Skip to content

Commit

Permalink
Improve Pallet UI doc test (#5264)
Browse files Browse the repository at this point in the history
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 <[email protected]>
Co-authored-by: Dónal Murray <[email protected]>
  • Loading branch information
ggwpez and seadanda authored Aug 6, 2024
1 parent 11fdff1 commit 291c082
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
1 change: 1 addition & 0 deletions substrate/frame/support/test/example-pallet-doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is the best pallet
1 change: 1 addition & 0 deletions substrate/frame/support/test/example-readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Very important information :D
19 changes: 11 additions & 8 deletions substrate/frame/support/test/tests/pallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -1941,8 +1943,9 @@ fn extrinsic_metadata_ir_types() {
#[test]
fn test_pallet_runtime_docs() {
let docs = crate::pallet::Pallet::<Runtime>::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);
}

Expand Down

0 comments on commit 291c082

Please sign in to comment.