Skip to content

Commit 1f62ec4

Browse files
committed
Move pkg load functions to own .m file
* PKG_ADD, PKG_DEL: deleted * __load_arduino__.m, __unload_arduino__.m: new files
1 parent 1848ce4 commit 1f62ec4

File tree

4 files changed

+98
-48
lines changed

4 files changed

+98
-48
lines changed

inst/PKG_ADD

-24
This file was deleted.

inst/PKG_DEL

-24
This file was deleted.

inst/__load_arduino__.m

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
## Copyright (C) 2023 John Donoghue
2+
##
3+
## This program is free software; you can redistribute it and/or
4+
## modify it under the terms of the GNU General Public License as
5+
## published by the Free Software Foundation; either version 3 of the
6+
## License, or (at your option) any later version.
7+
##
8+
## This program is distributed in the hope that it will be useful, but
9+
## WITHOUT ANY WARRANTY; without even the implied warranty of
10+
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
## General Public License for more details.
12+
##
13+
## You should have received a copy of the GNU General Public License
14+
## along with this program; if not, see
15+
## <http:##www.gnu.org/licenses/>.
16+
17+
## -*- texinfo -*-
18+
## @deftypefn {} {} __load_arduino__ ()
19+
## Undocumented internal function of arduino package.
20+
## @end deftypefn
21+
22+
## PKG_ADD: __load_arduino__ ()
23+
24+
function __load_arduino__ ()
25+
if exist ("isfolder") == 0
26+
if (isdir (fullfile (fileparts (mfilename ("fullpath")), "sensors")))
27+
addpath (fullfile (fileparts (mfilename ("fullpath")), "sensors"));
28+
endif
29+
else
30+
if (isfolder (fullfile (fileparts (mfilename ("fullpath")), "sensors")))
31+
addpath (fullfile (fileparts (mfilename ("fullpath")), "sensors"));
32+
endif
33+
endif
34+
35+
# on package load, attempt to load docs
36+
try
37+
pkg_dir = fileparts (fullfile (mfilename ("fullpath")));
38+
doc_file = fullfile (pkg_dir, "doc", "arduino.qch");
39+
if exist(doc_file, "file")
40+
if exist("__event_manager_register_documentation__")
41+
__event_manager_register_documentation__ (doc_file);
42+
elseif exist("__event_manager_register_doc__")
43+
__event_manager_register_doc__ (doc_file);
44+
endif
45+
endif
46+
catch
47+
# do nothing
48+
end_try_catch
49+
endfunction

inst/__unload_arduino__.m

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
## Copyright (C) 2023 John Donoghue
2+
##
3+
## This program is free software; you can redistribute it and/or
4+
## modify it under the terms of the GNU General Public License as
5+
## published by the Free Software Foundation; either version 3 of the
6+
## License, or (at your option) any later version.
7+
##
8+
## This program is distributed in the hope that it will be useful, but
9+
## WITHOUT ANY WARRANTY; without even the implied warranty of
10+
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
## General Public License for more details.
12+
##
13+
## You should have received a copy of the GNU General Public License
14+
## along with this program; if not, see
15+
## <http:##www.gnu.org/licenses/>.
16+
17+
## -*- texinfo -*-
18+
## @deftypefn {} {} __unload_arduino__ ()
19+
## Undocumented internal function of arduino package.
20+
## @end deftypefn
21+
22+
## PKG_DEL: __unload_arduino__ ()
23+
24+
function __unload_arduino__ ()
25+
if exist ("isfolder") == 0
26+
if (isdir (fullfile (fileparts (mfilename ("fullpath")), "sensors")))
27+
rmpath (fullfile (fileparts (mfilename ("fullpath")), "sensors"));
28+
endif
29+
else
30+
if (isfolder (fullfile (fileparts (mfilename ("fullpath")), "sensors")))
31+
rmpath (fullfile (fileparts (mfilename ("fullpath")), "sensors"));
32+
endif
33+
endif
34+
35+
# on package unload, attempt to unload docs
36+
try
37+
pkg_dir = fileparts (fullfile (mfilename ("fullpath")));
38+
doc_file = fullfile (pkg_dir, "doc", "arduino.qch");
39+
if exist(doc_file, "file")
40+
if exist("__event_manager_unregister_documentation__")
41+
__event_manager_unregister_documentation__ (doc_file);
42+
elseif exist("__event_manager_unregister_doc__")
43+
__event_manager_unregister_doc__ (doc_file);
44+
endif
45+
endif
46+
catch
47+
# do nothing
48+
end_try_catch
49+
endfunction

0 commit comments

Comments
 (0)