From 9332b8115daa2a0813cbc97dc7054576b063eab0 Mon Sep 17 00:00:00 2001 From: Amitai Schleier Date: Mon, 22 Oct 2018 00:24:59 -0400 Subject: [PATCH] Give graph an optional "file" param, like table's. --- IkiWiki/Plugin/graphviz.pm | 8 ++++++++ doc/ikiwiki/directive/graph.mdwn | 1 + 2 files changed, 9 insertions(+) diff --git a/IkiWiki/Plugin/graphviz.pm b/IkiWiki/Plugin/graphviz.pm index d4018edaa..479da6f73 100644 --- a/IkiWiki/Plugin/graphviz.pm +++ b/IkiWiki/Plugin/graphviz.pm @@ -95,6 +95,14 @@ sub render_graph (\%) { sub graph (@) { my %params=@_; + if (exists $params{file}) { + if (! exists $pagesources{$params{file}}) { + error gettext("cannot find file"); + } + $params{src} = readfile(srcfile($params{file})); + add_depends($params{page}, $params{file}); + } + # Support wikilinks in the graph source. my $src=$params{src}; $src="" unless defined $src; diff --git a/doc/ikiwiki/directive/graph.mdwn b/doc/ikiwiki/directive/graph.mdwn index 7021e47fb..1463420d7 100644 --- a/doc/ikiwiki/directive/graph.mdwn +++ b/doc/ikiwiki/directive/graph.mdwn @@ -21,6 +21,7 @@ ikiwiki, [[WikiLinks|ikiwiki/wikilink]] can also be used. For example: The `graph` directive supports the following parameters: - `src` - The graphviz source to render. +* `file` - A file in the wiki containing the graphviz source. - `type` - The type of graph to render: `graph` or `digraph`. Defaults to `digraph`. - `prog` - The graphviz program to render with: `dot`, `neato`, `fdp`, `twopi`, -- 2.39.5