From 8fa8bd0adb034f05131648dcb7b14011672649e8 Mon Sep 17 00:00:00 2001 From: joey Date: Fri, 27 Apr 2007 08:34:09 +0000 Subject: the kind of perl code that can only be written at 4:30 am (Get a good message when a PageSpec fails due to a negated success by creating success objects with a reason string, which morph into failure objects when negated.) --- doc/plugins/testpagespec.mdwn | 16 +++++++++++++--- doc/plugins/write.mdwn | 8 ++------ 2 files changed, 15 insertions(+), 9 deletions(-) (limited to 'doc/plugins') diff --git a/doc/plugins/testpagespec.mdwn b/doc/plugins/testpagespec.mdwn index 28e5ba7a7..c5155129d 100644 --- a/doc/plugins/testpagespec.mdwn +++ b/doc/plugins/testpagespec.mdwn @@ -2,11 +2,21 @@ [[tag type/useful]] This plugin allows testing a [[PageSpec]] to see if it matches a page, and -if not, why it fails to match. +to see the part that matches, or causes the match to fail. -Example use: +Example uses: \[[testpagespec pagespec="foopage and barpage" match="foopage"]] -This will print out something like "barpage does not match foopage", +This will print out something like "no match: barpage does not match foopage", highlighting which part of the [[PageSpec]] is causing the match to fail. + + \[[testpagespec pagespec="foopage or !bar*" match="barpage"]] + +This will print out something like "no match: bar* matches barpage", since the part +of the [[PageSpec]] that fails is this negated match. + + \[[testpagespec pagespec="foopage or barpage" match="barpage"]] + +This will print out something like "match: barpage matches barpage", +indicating the part of the [[PageSpec]] that did match. diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index ef9d412e5..0eef3d2ba 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -328,10 +328,6 @@ The most often used is "location", which specifies the location the PageSpec should match against. If not passed, relative PageSpecs will match relative to the top of the wiki. -If the PageSpec fails to match, it may return a IkiWiki::FailReason object, -which evaluates to false in a boolean context, but in a string context, -evaulates to the reason the PageSpec failed to match. - #### `bestlink($$)` Given a page and the text of a link on the page, determine which @@ -452,5 +448,5 @@ IkiWiki::PageSpec package, that is named `match_foo`, where "foo()" is how it will be accessed in a [[PageSpec]]. The function will be passed two parameters: The name of the page being matched, and the thing to match against. It may also be passed additional, named parameters. It should return -true if the match succeeds, and either false or a IkiWiki::FailReason object -if the match fails. +a IkiWiki::SuccessReason object if the match succeeds, or an +IkiWiki::FailReason object if the match fails. -- cgit v1.2.3