WIP: Expand the developer documentation #27

Draft
gremond wants to merge 51 commits from develop into developer_docs
11 changed files with 61 additions and 17 deletions
Showing only changes of commit 4da9a50265 - Show all commits

View file

@ -75,11 +75,11 @@ class Annotator(Walk): # pylint: disable=R0903
self.forbidden_name = []
# default type inference from a default value with :term:`basic types`
self.basic_types = {str: "string", int: "number", bool: "boolean", float: "float"}
self.verify_choices()
self.convert_variable()
self.convert_test()
self.convert_examples()
self.convert_help()
self.verify_choices()
def convert_variable(self):
"""convert variable"""
@ -135,7 +135,7 @@ class Annotator(Walk): # pylint: disable=R0903
return
# copy type and params
calculated_variable_path = variable.default.variable
calculated_variable, suffix = self.objectspace.paths.get_with_dynamic(
calculated_variable, identifier = self.objectspace.paths.get_with_dynamic(
calculated_variable_path, variable.default.path_prefix, variable.path, variable.version, variable.namespace, variable.xmlfiles
)
if calculated_variable is None:
@ -171,15 +171,20 @@ class Annotator(Walk): # pylint: disable=R0903
family = self.objectspace.paths[variable.path.rsplit(".", 1)[0]]
if variable.hidden:
family.hidden = variable.hidden
elif family.hidden:
variable.hidden = family.hidden
# elif family.hidden:
# variable.hidden = family.hidden
variable.hidden = None
if variable.choices is not None and variable.type != 'choice':
msg = _(f'the variable "{variable.path}" has choices attribut but has not the "choice" type')
raise DictConsistencyError(msg, 11, variable.xmlfiles)
if variable.regexp is not None and variable.type != 'regexp':
msg = _(f'the variable "{variable.path}" has regexp attribut but has not the "regexp" type')
raise DictConsistencyError(msg, 37, variable.xmlfiles)
if variable.mandatory is None:
family_path = variable.path
hidden = variable.hidden is True
while '.' in family_path and not hidden:
family_path = family_path.rsplit(".", 1)[0]
family = self.objectspace.paths[family_path]
hidden = family.hidden is True
variable.mandatory = not hidden
def convert_test(self):
"""Convert variable tests value"""
@ -213,8 +218,18 @@ class Annotator(Walk): # pylint: disable=R0903
def verify_choices(self):
for variable in self.get_variables():
if variable.type != 'choice' or variable.default is None:
if variable.type is None and variable.choices:
# choice type inference from the `choices` attribute
variable.type = "choice"
if variable.choices is not None and variable.type != 'choice':
msg = _(f'the variable "{variable.path}" has choices attribut but has not the "choice" type')
raise DictConsistencyError(msg, 11, variable.xmlfiles)
if variable.type != 'choice':
continue
if variable.default is None:
continue
if None in variable.choices and variable.mandatory is None:
variable.mandatory = False
if not isinstance(variable.choices, list):
continue
choices = variable.choices

View file

@ -5,3 +5,4 @@ var:
auto_save: true
hidden: true
default: 'yes'
mandatory: false

View file

@ -4,3 +4,4 @@ var1:
description: a first variable
hidden: true
default: "no"
mandatory: false

View file

@ -3,3 +3,4 @@ version: '1.1'
variable:
redefine: true
hidden: true
mandatory: false

View file

@ -2,5 +2,10 @@
version: '1.1'
leader: # a leadership
type: leadership
leader: [] # a leader
follower: # a follower
leader:
description: a leader
multi: true
mandatory: false
follower:
description: a follower
mandatory: false

View file

@ -11,13 +11,16 @@ my_family:
description: a type family
type: family
my_variable:
mandatory: false
description:
description: This is a other great family
my_variable:
mandatory: false
help:
description: a help family
help: This is a other great family
my_variable:
mandatory: false
mode:
description: a mode family
mode: advanced
@ -27,7 +30,9 @@ my_family:
description: an hidden family
hidden: true
my_variable:
mandatory: false
disabled:
description: an disabled family
disabled: true
my_variable:
mandatory: false

View file

@ -6,6 +6,10 @@ leader:
hidden: true
type: leadership
leader: # a leader
leader:
description: a leader
mandatory: false
follower: # a follower
follower:
description: a follower
mandatory: false

View file

@ -8,5 +8,8 @@ leader:
description: a leader
multi: true
hidden: true
mandatory: false
follower: # a follower
follower:
description: a follower
mandatory: false

View file

@ -7,5 +7,10 @@ leader:
description: a leader
multi: true
hidden: true
follower1: # the follower1
follower2: # the follower2
mandatory: false
follower1:
description: the follower1
mandatory: false
follower2:
description: the follower2
mandatory: false

View file

@ -1,4 +1,6 @@
---
version: '1.1'
leader:
follower3: # follower3
follower3:
description: follower3
mandatory: false

View file

@ -1,4 +1,6 @@
---
version: '1.1'
family: # a family
var: # a variable
var:
description: a variable
mandatory: false