Skip to main content

to_commonmark

Function to_commonmark 

Source
pub fn to_commonmark(doc: &str) -> String
Expand description

Translate one Rust doc comment into CommonMark.

Returns the text unchanged when it carries nothing rustdoc-only, so a description that was already portable is not rewritten and the generated artifacts do not churn.

use majordomus_cli::capability::rustdoc::to_commonmark;

let doc = "Distinct from [`WaiverReason::ExternalDependency`]: nothing else.";
assert_eq!(to_commonmark(doc), "Distinct from `WaiverReason::ExternalDependency`: nothing else.");

// portable text comes back as it went in
assert_eq!(to_commonmark("Already *CommonMark*."), "Already *CommonMark*.");