Skip to content

Commit ebb014f

Browse files
authored
Merge pull request #1216 from AllenInstitute/feature/1216-check-help-string-analysis-functions
Check help string analysis functions
2 parents e516eff + 1b357e3 commit ebb014f

File tree

3 files changed

+56
-21
lines changed

3 files changed

+56
-21
lines changed

Packages/MIES/MIES_AnalysisFunctionHelpers.ipf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,29 @@ Function/S AFH_GetListOfAnalysisParams(func, mode)
502502
endif
503503
End
504504

505+
/// @brief Get help string from optional `$func_GetHelp`
506+
///
507+
/// @param func Analysis function `V3`
508+
/// @param name Parameter name
509+
Function/S AFH_GetHelpForAnalysisParameter(string func, string name)
510+
511+
FUNCREF AF_PROTO_PARAM_HELP_GETTER_V3 f = $(func + "_GetHelp")
512+
513+
if(!FuncRefIsAssigned(FuncRefInfo(f)))
514+
return ""
515+
endif
516+
517+
AssertOnAndClearRTError()
518+
try
519+
return f(name); AbortOnRTE
520+
catch
521+
ClearRTError()
522+
// ignoring errors here
523+
endtry
524+
525+
return ""
526+
End
527+
505528
/// @defgroup AnalysisFunctionParameterHelpers Analysis Helper functions for dealing with user parameters
506529

507530
/// @brief Return a semicolon separated list of user parameters

Packages/MIES/MIES_WaveBuilderPanel.ipf

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,27 +1804,16 @@ static Function WBP_UpdateParameterWave()
18041804
listWave[][%Help] = ""
18051805
helpWave[][] = ""
18061806

1807-
FUNCREF AF_PROTO_PARAM_HELP_GETTER_V3 f = $(genericFunc + "_GetHelp")
1808-
1809-
if(FuncRefIsAssigned(FuncRefInfo(f)))
1810-
1811-
numEntries = DimSize(listWave, ROWS)
1812-
for(i = 0; i < numEntries; i += 1)
1813-
name = listWave[i][%Name]
1814-
1815-
if(WhichListItem(name, suggNames) != -1)
1816-
AssertOnAndClearRTError()
1817-
try
1818-
help = f(name); AbortOnRTE
1819-
listWave[i][%Help] = help
1820-
helpWave[i][%Help] = LineBreakingIntoPar(help, minimumWidth = 40)
1821-
catch
1822-
ClearRTError()
1823-
// ignoring errors here
1824-
endtry
1825-
endif
1826-
endfor
1827-
endif
1807+
numEntries = DimSize(listWave, ROWS)
1808+
for(i = 0; i < numEntries; i += 1)
1809+
name = listWave[i][%Name]
1810+
1811+
if(WhichListItem(name, suggNames) != -1)
1812+
help = AFH_GetHelpForAnalysisParameter(genericFunc, name)
1813+
listWave[i][%Help] = help
1814+
helpWave[i][%Help] = LineBreakingIntoPar(help, minimumWidth = 40)
1815+
endif
1816+
endfor
18281817
End
18291818

18301819
/// @brief Toggle the analysis parameter GUI

Packages/Testing-MIES/UTF_AnalysisFunctionManagement.ipf

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,29 @@ static Function EnsureCorrectUserAnalysis()
311311
REQUIRE_EQUAL_VAR(ItemsInList(FunctionList("InvalidSignature", ";", "WIN:UserAnalysisFunctions.ipf")), 1)
312312
End
313313

314+
Function CheckHelpStringsOfAllAnalysisFunctions()
315+
string funcs, genericFunc, params, names, name, help
316+
variable i, j, numFuncs, numParams
317+
318+
funcs = WBP_GetAnalysisFunctions(ANALYSIS_FUNCTION_VERSION_V3)
319+
// remove our test help functions which do nasty things
320+
funcs = GrepList(funcs, "Params[[:digit:]]*_V3", 1)
321+
322+
numFuncs = ItemsInList(funcs)
323+
for(i = 0; i < numFuncs; i += 1)
324+
genericFunc = StringFromList(i, funcs)
325+
params = AFH_GetListOfAnalysisParams(genericFunc, REQUIRED_PARAMS | OPTIONAL_PARAMS)
326+
327+
names = AFH_GetListOfAnalysisParamNames(params)
328+
numParams = ItemsInList(names)
329+
for(j = 0; j < numParams; j += 1)
330+
name = StringFromList(j, names)
331+
help = AFH_GetHelpForAnalysisParameter(genericFunc, name)
332+
CHECK_PROPER_STR(help)
333+
endfor
334+
endfor
335+
End
336+
314337
// invalid analysis functions
315338
// UTF_TD_GENERATOR HardwareMain#DeviceNameGeneratorMD1
316339
static Function AFT1([str])

0 commit comments

Comments
 (0)