diff --git a/core/modules/filters/inspect.js b/core/modules/filters/inspect.js index 131da61a2..c51dc2b77 100644 --- a/core/modules/filters/inspect.js +++ b/core/modules/filters/inspect.js @@ -15,7 +15,7 @@ Export our filter function exports.inspect = function(source,operator,options) { var self = this, inputFilter = operator.operands[0] || "", - output = {input: [],runs: []}, + output = {input: [],runs: [], inputFilter: inputFilter}, currentRun; // Save the input source(function(tiddler,title) { @@ -29,11 +29,13 @@ exports.inspect = function(source,operator,options) { var details ={ input: results.toArray(), prefixName: innerOptions.prefixName, + suffixes: innerOptions.suffixes, operators: [] }; currentRun = details.operators; var innerResults = filterRunPrefixFunction.call(null,operationFunction,innerOptions); innerResults(results,innerSource,innerWidget); + details.output = results.toArray(); output.runs.push(details); }; }, @@ -52,12 +54,14 @@ exports.inspect = function(source,operator,options) { }); currentRun.push(details); var innerResults = operatorFunction.apply(null,Array.prototype.slice.call(arguments,1)); + details.output = innerResults.slice(0); return innerResults; } } }); output.output = compiledFilter.call(options.wiki,source,options.widget); var results = []; +console.log(`Inspected ${JSON.stringify(output,null,4)}`); results.push(JSON.stringify(output,null,4)); return results; }; diff --git a/editions/test/tiddlers/tests/data/filter-wrappers/Simple.tid b/editions/test/tiddlers/tests/data/filter-wrappers/Simple.tid index c082fe0d1..fc9ecef90 100644 --- a/editions/test/tiddlers/tests/data/filter-wrappers/Simple.tid +++ b/editions/test/tiddlers/tests/data/filter-wrappers/Simple.tid @@ -31,6 +31,7 @@ title: ExpectedResult { "input": [], "prefixName": "or", + "suffixes": [], "operators": [ { "operatorName": "title", @@ -41,8 +42,14 @@ title: ExpectedResult "$:/core", "ExpectedResult", "Output" + ], + "output": [ + "1" ] } + ], + "output": [ + "1" ] }, { @@ -50,6 +57,7 @@ title: ExpectedResult "1" ], "prefixName": "or", + "suffixes": [], "operators": [ { "operatorName": "title", @@ -60,8 +68,15 @@ title: ExpectedResult "$:/core", "ExpectedResult", "Output" + ], + "output": [ + "2" ] } + ], + "output": [ + "1", + "2" ] }, { @@ -70,6 +85,7 @@ title: ExpectedResult "2" ], "prefixName": "or", + "suffixes": [], "operators": [ { "operatorName": "title", @@ -80,11 +96,20 @@ title: ExpectedResult "$:/core", "ExpectedResult", "Output" + ], + "output": [ + "3" ] } + ], + "output": [ + "1", + "2", + "3" ] } ], + "inputFilter": "1 2 3", "output": [ "1", "2", diff --git a/editions/tw5.com/tiddlers/filters/inspect Operator.tid b/editions/tw5.com/tiddlers/filters/inspect Operator.tid index 44460ca1c..613a4fc10 100644 --- a/editions/tw5.com/tiddlers/filters/inspect Operator.tid +++ b/editions/tw5.com/tiddlers/filters/inspect Operator.tid @@ -15,6 +15,7 @@ type: text/vnd.tiddlywiki The JSON object contains the following properties: * `input`: the input titles passed to the filter +* `inputFilter`: the filter being inspected * `output`: the output titles resulting from evaluating the filter * `runs`: an array of objects, each of which represents a single run of the filter. Each object contains the following properties: ** `prefixName`: the name of the prefix operator that was used in this run @@ -23,4 +24,9 @@ The JSON object contains the following properties: *** `operatorName`: the name of the operator *** `operands`: an array of string operands passed to the operator *** `input`: the input titles passed to the operator +*** `output`: the output titles resulting from evaluating the operator + +!! Examples + +<$transclude $variable="inspect-filter" filter="1 2 3" inputFilter="[all[tiddler]]"/>