summaryrefslogtreecommitdiff
path: root/subplotlib
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-09-03 13:47:16 +0300
committerLars Wirzenius <liw@liw.fi>2022-09-06 07:24:31 +0300
commit765b2e1d4d94b2274de28d4efd24bfe77e8d93ac (patch)
treea7c22c35da5811f19fa02772ecc6498d87d63030 /subplotlib
parentc230684f3bab80154d5224d4f2f71eafd00fd100 (diff)
downloadsubplot-765b2e1d4d94b2274de28d4efd24bfe77e8d93ac.tar.gz
feat! read document metadata from a YAML file
This is a huge change all in one commit, sorry. However, as it changes a fundamental part of the command line interface (namely, what constitutes as the input file), there doesn't seem a way to break this into a tidy series of small commits. Most of the diff is in subplot.md, where every scenario that invokes Subplot needs multiple changes, thus touching much of the file. The overall change is that where we previously had document metadata in embedded YAML in the Markdown file, we now have it in a separate YAML file. The Markdown file is named in the YAML file. We still parse the Markdown with Pandoc for everything, except codegen. Switching from Pandoc to pulldown_cmark for parsing will be another big change that I didn't want to include in this huge change set. Sponsored-by: author
Diffstat (limited to 'subplotlib')
-rw-r--r--subplotlib/build.rs14
-rw-r--r--subplotlib/subplotlib.subplot10
2 files changed, 17 insertions, 7 deletions
diff --git a/subplotlib/build.rs b/subplotlib/build.rs
index f22a50c..e5f8917 100644
--- a/subplotlib/build.rs
+++ b/subplotlib/build.rs
@@ -2,8 +2,8 @@
//
// We use the `subplot_build` crate to generate a Rust test code file
// with functions for the scenarios for each subplot file
-// (subplot/*.md in the source tree). The generated file is written to
-// the Cargo target directory. For each subplot foo.md there should be
+// (subplot/*.subplot in the source tree). The generated file is written to
+// the Cargo target directory. For each subplot foo.subplot there should be
// a tests/foo.rs in the source tree, which includes the generated
// file from the Cargo target tree. The source file should look like this:
//
@@ -15,11 +15,11 @@ use glob::glob;
use std::{fs, path::Path};
fn gen_tests() {
- let subplots = glob("*.md").expect("failed to find subplots in subplotlib");
+ let subplots = glob("*.subplot").expect("failed to find subplots in subplotlib");
let tests = Path::new("tests");
- let subplots = subplots.chain(Some(Ok("../subplot.md".into())));
+ let subplots = subplots.chain(Some(Ok("../subplot.subplot".into())));
let subplots = subplots
- .chain(glob("../tests/subplots/common/*.md").expect("failed to find common subplots"));
+ .chain(glob("../tests/subplots/common/*.subplot").expect("failed to find common subplots"));
for entry in subplots {
let entry = entry.expect("failed to get subplot dir entry in subplotlib");
let mut inc = tests.join(&entry.file_name().unwrap());
@@ -35,8 +35,8 @@ fn gen_tests() {
fn main() {
// Because we cannot generate tests if we're not fully inside the main subplot tree
- // we only generate them if we can see ../subplot.md which is a good indicator.
- if fs::metadata("../subplot.md").is_ok() {
+ // we only generate them if we can see ../subplot.subplot which is a good indicator.
+ if fs::metadata("../subplot.subplot").is_ok() {
gen_tests();
}
}
diff --git a/subplotlib/subplotlib.subplot b/subplotlib/subplotlib.subplot
new file mode 100644
index 0000000..e12804e
--- /dev/null
+++ b/subplotlib/subplotlib.subplot
@@ -0,0 +1,10 @@
+title: Testing the Rust crate "subplotlib"
+markdowns:
+ - subplotlib.md
+bindings:
+ - subplotlib.yaml
+ - lib/datadir.yaml
+impls:
+ rust:
+ - helpers/subplotlib_context.rs
+ - helpers/subplotlib_impl.rs