summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2023-06-03 06:47:59 +0300
committerLars Wirzenius <liw@liw.fi>2023-06-03 18:13:06 +0300
commite8dca81ac5fca1cd7bd3532293858e52eb376882 (patch)
tree7a9bde8b2b7b35c8ed992ed8da32d705c6fe55d7
parentb3f9948a720eae708f7575d9a05943b85f328e42 (diff)
downloadsubplot-e8dca81ac5fca1cd7bd3532293858e52eb376882.tar.gz
fix: allow docgen to handle a subplot not in current directory
Sponsored-by: author
-rw-r--r--src/bin/subplot.rs8
-rw-r--r--subplot.md24
2 files changed, 31 insertions, 1 deletions
diff --git a/src/bin/subplot.rs b/src/bin/subplot.rs
index b95b550..b23f858 100644
--- a/src/bin/subplot.rs
+++ b/src/bin/subplot.rs
@@ -265,8 +265,14 @@ impl Docgen {
date.to_string()
} else {
let mut newest = None;
+ let basedir = if let Some(basedir) = self.input.parent() {
+ basedir.to_path_buf()
+ } else {
+ return Err(SubplotError::BasedirError(self.input.clone()).into());
+ };
for filename in doc.meta().markdown_filenames() {
- let mtime = Self::mtime(filename)?;
+ let filename = basedir.join(filename);
+ let mtime = Self::mtime(&filename)?;
if let Some(so_far) = newest {
if mtime > so_far {
newest = Some(mtime);
diff --git a/subplot.md b/subplot.md
index ae0aa78..bb4bd75 100644
--- a/subplot.md
+++ b/subplot.md
@@ -3560,3 +3560,27 @@ markdowns:
~~~{#foo.txt .file add-newline=xyzzy}
~~~
~~~~~~
+
+## Running Subplot
+
+The scenarios in this section verify that the Subplot tool can be run
+in various specific ways.
+
+### Files not in current working directory
+
+_Requirement: Subplot can process a subplot that is not in the current
+working directory._
+
+~~~scenario
+given file x/simple.subplot from simple.subplot
+given file x/simple.md from simple.md
+given file x/b.yaml from b.yaml
+given file x/f.py from f.py
+given an installed subplot
+when I run subplot metadata x/simple.subplot
+then command is successful
+when I run subplot codegen x/simple.subplot -o test.py
+then file test.py exists
+when I run subplot docgen x/simple.subplot -o simple.html
+then file simple.html exists
+~~~