Documented name-value argument not recognized

10 次查看(过去 30 天)
Hi,
I want to specify the location where publish will save visdiff's output. I try to do this using
comp = visdiff(ancestor, fileName);
filter(comp, 'unfiltered');
report = publish(comp, 'outputDir', 'saved_reports/');
However, when running the above code, I this error message:
Error using comparisons.internal.api.PublishInputParser/parse
'outputDir' is not a recognized parameter. For a list of valid name-value pair arguments, see the documentation for this function.
However, help publish produces the following:
Name-Value Arguments
Output Options
format - Output format
'html' (default) | 'doc' | 'latex' | 'ppt' | 'xml' | 'pdf'
outputDir - Output folder
character vector
stylesheet - Extensible Stylesheet Language (XSL) file
character vector
So why is outputDir not a recognized argument?
Best regards,
Viktor
  4 个评论
Walter Roberson
Walter Roberson 2025-8-7
Using 'outputDir' as a parameter works for me in R2024b and R2025a
sample = "disp('hello')";
tn = tempname() + ".m";
td = fileparts(tn);
addpath(td)
writelines(sample, tn)
publish(tn, 'outputDir', tempdir())
Viktor
Viktor 2025-8-7
>> which publish -all
C:\Program Files\MATLAB\R2024b\toolbox\matlab\codetools\publish.p
publish is a Java method % com.mathworks.addons.sidepanel.Communicator method
C:\Program Files\MATLAB\R2024b\toolbox\matlab\connector2\messageservice\+message\+internal\MessageService.p % message.internal.MessageService method
C:\Program Files\MATLAB\R2024b\toolbox\simulink\comparisons\model\mldesktop\matlab\+slxmlcomp\SimulinkModelComparison.p % slxmlcomp.SimulinkModelComparison method
C:\Program Files\MATLAB\R2024b\toolbox\shared\comparisons\+comparisons\Comparison.p % comparisons.Comparison method
C:\Program Files\MATLAB\R2024b\toolbox\simulink\comparisons\model\mldesktop\matlab\+slxmlcomp\+internal\SimulinkModelComparison.p % slxmlcomp.internal.SimulinkModelComparison method

请先登录,再进行评论。

采纳的回答

Steven Lord
Steven Lord 2025-8-7
The problem is that the documentation of publish is wrong. The correct name-value argument is outputFolder.
The problem is that you're looking at the documentation for the wrong publish function. You're looking at the documentation for the general publish function. The object returned by visdiff has its own publish method and it seems that method 1) is not documented as a separate function, just via the example on the visdiff documentation page and 2) uses slightly different name-value arguments from the general publish function.
Let's look at which publish function gets used for a difference object:
benchfile = which('bench.m'); % sample file
obj = visdiff(benchfile, benchfile);
which publish(obj) % ask which overload would be called by that command
/MATLAB/toolbox/comparisons/text/mldesktop/matlab/+comparisons/TextComparison.p % comparisons.TextComparison method
and which gets used for general publishing of a file:
which publish(benchfile)
/MATLAB/toolbox/matlab/codetools/publish.p
I'll note this discrepancy in the name-value argument support to the development staff.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 File Operations 的更多信息

产品


版本

R2024b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by