Add rustdoc_to_markdown crate (#12445)

This PR adds a new crate for converting rustdoc output to Markdown.

We're leveraging Servo's `html5ever` to parse the Markdown content, and
then walking the DOM nodes to convert it to a Markdown string.

The Markdown output will be continued to be refined, but it's in a place
where it should be reasonable.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-05-29 16:05:16 -04:00 committed by GitHub
parent a22cd95f9d
commit 5bcb9ed017
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 420 additions and 17 deletions

View file

@ -0,0 +1,29 @@
use indoc::indoc;
use rustdoc_to_markdown::convert_rustdoc_to_markdown;
pub fn main() {
let html = indoc! {"
<html>
<body>
<h1>Hello World</h1>
<p>
Here is some content.
</p>
<h2>Some items</h2>
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
</body>
</html>
"};
// To test this out with some real input, try this:
//
// ```
// let html = include_str!("/path/to/zed/target/doc/gpui/index.html");
// ```
let markdown = convert_rustdoc_to_markdown(html).unwrap();
println!("{markdown}");
}