@@ 2,7 2,6 @@ use std::collections::BTreeMap;
use std::path::PathBuf;
use argh::FromArgs;
-use serde::{Deserialize, Serialize};
use serde_derive::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
@@ 15,6 14,15 @@ struct Instruction {
}
/// simple generator to read the instructions.toml file and produce some kind of output.
+///
+/// Right now it just outputs fairly basic Markdown. You can convert it to other formats
+/// with Pandoc:
+///
+/// ```
+/// cargo run -- instructions.toml > instructions.md
+/// pandoc -o instructions.html instructions.md
+/// pandoc --pdf-engine=xelatex -o instructions.pdf instructions.md
+/// ```
#[derive(FromArgs, Debug, Clone)]
struct Opts {
/// input file name
@@ 26,8 34,11 @@ fn output_md(instrs: &mut dyn Iterator<I
for (name, i) in instrs {
println!("# {}", name);
println!("**Name:** {}", i.name);
+ println!();
println!("**Opcode:** {}", i.opcode);
+ println!();
println!("**Encoding:** {}", i.encoding);
+ println!();
println!("**Extension:** {}", i.extension);
println!();
println!("{}", i.long_description);
@@ 36,7 47,6 @@ fn output_md(instrs: &mut dyn Iterator<I
fn main() {
let opts: Opts = argh::from_env();
- println!("Parsing {}", opts.file.display());
let contents = std::fs::read_to_string(&opts.file).unwrap();
let deserialized: BTreeMap<String, Instruction> = toml::from_str(&contents).unwrap();
let iter = &mut deserialized.iter();