WIP: Expand the developer documentation #27

Draft
gremond wants to merge 226 commits from develop into developer_docs
3 changed files with 24 additions and 8 deletions
Showing only changes of commit 1ee82bede9 - Show all commits

View file

@ -485,7 +485,7 @@ class JinjaCalculation(Calculation):
class _VariableCalculation(Calculation): class _VariableCalculation(Calculation):
variable: StrictStr variable: StrictStr
propertyerror: bool = True propertyerror: Union[Literal["transitive"], bool] = True
allow_none: bool = False allow_none: bool = False
optional: bool = False optional: bool = False

View file

@ -372,8 +372,11 @@ class Common:
params.append("optional=True") params.append("optional=True")
else: else:
param_type = "ParamOption" param_type = "ParamOption"
if not param.get("propertyerror", True): propertyerror = param.get("propertyerror", True)
if not propertyerror:
params.append("notraisepropertyerror=True") params.append("notraisepropertyerror=True")
elif propertyerror == "transitive":
params.append("raisepropertyerror=True")
return f'{param_type}({", ".join(params)})' return f'{param_type}({", ".join(params)})'
def calculation_value( def calculation_value(

View file

@ -353,17 +353,32 @@ class UserData:
_("{0}, it has been loaded from {1}").format(err, options["source"]): option._subconfig} _("{0}, it has been loaded from {1}").format(err, options["source"]): option._subconfig}
) )
continue continue
except AttributeOptionError as err: except AttributeOptionError as err:
if err.code == "option-not-found": if err.code == "option-not-found":
err_path = err.path
if "." not in err_path:
subconfig = None
child_name = err_path
else:
parent_path, child_name = err_path.rsplit('.', 1)
subconfig = self.config.option(parent_path)
subconfig._set_subconfig()
err_msg = _(
'variable or family "{0}" does not exist so cannot load "{1}'
).format(child_name, path)
if self.unknown_user_data_error: if self.unknown_user_data_error:
msg = _( msg = _(
'variable or family "{0}" does not exist, it has been loading from {1}' '{0}, it has been loading from {1}'
) )
else: else:
msg = _( msg = _(
'variable or family "{0}" does not exist, it will be ignored when loading from {1}' '{0}, it will be ignored when loading from {1}'
) )
self.unknowns.append(msg.format(err.path, options["source"])) msg = msg.format(err_msg, options["source"])
if subconfig is not None:
msg = {msg: subconfig._subconfig}
self.unknowns.append(msg)
elif err.code == "option-dynamic": elif err.code == "option-dynamic":
if self.invalid_user_data_error: if self.invalid_user_data_error:
msg = _( msg = _(
@ -373,9 +388,7 @@ class UserData:
msg = _( msg = _(
'"{0}" is the name of a dynamic family, it will be ignored when loading from {1}' '"{0}" is the name of a dynamic family, it will be ignored when loading from {1}'
) )
self.invalids.append( self.invalids.append({msg.format(option.description(with_quote=True), options["source"]): option._subconfig})
{msg.format(option.description(with_quote=True), options["source"]): option._subconfig}
)
else: else:
self.invalids.append( self.invalids.append(
_("{0} loaded from {1}").format(err, options["source"]) _("{0} loaded from {1}").format(err, options["source"])