Skip to content

Commit

Permalink
Fix livescripts add livescript test
Browse files Browse the repository at this point in the history
  • Loading branch information
ehennestad committed Oct 1, 2024
1 parent ee07559 commit 701b0ca
Show file tree
Hide file tree
Showing 13 changed files with 261 additions and 32 deletions.
9 changes: 9 additions & 0 deletions code/+openminds/toolboxdir.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function folderPath = toolboxdir()
% Root folder for the openMINDS_MATLAB toolbox
%
% S = openminds.toolboxdir() returns a character vector that is the absolute
% path to the root of the toolbox folder

folderPath = fileparts(fileparts(mfilename('fullpath')));
assert(isfolder(folderPath), 'Toolbox folder does not exist') % Should not happen
end
Binary file modified code/gettingStarted.mlx
Binary file not shown.
Binary file modified code/livescripts/crewMemberCollection.mlx
Binary file not shown.
1 change: 0 additions & 1 deletion dev/+utility/createContentsHeader.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@
copyRightLine, ...
separatorLine}, newline);
end

2 changes: 1 addition & 1 deletion dev/+utility/getVersionFromContents.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
error('BUILDTOOLS:Version:VersionNotFound', ...
'No version was detected in the Contents file for this toolbox.')
end
end
end
2 changes: 1 addition & 1 deletion dev/+utility/updateContentsHeader.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ function updateContentsHeader(toolboxFolder, contentsHeader)

fprintf('Updated %s\n', contentsFilePath)
disp(strjoin(contentsStrLines, newline))
end
end
2 changes: 1 addition & 1 deletion dev/tasks/createTestedWithBadgeforToolbox.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function createTestedWithBadgeforToolbox(versionNumber, rootDir)
&& sum([testResults.testsuite.failuresAttribute]) == 0 ...
&& sum([testResults.testsuite.skippedAttribute]) == 0
if releasesTestedWith ~= ""
% Insert the seperator between released after the first one
% Insert the separator between released after the first one
releasesTestedWith = releasesTestedWith + " | ";
end
releasesTestedWith = releasesTestedWith + releaseName;
Expand Down
51 changes: 51 additions & 0 deletions dev/tests/unitTests/TutorialTest.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
classdef TutorialTest < matlab.unittest.TestCase
% TutorialTest - Unit test for testing the openMINDS tutorials.

properties
RootDirectory = openminds.internal.rootpath();
end

properties (TestParameter)
% TutorialFile - A cell array where each cell is the name of a
% tutorial file. testTutorial will run on each file individually
tutorialFile = listTutorialFiles();
end

properties (Constant)
SkippedTutorials = {};
end

methods (TestClassSetup)
function setupClass(testCase) %#ok<*MANU>
openminds.startup("latest")
end
end

methods (TestClassTeardown)
function tearDownClass(testCase)
% Pass. No class teardown routines needed
end
end

methods (TestMethodSetup)
function setupMethod(testCase)
% Pass. No method setup routines needed
end
end

methods (Test)
function testTutorial(testCase, tutorialFile)
run(tutorialFile)
end
end
end

function tutorialFilePaths = listTutorialFiles()
% listTutorialFiles - List names of all tutorial files (exclude skipped files)
rootPath = openminds.internal.rootpath();
L = dir(fullfile(rootPath, 'livescripts', '*.mlx'));
tutorialNames = setdiff({L.name}, TutorialTest.SkippedTutorials);

tutorialFilePaths = fullfile(rootPath, 'livescripts', tutorialNames);
tutorialFilePaths{end+1} = fullfile(rootPath, 'gettingStarted.mlx');
end
1 change: 1 addition & 0 deletions docs/exportTutorials.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ function exportTutorials()
openmindsDocsPath = strrep(openmindsCodePath, 'code', 'docs');

L = dir(fullfile(openmindsCodePath, 'livescripts', '*.mlx'));
L = cat(1, L, dir(fullfile(openmindsCodePath, 'gettingStarted.mlx')));

for i = 1:numel(L)
sourcePath = fullfile(L(i).folder, L(i).name);
Expand Down
33 changes: 16 additions & 17 deletions docs/tutorials/crewMemberCollection.html

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions docs/tutorials/crewMemberCollection.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ In this example we will create a metadata collection for the crew members of the
We start by importing a csv file with crew member information:

```matlab
currentPath = fileparts(matlab.desktop.editor.getActiveFilename);
filePath = fullfile(currentPath, "data", "spacecraft_crew_members.csv");
filePath = fullfile(openminds.toolboxdir(), "livescripts", "data", "spacecraft_crew_members.csv");
crewMembers = readtable(filePath, "TextType", "String")
```
| |givenName|familyName|alternateName|email|memberOf|
Expand All @@ -29,9 +28,9 @@ With these assumptions we will create:
- a unique set of <samp>Consortium</samp> instances based on the name given in the <samp>memberOf</samp> column
- a <samp>ContactInformation</samp> instance based on the <samp>email</samp> column
- a <samp>Person</samp> instance for each table row with:
- the <samp>givenName</samp>, <samp>familyName</samp>, and <samp>alternateName</samp> (if available)
- a link to the respective <samp>ContactInformation</samp> instance
- a person-specific embedded <samp>Affiliation</samp> instance that links to the respective <samp>Consortium</samp> instance
- the <samp>givenName</samp>, <samp>familyName</samp>, and <samp>alternateName</samp> (if available)
- a link to the respective <samp>ContactInformation</samp> instance
- a person-specific embedded <samp>Affiliation</samp> instance that links to the respective <samp>Consortium</samp> instance

We start by creating an empty metadata collection for storing metadata instances.

Expand Down
Loading

0 comments on commit 701b0ca

Please sign in to comment.