mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-02-02 07:02:07 +01:00
Add simple preprocessor to handle descriptions interpreted by cargo doc
This seemed easiest, especially since I also am the author of pulldown-cmark-to-cmark :D. Funny how things fit together sometimes. And so much better than if I would have tried the same in pure python.
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,6 @@
|
||||
.DS_Store
|
||||
/.vscode/
|
||||
/.idea/
|
||||
.timestamp
|
||||
gen/doc
|
||||
*.go
|
||||
|
||||
12
src/rust/preproc/Cargo.toml
Normal file
12
src/rust/preproc/Cargo.toml
Normal file
@@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "preproc"
|
||||
version = "0.1.0"
|
||||
authors = ["Sebastian Thiel <sthiel@thoughtworks.com>"]
|
||||
edition = "2018"
|
||||
publish = false
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
pulldown-cmark-to-cmark = "1.2.2"
|
||||
pulldown-cmark = "0.5.2"
|
||||
36
src/rust/preproc/src/main.rs
Normal file
36
src/rust/preproc/src/main.rs
Normal file
@@ -0,0 +1,36 @@
|
||||
extern crate pulldown_cmark;
|
||||
extern crate pulldown_cmark_to_cmark;
|
||||
|
||||
use pulldown_cmark::Parser;
|
||||
use pulldown_cmark_to_cmark::fmt::cmark;
|
||||
use std::io::{self, Read, Write};
|
||||
|
||||
fn main() {
|
||||
let md = {
|
||||
let mut buf = String::with_capacity(2048);
|
||||
io::stdin().read_to_string(&mut buf).unwrap();
|
||||
buf
|
||||
};
|
||||
|
||||
let mut output = String::with_capacity(2048);
|
||||
|
||||
cmark(
|
||||
Parser::new_ext(&md, pulldown_cmark::Options::all()).map(|e| {
|
||||
use pulldown_cmark::Event::*;
|
||||
match e {
|
||||
Start(ref tag) => {
|
||||
use pulldown_cmark::Tag::*;
|
||||
match tag {
|
||||
CodeBlock(code) => Start(CodeBlock(format!("ignore{}", code).into())),
|
||||
_ => e,
|
||||
}
|
||||
}
|
||||
_ => e,
|
||||
}
|
||||
}),
|
||||
&mut output,
|
||||
None,
|
||||
)
|
||||
.unwrap();
|
||||
io::stdout().write_all(&output.as_bytes()).unwrap();
|
||||
}
|
||||
Reference in New Issue
Block a user