From 97e04981fa182318c68e34a28f0423d2c8460ffc Mon Sep 17 00:00:00 2001
From: Jan Lemmer <jan.lemmer@fst.tu-darmstadt.de>
Date: Tue, 25 Jan 2022 11:44:23 +0100
Subject: [PATCH] Add support for file or function name in scriptPath

---
 +PlotID/Publish.m | 7 ++++++-
 CHANGELOG.md      | 3 ++-
 README.md         | 4 ++--
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/+PlotID/Publish.m b/+PlotID/Publish.m
index f134cc0..ce254fb 100644
--- a/+PlotID/Publish.m
+++ b/+PlotID/Publish.m
@@ -27,7 +27,7 @@ function Publish(DataPaths,scriptPath, figure, options)
 
 arguments
    DataPaths {mustBeDataPath} % location of the data-file(s)
-   scriptPath (1,:) {mustBeFile} % location of the matlab script
+   scriptPath (1,:) {mustBeText} % location of the matlab script
    figure (1,:) {mustBeFigure} % Checks if figure is a figure object
    options.Location {mustBeMember(options.Location ,{'local','server','manual','CI-Test'})} = 'local' % storage path
    options.Method {mustBeMember(options.Method ,{'individual','centralized'})} = 'individual'
@@ -66,6 +66,11 @@ if numel(figure) > 1
     warning(msg);
 end
 
+% find scriptpath
+if ~isfile(scriptPath)
+    scriptPath= which(['/',scriptPath]);
+end
+
 % catch missing .m extension
 [~,~, scriptExt] = fileparts(scriptPath);
 if isempty(scriptExt)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 555d6ef..958e507 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,2 +1,3 @@
 # V0.3
-- Add Changelog 
+- Add changelog 
+- Add support for file or function name as scriptPath 
diff --git a/README.md b/README.md
index 929ac87..4999db6 100644
--- a/README.md
+++ b/README.md
@@ -28,8 +28,8 @@ The **ProjectID** is your custom project number, it well be the prefix of the ID
 2. Publish the plot and the associated data
 `PlotID.Publish(DataPaths,scriptPath,  figure, options)`
 
-`scriptPath` contains the path to the script, this can be provided with the simple call of `scriptPath = [mfilename('fullpath'),'.m']` \
-`DataPaths` contains the path(s) to the research data, for multiple files you can use a cell arrays (they must be at the path). \
+`scriptPath` contains either the path to the script, this can be provided with the simple call of `scriptPath = [mfilename('fullpath'),'.m']` or the script or function name that is used for creating your plot. \
+`DataPaths` contains the path(s) to the research data, for multiple files you can use a cell array (they must be at the path). \
 `figure` is the figure that should be published.
  
 
-- 
GitLab