From ec51beaf875131ae5bbb399d7df02484125f32e0 Mon Sep 17 00:00:00 2001 From: Jakob Stierhof Date: Thu, 1 Apr 2021 17:03:01 +0200 Subject: [PATCH 1/3] This will take forever to make it pass! --- test/test_documentation.sl | 89 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 test/test_documentation.sl diff --git a/test/test_documentation.sl b/test/test_documentation.sl new file mode 100644 index 00000000..4f2ccfab --- /dev/null +++ b/test/test_documentation.sl @@ -0,0 +1,89 @@ +% test for documentation of accessible functions +% No documentation -> No publication + +% get slang internal package +require("slshhelp"); +require("setfuns"); + +% get everything known from global ns and other packages required +variable file = "./share/isisscripts.sl"; +variable fp = fopen(file,"r"); +variable mat,si,s; +variable modules = {}; +variable line; + +foreach line (fp) using ("line") +{ + mat = string_matches(line,"try[ ]*{[ ]*\(require.*\)}"R); + if (length(mat) > 1) + { + si = strchop(mat[1],';',0); + foreach s(si) + { + mat = string_matches(s,".*require(.*\"\(.*\)\".*)"R); + if (length(mat) > 1) + { + list_append(modules, mat[1]); + } + } + } +} + +if (length(modules)) + modules = list_to_array(modules); +else + modules = NULL; +modules = modules[unique(modules)]; +variable m; +foreach m (modules) + try { require(m); } catch AnyError; + +variable knowns = [_apropos("Global", "", 1 | 2), _apropos(current_namespace(), "", 1 | 2)]; + +% import packages to seperate namespaces +variable ns = "isisscripts_test"; +% load isisscript to new ns +require(file, ns); + +variable Local_Functions, Global_Functions; +variable name; +variable nodoc_globals = 0; +variable nodoc_locals = 0; + +% iterate over all functions, and check if we get a help +Local_Functions = _apropos(ns, "", 1 | 2); +Global_Functions = _apropos("Global", "", 1 | 2); + +if (Int_Type != typeof(Local_Functions)) { + % remove everything that comes from slang and associated packages + Local_Functions = Local_Functions[complement(Local_Functions, knowns)]; + foreach name (Local_Functions) { + if (NULL == slsh_get_doc_string(name)) { % no help! + nodoc_locals++; + } + } +} else { + Local_Functions = {}; +} + +if (Int_Type != typeof(Global_Functions)) { + % remove everything that comes from slang and associated packages + Global_Functions = Global_Functions[complement(Global_Functions, knowns)]; + foreach name (Global_Functions) { + if (NULL == slsh_get_doc_string(name)) { % no help! + nodoc_globals++; + } + } +} else { + Global_Functions = {}; +} + +vmessage(` +ISISSCRIPTS defines + Global functions: %d, %d undocumented + Local functions: %d, %d undocumented +`, + length(Global_Functions), nodoc_globals, + length(Local_Functions), nodoc_locals); + +exit(nodoc_globals || nodoc_locals); -- GitLab From 445b6f89c2b4e2528f6e2fbae328e2b104f8655d Mon Sep 17 00:00:00 2001 From: Jakob Stierhof Date: Fri, 7 May 2021 16:22:51 +0200 Subject: [PATCH 2/3] Better handling of verbosity Tie _Isisscripts_Verbose to Isis_Verbose if not defined explicitely. This way we can use the '-q' option and suppress everything. Unfortunately one can not suppress the xspec cross section and abundance messages. In xspec/tcl setting chatter to 0 (or something below 6) suppresses these messages. But this is not the same function the xspec library provides for chattiness... --- Makefile | 2 +- build/isisscripts_prefix.sl | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index e2300f2f..92335397 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ test: # fails if any command produces exit code != 0 @for test in test/*.sl; do \ echo; \ echo $$test; \ - isis -g -n $$test || exit 1; \ + isis -g -n -q -10 --script $$test || exit 1; \ done @awk -f test/number_of_if_endif_directives.awk share/isisscripts.sl diff --git a/build/isisscripts_prefix.sl b/build/isisscripts_prefix.sl index b0c72787..fd4260b2 100644 --- a/build/isisscripts_prefix.sl +++ b/build/isisscripts_prefix.sl @@ -4,11 +4,11 @@ % #ifeval __get_reference("_Isisscripts_Verbose")==NULL -variable _Isisscripts_Verbose=1; +variable _Isisscripts_Verbose=Isis_Verbose; #endif if (Undefined_Type==typeof(_Isisscripts_Verbose)) { - _Isisscripts_Verbose=1; + _Isisscripts_Verbose=Isis_Verbose; } if (_Isisscripts_Verbose>0) { -- GitLab From 03fa82254198dcfe95d6f6e9da414bebba9043cb Mon Sep 17 00:00:00 2001 From: Jakob Stierhof Date: Fri, 7 May 2021 16:48:33 +0200 Subject: [PATCH 3/3] Documentation test Make the test output the undocumented functions. For now, let the test not fail. --- test/test_documentation.sl | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/test/test_documentation.sl b/test/test_documentation.sl index 4f2ccfab..926d695f 100644 --- a/test/test_documentation.sl +++ b/test/test_documentation.sl @@ -54,24 +54,28 @@ variable nodoc_locals = 0; Local_Functions = _apropos(ns, "", 1 | 2); Global_Functions = _apropos("Global", "", 1 | 2); +variable Local_Undoc = {}; if (Int_Type != typeof(Local_Functions)) { % remove everything that comes from slang and associated packages Local_Functions = Local_Functions[complement(Local_Functions, knowns)]; foreach name (Local_Functions) { if (NULL == slsh_get_doc_string(name)) { % no help! nodoc_locals++; + list_append(Local_Undoc, name); } } } else { Local_Functions = {}; } +variable Global_Undoc = {}; if (Int_Type != typeof(Global_Functions)) { % remove everything that comes from slang and associated packages Global_Functions = Global_Functions[complement(Global_Functions, knowns)]; foreach name (Global_Functions) { if (NULL == slsh_get_doc_string(name)) { % no help! nodoc_globals++; + list_append(Global_Undoc, name); } } } else { @@ -86,4 +90,20 @@ ISISSCRIPTS defines length(Global_Functions), nodoc_globals, length(Local_Functions), nodoc_locals); -exit(nodoc_globals || nodoc_locals); +if (nodoc_globals) { + vmessage("%s Undocumented Globals %s", ("=")[[0:14]/15], dup()); + variable sym; + foreach sym (Global_Undoc) + vmessage(" %s", sym); +} + +if (nodoc_locals) { + vmessage("%s Undocumented Locals %s", ("=")[[0:14]/15], dup()); + foreach sym (Local_Undoc) + vmessage(" %s", sym); +} + +vmessage(""); + +%exit(nodoc_globals || nodoc_locals); +exit(0); % once we have everything documented this should fail on missing documentation -- GitLab