-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
66 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
function load_jsonstuff | ||
% Load the jsonstuff library | ||
|
||
pkg_name = "jsonstuff"; | ||
|
||
this_dir = fileparts (fullfile (mfilename ("fullpath"))); | ||
inst_dir = fileparts (fileparts (this_dir)); | ||
shims_dir = fullfile (inst_dir, "shims", "compat"); | ||
|
||
% Load doco | ||
|
||
% When a package is installed, the doc/ directory is added as a subdir | ||
% of the main installation dir, which contains the inst/ files. But when | ||
% running from the repo, doc/ is a sibling of inst/. | ||
|
||
if exist (fullfile (inst_dir, "doc", [pkg_name ".qch"]), "file") | ||
qhelp_file = fullfile (inst_dir, "doc", [pkg_name ".qch"]); | ||
elseif exist (fullfile (fileparts (inst_dir), "doc", [pkg_name ".qch"]), "file") | ||
qhelp_file = fullfile (fileparts (inst_dir), "doc", [pkg_name ".qch"]); | ||
else | ||
% Couldn't find doc file. Oh well. | ||
qhelp_file = []; | ||
endif | ||
|
||
if ! isempty (qhelp_file) | ||
if compare_versions (version, "4.4.0", ">=") && compare_versions (version, "6.0.0", "<") | ||
__octave_link_register_doc__ (qhelp_file); | ||
elseif compare_versions (version, "6.0.0", ">=") | ||
__event_manager_register_doc__ (qhelp_file); | ||
endif | ||
endif | ||
|
||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
function unload_jsonstuff | ||
% Unload the jsonstuff library | ||
|
||
pkg_name = "jsonstuff"; | ||
|
||
this_dir = fileparts (fullfile (mfilename ("fullpath"))); | ||
inst_dir = fileparts (fileparts (this_dir)); | ||
shims_dir = fullfile (inst_dir, "shims", "compat"); | ||
|
||
% Unregister doco | ||
|
||
if exist (fullfile (inst_dir, "doc", [pkg_name ".qch"]), "file") | ||
qhelp_file = fullfile (inst_dir, "doc", [pkg_name ".qch"]); | ||
elseif exist (fullfile (fileparts (inst_dir), "doc", [pkg_name ".qch"]), "file") | ||
qhelp_file = fullfile (fileparts (inst_dir), "doc", [pkg_name ".qch"]); | ||
else | ||
% Couldn't find doc file. Oh well. | ||
qhelp_file = []; | ||
endif | ||
|
||
if ! isempty (qhelp_file) | ||
if compare_versions (version, "4.4.0", ">=") && compare_versions (version, "6.0.0", "<") | ||
__octave_link_unregister_doc__ (qhelp_file); | ||
elseif compare_versions (version, "6.0.0", ">=") | ||
__event_manager_unregister_doc__ (qhelp_file); | ||
endif | ||
endif | ||
|
||
|
||
endfunction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1 @@ | ||
% Register package's QHelp with the doc browser | ||
|
||
% PKG_ADD is run in the base workspace, not in a function. So use "__" variable | ||
% names to reduce risk of collision with user variables, and clear them all | ||
% at the end. | ||
|
||
% Have to hardcode this since it's not available from context | ||
__my_pkg_name = 'jsonstuff'; | ||
|
||
% We only want this to happen when we're called by 'pkg load', not when | ||
% this code is just added to the path. | ||
% Note: This detection is a hack and is brittle WRT changes in Octave's | ||
% internal implementation. | ||
|
||
__stack = dbstack; | ||
__is_loading = any (ismember ({__stack.name}, {'load_packages'})); | ||
if ~__is_loading | ||
return; | ||
end | ||
|
||
% And we can only do this on Octave 4.4 and newer, because 4.2 has no | ||
% __octave_link_register_doc___ | ||
if compare_versions (version, '4.4.0', '>=') | ||
|
||
% When a package is installed, the doc/ directory is added as a subdir | ||
% of the main installation dir, which contains the inst/ files | ||
|
||
__this_dir = fileparts (mfilename ('fullpath')); | ||
__my_doc_dir = fullfile (__this_dir, 'doc'); | ||
__my_qhelp_file = fullfile (__my_doc_dir, [__my_pkg_name '.qch']); | ||
if ~exist (__my_qhelp_file, 'file') | ||
warning('QHelp file for package %s is missing: %s', ... | ||
__my_pkg_name, __my_qhelp_file); | ||
return; | ||
end | ||
|
||
__octave_link_register_doc__ (__my_qhelp_file); | ||
|
||
endif | ||
|
||
clear __my_pkg_name __is_loading __stack __this_dir __my_doc_dir __my_qhelp_file | ||
jsonstuff.internal.load_jsonstuff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1 @@ | ||
% Unregister package's QHelp with the doc browser | ||
|
||
% PKG_DEL is run in the base workspace, not in a function. So use "__" variable | ||
% names to reduce risk of collision with user variables, and clear them all | ||
% at the end. | ||
|
||
% Have to hardcode this since it's not available from context | ||
__my_pkg_name = 'jsonstuff'; | ||
|
||
% We only want this to happen when we're called by 'pkg unload', not when | ||
% this code is just removed from the path. | ||
% Note: This detection is a hack and is brittle WRT changes in Octave's | ||
% internal implementation. | ||
|
||
__stack = dbstack; | ||
__is_loading = any (ismember ({__stack.name}, {'unload_packages','uninstall'})); | ||
if ~__is_loading | ||
return; | ||
end | ||
|
||
% And we can only do this on Octave 4.4 and newer, because 4.2 has no | ||
% __octave_link_register_doc___ | ||
if compare_versions (version, '4.4.0', '>=') | ||
|
||
% When a package is installed, the doc/ directory is added as a subdir | ||
% of the main installation dir, which contains the inst/ files | ||
|
||
__this_dir = fileparts (mfilename ('fullpath')); | ||
__my_doc_dir = fullfile (__this_dir, 'doc'); | ||
__my_qhelp_file = fullfile (__my_doc_dir, [__my_pkg_name '.qch']); | ||
if ~exist (__my_qhelp_file, 'file') | ||
% Don't bother warning on unloads | ||
return; | ||
end | ||
|
||
__octave_link_unregister_doc__ (__my_qhelp_file); | ||
|
||
endif | ||
|
||
clear __my_pkg_name __stack __is_loading __this_dir __my_doc_dir __my_qhelp_file | ||
jsonstuff.internal.unload_jsonstuff |