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

Is there any test configuration exclude no specified code block? #854

Open
sshplendid opened this issue Dec 17, 2018 · 2 comments
Open

Is there any test configuration exclude no specified code block? #854

sshplendid opened this issue Dec 17, 2018 · 2 comments
Labels
A-Code-Blocks Area: Code blocks A-Configuration Area: Configuration A-Tests Area: `mbdook test` related tests

Comments

@sshplendid
Copy link
Contributor

I'm really grateful to all of mdbook maintainers.

When mdbook tests documents, it does even plain code block.
I know base rule is testing not specified code block.
I think It's good feature to enable not specifed code block with configuration.
like this:

# book.toml
[test]
    exclude-plain-code-block: true # If this is true, test command exclude not specified code block.
@ehuss ehuss added A-Code-Blocks Area: Code blocks A-Configuration Area: Configuration A-Tests Area: `mbdook test` related tests labels May 17, 2019
@uint
Copy link
Contributor

uint commented May 3, 2020

Funnily, code blocks marked rs don't get tested.

It looks to me like what happens is this: the book source is run through the links preprocessor, the processed files get dumped in a temporary folder with the same directory structure as the source and then run through rustdoc --test.

Here's the relevant code for anyone interested.

Since we probably don't want to change the behavior of rustdoc, would the appropriate workaround be to add some meaningless attribute to code blocks without one (like none?) before we run them through rustdoc? And while we're at it, expand rs to rust?

@ehuss
Copy link
Contributor

ehuss commented May 3, 2020

I think it would probably be better to add an option to rustdoc to set the default language (rust-lang/rust#59867). Trying to rewrite the markdown would be tricky (would need to parse and transform the original text, and indented code blocks do not have a way to set the language).

I would also prefer to not add language aliases. That could get tricky with highlight.js.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Code-Blocks Area: Code blocks A-Configuration Area: Configuration A-Tests Area: `mbdook test` related tests
Projects
None yet
Development

No branches or pull requests

3 participants