Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial docify readme with some content #6333 #7093

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

seemantaggarwal
Copy link
Contributor

Use docify export for parachain template hardcoded configuration and embed it in its README #6333

@paritytech-workflow-stopper
Copy link

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/12699030630
Failed job name: test-linux-stable-no-try-runtime

Copy link
Contributor

@iulianbarbu iulianbarbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't run this yet, but I think it needs a few tweaks before it runs successfully. LMK if anything is not clear.

@@ -7,6 +7,13 @@ use alloc::{vec, vec::Vec};

use polkadot_sdk::{staging_xcm as xcm, *};

#[doc::include_str!("../../README.md")]
#[cfg(feature = "generate-readme")]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: empty line can be removed.

@@ -7,6 +7,13 @@ use alloc::{vec, vec::Vec};

use polkadot_sdk::{staging_xcm as xcm, *};

#[doc::include_str!("../../README.md")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to include the README as a string here. This line can be removed.


/// Generate the session keys from individual elements.
///
/// The input must be a tuple of individual keys (a single arg for now since we have just one key).
pub fn template_session_keys(keys: AuraId) -> SessionKeys {
SessionKeys { aura: keys }
}
#[docify::export(name = "get_parachain_id")]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about using export_content instead of export? This way we're getting only the PARACHAIN_ID var name.

@@ -17,14 +24,19 @@ use sp_keyring::Sr25519Keyring;
/// The default XCM version to set in genesis config.
const SAFE_XCM_VERSION: u32 = xcm::prelude::XCM_VERSION;
/// Parachain id used for genesis config presets of parachain template.
pub const PARACHAIN_ID: u32 = 1000;
#[export]
pub const PARACHAIN_ID: u32 = 2000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a leftover committed while testing Readme recompilation. We can change it back to 1000.

cd parachain-template
```

## Starting a Development Chain
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about adding a note at the beginning of this section where we embed the PARACHAIN_ID const (as it is declared in the rust code), with docify::embed, as described in these docs (https://docs.rs/docify/latest/docify/macro.compile_markdown.html)?

This prepares the reader for these hardcoded values that will be used across the code base.

#[doc::include_str!("../../README.md")]
#[cfg(feature = "generate-readme")]

docify::compile_markdown!("../..","../..");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be:

Suggested change
docify::compile_markdown!("../..","../..");
docify::compile_markdown!("../../README.docify.md","../../README.md");

Comment on lines +37 to +39
pub fn get_parachain_id() -> u32 {
PARACHAIN_ID
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking again about this, I would have this function return a plain 1000 (such that it corresponds with the cost PARACHAIN_ID). We should follow with a test that asserts PARACHAIN_ID == get_parachain_id(). Might sound redundant, but this is to overcome the lack of docify support around interpolating exported primitive constants by value directly into the README.

Then, we can directly use the get_parachain_id tag in the README.docify.md to interpolate 1000 into the doc wherever it is needed. I haven't tried this though, I have a slight concern it might not work everywhere.

Last thing would be to run cargo build --features generate-readme to trigger the README.md compilation, based on the README.docify.md file.

Suggested change
pub fn get_parachain_id() -> u32 {
PARACHAIN_ID
}
const fn get_parachain_id() -> u32 {
1000
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants