-
Notifications
You must be signed in to change notification settings - Fork 32
/
generateCore.m
55 lines (51 loc) · 1.94 KB
/
generateCore.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function generateCore(varargin)
% GENERATECORE Generate Matlab classes from NWB core schema files
% GENERATECORE() Generate classes (Matlab m-files) from the
% NWB core namespace file. By default, generates off of the most recent nwb-schema
% release.
%
% GENERATECORE(version) Generate classes for the
% core namespace of the listed version.
%
% A cache of schema data is generated in the 'namespaces' subdirectory in
% the current working directory. This is for allowing cross-referencing
% classes between multiple namespaces.
%
% Output files are generated placed in a '+types' subdirectory in the
% current working directory.
%
% GENERATECORE(__, 'savedir', saveDirectory) Generates the core class
% files in the specified directory.
%
% Example:
% generateCore();
% generateCore('2.2.3');
%
% See also GENERATEEXTENSION
latestVersion = '2.7.0';
if nargin == 0 || strcmp(varargin{1}, 'savedir')
version = latestVersion;
else
version = varargin{1};
validateattributes(version, {'char', 'string'}, {'scalartext'}, 'generateCore', 'version', 1);
version = char(version);
varargin = varargin(2:end);
end
if strcmp(version, 'latest')
version = latestVersion;
end
schemaPath = fullfile(misc.getMatnwbDir(), 'nwb-schema', version);
corePath = fullfile(schemaPath, 'core', 'nwb.namespace.yaml');
commonPath = fullfile(schemaPath,...
'hdmf-common-schema', ...
'common',...
'namespace.yaml');
assert(2 == exist(corePath, 'file'),...
'NWB:GenerateCore:MissingCoreSchema',...
'Cannot find suitable core namespace for schema version `%s`',...
version);
if 2 == exist(commonPath, 'file')
generateExtension(commonPath, varargin{:});
end
generateExtension(corePath, varargin{:});
end