Skip to content

chore: fix doc-test parsing errors in doc examples#4290

Open
ShashwatGauniyal wants to merge 4 commits intosolana-foundation:masterfrom
ShashwatGauniyal:fix-doctests-#4236
Open

chore: fix doc-test parsing errors in doc examples#4290
ShashwatGauniyal wants to merge 4 commits intosolana-foundation:masterfrom
ShashwatGauniyal:fix-doctests-#4236

Conversation

@ShashwatGauniyal
Copy link
Copy Markdown

Closes #4236

In this PR :-
-- Added ignore tags to problematic doctest blocks to prevent them from being compiled incorrectly by rustdoc.
--In specific cases where a main() function was required for proper parsing of the macro-based examples, I explicitly added # fn main() {}.

verified by running cargo test --doc and the crates pass the doctest suite with 0 failed

Note: I intentionally left several other ignore blocks as-is where the code was already valid Rust and did not require a main() wrapper or any further modification, ensuring that we do not introduce unnecessary boilerplate into the documentation.

@vercel
Copy link
Copy Markdown

vercel bot commented Mar 5, 2026

@ShashwatGauniyal is attempting to deploy a commit to the Solana Foundation Team on Vercel.

A member of the Team first needs to authorize it.

cli/src/lib.rs Outdated
/// # let temp_dir = tempfile::tempdir()?;
/// # let file_path = temp_dir.path().join("lib.rs");
/// # let files = vec![(file_path, "// Content".to_string())];
/// // override_or_create_files(&files)?;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please restore the original line here - no-run can be used to ensure that it compiles without requiring it to run

cli/src/lib.rs Outdated
/// # fn main() -> anyhow::Result<()> {
/// # use std::path::PathBuf;
/// # let files = vec![(PathBuf::from("programs/my_program/src/lib.rs"), "// Content".to_string())];
/// # crate::create_files(&files)?;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This should not be commented out, the doctest will be empty

///
/// #[derive(Accounts)]
/// pub struct Create {
/// pub struct Create <'info> { // <'info> added
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// pub struct Create <'info> { // <'info> added
/// pub struct Create <'info> {

/// pub data: Account<'info, ExampleAccount>,
/// }
///
/// # fn main() {}
Copy link
Copy Markdown
Collaborator

@jamie-osec jamie-osec Mar 9, 2026

Choose a reason for hiding this comment

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

There's no reason to add this if the test is not compiled. Same for many other instances of this pattern

cli/src/lib.rs Outdated
Comment on lines +1563 to +1564
/// # let files = vec![(PathBuf::from("programs/my_program/src/lib.rs"), "// Content".to_string())];
/// # create_files(&files)?;
Copy link
Copy Markdown
Collaborator

@jamie-osec jamie-osec Mar 10, 2026

Choose a reason for hiding this comment

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

These should not be hidden (as well as in the other instances of this)

Suggested change
/// # let files = vec![(PathBuf::from("programs/my_program/src/lib.rs"), "// Content".to_string())];
/// # create_files(&files)?;
/// let files = vec![(PathBuf::from("programs/my_program/src/lib.rs"), "// Content".to_string())];
/// create_files(&files)?;

@ShashwatGauniyal
Copy link
Copy Markdown
Author

The misc-optional test failures are transaction timeout on the CI test validator, unrelated to the doc changes in this PR. Could you re-run the CI? also the tests/bench compute unit failure is also unrelated I did not change program code in the PR, only documentation comments. Please look into it and confirm.

@ShashwatGauniyal
Copy link
Copy Markdown
Author

I noticed the tests/misc job failed again with a TransactionExpiredTimeoutError (transaction not confirmed in 30 seconds). Since my changes only touch documentation comments, this looks like the test validator timing out again. Could you please re-trigger that failed job?

/// # Example
///
/// ```ignore
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please remove all changes like these to tests which are still marked ignore

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.

ignored doctests

2 participants