Skip to content

Code in documentation that's conditionally started with or ignore based on feature doesn't render correctly #10331

Closed
@marcianx

Description

@marcianx

Current Behavior

I just published downcast-rs v2.0.0 and the documentation appears misformatted even though it appears fine on docs.rs. Compare:

This seems due to code within the documentation that is only conditionally run for testing based on whether a feature is enabled:

...
//! Since 2.0.0, the minimum supported Rust version is 1.56.
//!
#![cfg_attr(feature = "sync", doc = "```")]
#![cfg_attr(not(feature = "sync"), doc = "```ignore")]
//! # #[macro_use]
//! # extern crate downcast_rs;
...

Effectively, the code block is being started with ``` when the sync feature is enabled and with ```ignore when it's disabled.

Actual code here.

Also:

  • Any workarounds?
  • Any way to discover such issues before publishing?

Expected Behavior

crates.io should render the documentation as well as docs.rs does.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions