Description
Are there any thoughts on using an off-the-shelf markdown formatter to handle doc comments? Specifically comrak which is quite popular and (I believe) has a compatible license.
Reasoning is that it seems like needs are slowly approaching a full markdown-aware formatter. Things like preserving list items (#5746) or maintaining table format are important but tricky to handle without one.
Just a sample from #5746, using comrak configured to line length 80 - note that text is wrapped but indentation and code are both preserved
Input:
//! - References?
//! - Unsound. See this example:
//! ```compile_fail
//! # use core::mem::MaybeUninit;
//! let mut a = 0;
//! let b = maybe_uninit_ext::new::<&mut MaybeUninit<u8>>(&mut a);
//! *b = maybe_uninit_ext::uninit();
//! assert_eq!(a, 0); // undefined behavior! a is uninitialized.
//! ```
//! Due to interior mutability, this is an issue for immutable references
//! as well.
//!
//! Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean felis ipsum, mollis non
//! malesuada quis, tincidunt a orci. Aliquam erat volutpat. Nullam dui diam, sollicitudin
//! sed nulla ut, efficitur tempus mauris. Fusce consequat posuere nisl vitae consequat. Vivamus mattis porttitor sapien,
//! sit amet interdum velit varius quis. Integer est dolor, interdum ultrices elementum
//! vitae, porttitor sit amet ligula. Fusce ullamcorper sed velit nec dictum.
Output:
//! - References?
//! - Unsound. See this example:
//! ``` compile_fail
//! # use core::mem::MaybeUninit;
//! let mut a = 0;
//! let b = maybe_uninit_ext::new::<&mut MaybeUninit<u8>>(&mut a);
//! *b = maybe_uninit_ext::uninit();
//! assert_eq!(a, 0); // undefined behavior! a is uninitialized.
//! ```
//! Due to interior mutability, this is an issue for immutable references as
//! well. //\! Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean
//! felis ipsum, mollis non malesuada quis, tincidunt a orci. Aliquam erat
//! volutpat. Nullam dui diam, sollicitudin sed nulla ut, efficitur tempus
//! mauris. Fusce consequat posuere nisl vitae consequat. Vivamus mattis
//! porttitor sapien, sit amet interdum velit varius quis. Integer est dolor,
//! interdum ultrices elementum vitae, porttitor sit amet ligula. Fusce
//! ullamcorper sed velit nec dictum.
Edit with more context
Originally suggested at #3347 (comment) because it seems like we do a lot of things that need to be markdown-aware (wrapping comments and doc comments, formatting doc comments), and doing this all manually seems more tedious than using a tool designed to do this exact thing.