It works!! With lots of caveats, so next up will be to fix modules and allow more than one file.
ZYNEMGAZXWHIWGNPB2RTYG3JWTH5Y5XY4JWJ3TTPANIOORTCLISAC
HEUMSBESSTWA6G7ZG5OJP3ZW3FLXHYUCODGDHMZSLE4O777JSDJQC
BMG4FSHNV54VXDHNUVGZOMXQJWLFSUF3M5NCN7GJETNIF3QTHELQC
C73UJ7ZYG4EE3YTK3N66GXPNWJHEBSRE4PDQBWMN6SKQ3U6ZYKXAC
REI53XR4WDH5EKLTXTFVTOVWCCFRWTFH4GQS6DSNM5LSRFTX7HJQC
BSJYWOYSJRERQ45AD7RN3364RYQ5P3IM76S67262VLFZPFO3B5JQC
A4E5KLI2CEHJLO6WUME2VIXPK4C2DXHCBVEK2TJTLHGCRCZ2ZC7QC
2N3KOCP74PCK2ETO5PCWBDR5PA57DDNT2KR4JLBPZPQPA56SAR4QC
generics: syn::Generics::default(),
generics: syn::Generics { lt_token: None, params: Punctuated::from_iter(vec![syn::GenericParam::Type(syn::TypeParam { attrs: Vec::new(), ident: syn::Ident::new("T", proc_macro2::Span::call_site()), colon_token: None, bounds: Punctuated::new(), eq_token: None, default: None })].into_iter()), gt_token: None, where_clause: None },
output: syn::ReturnType::Default,
output: syn::ReturnType::Type(
syn::token::RArrow::default(),
Box::new(syn::Type::ImplTrait(syn::TypeImplTrait {
impl_token: syn::token::Impl::default(),
bounds: Punctuated::from_iter(
vec![syn::TypeParamBound::Trait(syn::TraitBound {
paren_token: None,
modifier: syn::TraitBoundModifier::None,
lifetimes: None,
path: syn::Path {
leading_colon: None,
segments: Punctuated::from_iter(
vec![syn::PathSegment {
ident: syn::Ident::new(
"ViewSequence",
proc_macro2::Span::call_site(),
),
arguments: syn::PathArguments::AngleBracketed(
syn::AngleBracketedGenericArguments {
colon2_token: None,
lt_token: syn::token::Lt::default(),
args: Punctuated::from_iter(
vec![syn::GenericArgument::Type(
syn::Type::Path(syn::TypePath {
qself: None,
path: syn::Path {
leading_colon: None,
segments: Punctuated::from_iter(vec![syn::PathSegment { ident: syn::Ident::new("T", proc_macro2::Span::call_site()), arguments: syn::PathArguments::None }].into_iter()),
},
}),
)]
.into_iter(),
),
gt_token: syn::token::Gt::default(),
},
),
}]
.into_iter(),
),
},
})]
.into_iter(),
),
})),
),
// Handle nested directories correctly
let remainder = if parent != prefix {
assert!(parent.starts_with(&prefix));
parent.strip_prefix(&prefix).unwrap().to_path_buf()
} else {
PathBuf::new()
};
// TODO: Handle nested directories correctly
// let remainder = if parent != prefix {
// assert!(parent.starts_with(&prefix));
// parent.strip_prefix(&prefix).unwrap().to_path_buf()
// } else {
// PathBuf::new()
// };
// Create the appropriate directory layout
let mut output_path = staging_dir
.join(remainder)
.join(file.path().file_name().unwrap());
// Our input is .typ, but output is .html
output_path.set_extension("html");
// Store everything inside one large autogenerated Rust file
let output_path = out_dir.join("docs.rs");
Command::new("pandoc")
.args([
file.path().to_str().unwrap(),
"-o",
output_path.to_str().unwrap(),
])
.status()
.expect("Error running pandoc. Check if it's installed");
// TODO: this will only work for a single file, in the top-level directory
let rust_code = transform_pandoc(file.path());
std::fs::write(&output_path, rust_code).unwrap();