Skip to content
Snippets Groups Projects
Commit 7b673a16 authored by Nick Draper's avatar Nick Draper
Browse files

Added allowed values to properties tables

also editied a couple of parameter dscriptions to fir better.
re #11822
parent f2cdfdf3
No related branches found
No related tags found
No related merge requests found
......@@ -38,10 +38,10 @@ void CreateCalFileByNames::init() {
new WorkspaceProperty<>("InstrumentWorkspace", "", Direction::Input,
boost::make_shared<InstrumentValidator>()),
"A workspace that contains a reference to the instrument of interest. "
"You can use [[LoadEmptyInstrument]] to create such a workspace.");
"You can use LoadEmptyInstrument to create such a workspace.");
declareProperty(
new FileProperty("GroupingFileName", "", FileProperty::Save, ".cal"),
"The name of the output [[CalFile]]");
"The name of the output CalFile");
declareProperty(
"GroupNames", "",
"A string of the instrument component names to use as separate groups. "
......
......@@ -49,7 +49,7 @@ class ConvertSnsRoiFileToMask(api.PythonAlgorithm):
allowedInstruments = kernel.StringListValidator(INSTRUMENTS)
self.declareProperty("Instrument", "",
validator=allowedInstruments,
doc="One of the following instruments: "+" ".join(INSTRUMENTS))
doc="One of the supported instruments")
self.declareProperty("OutputFilePrefix", "",
"Overrides the default filename for the output "\
+"file (Optional). Default is <inst_name>_Mask.")
......
......@@ -74,7 +74,7 @@ class PropertiesDirective(AlgorithmBaseDirective):
str(direction_string[prop.direction]),
property_type_dict.get(str(prop.type),str(prop.type)),
str(self._get_default_prop(prop)),
str(prop.documentation.replace("\n", " "))
self._create_property_description_string(prop)
))
self.add_rst(self.make_header("Properties"))
......@@ -200,6 +200,43 @@ class PropertiesDirective(AlgorithmBaseDirective):
return defaultstr
def _create_property_description_string(self, prop):
"""
Converts the description of the property to a more use-friendly one.
Args:
prop. The property to find the default value of.
Returns:
str: The string to add to the property table description section.
"""
desc = str(prop.documentation.replace("\n", " "))
allowedValueString = str(prop.allowedValues)
# 4 allows for ['']
if len(allowedValueString) > 4:
##make sure the last sentence ended with a full stop (or equivalent)
if (not desc.rstrip().endswith(".")) \
and (not desc.rstrip().endswith("!")) \
and (not desc.rstrip().endswith("?")) \
and (len(desc.strip())>0):
desc += "."
isFileExts = True
for item in prop.allowedValues:
#check it does not look like a file extension
if (not item.startswith(".")) and (not item[-4:].startswith(".")):
isFileExts = False
break
prefixString = " Allowed values: "
if isFileExts:
prefixString = " Allowed extensions: "
#put a space in between entries to allow the line to break
allowedValueString = allowedValueString.replace("','","', '")
desc += prefixString + allowedValueString
return desc
def setup(app):
"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment