At least as of Rust 1.55 edition 2018, a documentation test can be ignored with an annotation like the following:
/// ```ignore
/// do_something();
/// ```
Moreover, each documentation comment line is actually translated into an individual attribute, like so:
#[doc = " ```ignore"]
#[doc = " do_something();"]
#[doc = " ```"]
This means that the line saying ```ignore can be conditionally replaced, using the cfg_attr attribute, with one just saying ```, to activate the test:
#[cfg_attr(feature = "extra-doctests", doc = "```")]
#[cfg_attr(not(feature = "extra-doctests"), doc = "```ignore")]
/// do_something();
/// ```
When tests are run with the extra-doctests feature enabled, this doc-test will run normally; when this feature is disabled, it will appear as "ignored" in the log.