Documented name-value argument not recognized

10 Ansichten (letzte 30 Tage)
Viktor
Viktor am 7 Aug. 2025
Beantwortet: Steven Lord am 7 Aug. 2025
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 Kommentare
Walter Roberson
Walter Roberson am 7 Aug. 2025
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 am 7 Aug. 2025
>> 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

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Steven Lord
Steven Lord am 7 Aug. 2025
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.

Weitere Antworten (0)

Kategorien

Mehr zu File Operations finden Sie in Help Center und File Exchange

Produkte


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by