feat: can document a variable for a specified identifier
This commit is contained in:
parent
b4ce22a0af
commit
a92f447478
1 changed files with 19 additions and 11 deletions
|
|
@ -222,6 +222,7 @@ class CommonFormater:
|
||||||
self,
|
self,
|
||||||
informations: dict,
|
informations: dict,
|
||||||
modified_attributes: dict,
|
modified_attributes: dict,
|
||||||
|
force_identifiers: Optional[str],
|
||||||
) -> str:
|
) -> str:
|
||||||
ret_paths = []
|
ret_paths = []
|
||||||
path = informations["path"]
|
path = informations["path"]
|
||||||
|
|
@ -237,6 +238,8 @@ class CommonFormater:
|
||||||
new = []
|
new = []
|
||||||
if "identifiers" in informations:
|
if "identifiers" in informations:
|
||||||
for identifier in informations["identifiers"]:
|
for identifier in informations["identifiers"]:
|
||||||
|
if force_identifiers and identifier != force_identifiers:
|
||||||
|
continue
|
||||||
path_ = calc_path(path, self, identifier)
|
path_ = calc_path(path, self, identifier)
|
||||||
if identifier in new:
|
if identifier in new:
|
||||||
path_ = self.underline(path_)
|
path_ = self.underline(path_)
|
||||||
|
|
@ -299,7 +302,7 @@ class CommonFormater:
|
||||||
informations = value["informations"]
|
informations = value["informations"]
|
||||||
msg.append(self.namespace_to_title(informations, ori_level))
|
msg.append(self.namespace_to_title(informations, ori_level))
|
||||||
msg.append(self.family_informations())
|
msg.append(self.family_informations())
|
||||||
msg.extend(self.display_paths(informations, {}))
|
msg.extend(self.display_paths(informations, {}, None))
|
||||||
msg.append(self.after_family_paths())
|
msg.append(self.after_family_paths())
|
||||||
msg.append(
|
msg.append(
|
||||||
self.property_to_string(informations, {}, {})[1] + ENTER
|
self.property_to_string(informations, {}, {})[1] + ENTER
|
||||||
|
|
@ -327,7 +330,7 @@ class CommonFormater:
|
||||||
"""manage namespace family"""
|
"""manage namespace family"""
|
||||||
return self.title(
|
return self.title(
|
||||||
_('Variables for "{0}"').format(
|
_('Variables for "{0}"').format(
|
||||||
self.get_description("family", informations)
|
self.get_description("family", informations, {}, None)
|
||||||
),
|
),
|
||||||
level,
|
level,
|
||||||
)
|
)
|
||||||
|
|
@ -337,14 +340,14 @@ class CommonFormater:
|
||||||
|
|
||||||
def family_to_string(self, informations: dict, level: int) -> str:
|
def family_to_string(self, informations: dict, level: int) -> str:
|
||||||
"""manage other family type"""
|
"""manage other family type"""
|
||||||
msg = [self.title(self.get_description("family", informations), level)]
|
msg = [self.title(self.get_description("family", informations, {}, None), level)]
|
||||||
helps = informations.get("help")
|
helps = informations.get("help")
|
||||||
if helps:
|
if helps:
|
||||||
for help_ in helps:
|
for help_ in helps:
|
||||||
msg.append(self.display_family_help(help_.strip()))
|
msg.append(self.display_family_help(help_.strip()))
|
||||||
msg.append(self.family_informations())
|
msg.append(self.family_informations())
|
||||||
msg.append(
|
msg.append(
|
||||||
self.join(self.display_paths(informations, {})) + self.after_family_paths()
|
self.join(self.display_paths(informations, {}, None)) + self.after_family_paths()
|
||||||
)
|
)
|
||||||
calculated_properties = []
|
calculated_properties = []
|
||||||
msg.append(
|
msg.append(
|
||||||
|
|
@ -392,13 +395,13 @@ class CommonFormater:
|
||||||
return self.stripped(self.join(datas))
|
return self.stripped(self.join(datas))
|
||||||
|
|
||||||
def get_description(
|
def get_description(
|
||||||
self, type_: str, informations: dict, modified_attributes: dict = {}
|
self, type_: str, informations: dict, modified_attributes: dict, force_identifiers: Optional[str]
|
||||||
) -> str():
|
) -> str():
|
||||||
def _get_description(description, identifiers, delete=False, new=[]):
|
def _get_description(description, identifiers, delete=False, new=[]):
|
||||||
if "{{ identifier }}" in description:
|
if "{{ identifier }}" in description:
|
||||||
if type_ == "variable":
|
if type_ == "variable":
|
||||||
identifiers_text = display_list(
|
identifiers_text = display_list(
|
||||||
[self.italic(i[-1]) for i in identifiers], separator="or"
|
[self.italic(i[-1]) for i in identifiers if not force_identifiers or i == force_identifiers], separator="or"
|
||||||
)
|
)
|
||||||
description = description.replace(
|
description = description.replace(
|
||||||
"{{ identifier }}", identifiers_text
|
"{{ identifier }}", identifiers_text
|
||||||
|
|
@ -406,6 +409,8 @@ class CommonFormater:
|
||||||
else:
|
else:
|
||||||
d = []
|
d = []
|
||||||
for i in identifiers:
|
for i in identifiers:
|
||||||
|
if force_identifiers and i != force_identifiers:
|
||||||
|
continue
|
||||||
new_description = description.replace(
|
new_description = description.replace(
|
||||||
"{{ identifier }}", self.italic(i[-1])
|
"{{ identifier }}", self.italic(i[-1])
|
||||||
)
|
)
|
||||||
|
|
@ -442,12 +447,12 @@ class CommonFormater:
|
||||||
|
|
||||||
# VARIABLE
|
# VARIABLE
|
||||||
def variable_to_string(
|
def variable_to_string(
|
||||||
self, informations: dict, table_datas: list, modified_attributes: dict = {}
|
self, informations: dict, table_datas: list, modified_attributes: dict = {}, force_identifiers: Optional[str]=None
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Manage variable"""
|
"""Manage variable"""
|
||||||
calculated_properties = []
|
calculated_properties = []
|
||||||
multi, first_column = self.variable_first_column(
|
multi, first_column = self.variable_first_column(
|
||||||
informations, calculated_properties, modified_attributes
|
informations, calculated_properties, modified_attributes, force_identifiers
|
||||||
)
|
)
|
||||||
table_datas.append(
|
table_datas.append(
|
||||||
[
|
[
|
||||||
|
|
@ -457,7 +462,8 @@ class CommonFormater:
|
||||||
informations,
|
informations,
|
||||||
calculated_properties,
|
calculated_properties,
|
||||||
modified_attributes,
|
modified_attributes,
|
||||||
multi=multi,
|
multi,
|
||||||
|
force_identifiers,
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
|
@ -468,13 +474,14 @@ class CommonFormater:
|
||||||
informations: dict,
|
informations: dict,
|
||||||
calculated_properties: list,
|
calculated_properties: list,
|
||||||
modified_attributes: Optional[dict],
|
modified_attributes: Optional[dict],
|
||||||
|
force_identifiers: Optional[str],
|
||||||
) -> list:
|
) -> list:
|
||||||
"""Collect string for the first column"""
|
"""Collect string for the first column"""
|
||||||
multi, properties = self.property_to_string(
|
multi, properties = self.property_to_string(
|
||||||
informations, calculated_properties, modified_attributes
|
informations, calculated_properties, modified_attributes
|
||||||
)
|
)
|
||||||
first_col = [
|
first_col = [
|
||||||
self.join(self.display_paths(informations, modified_attributes)),
|
self.join(self.display_paths(informations, modified_attributes, force_identifiers)),
|
||||||
properties,
|
properties,
|
||||||
]
|
]
|
||||||
self.columns(first_col)
|
self.columns(first_col)
|
||||||
|
|
@ -486,13 +493,14 @@ class CommonFormater:
|
||||||
calculated_properties: list,
|
calculated_properties: list,
|
||||||
modified_attributes: dict,
|
modified_attributes: dict,
|
||||||
multi: bool,
|
multi: bool,
|
||||||
|
force_identifiers: Optional[str],
|
||||||
) -> list:
|
) -> list:
|
||||||
"""Collect string for the second column"""
|
"""Collect string for the second column"""
|
||||||
second_col = []
|
second_col = []
|
||||||
#
|
#
|
||||||
if "description" in informations:
|
if "description" in informations:
|
||||||
description = self.get_description(
|
description = self.get_description(
|
||||||
"variable", informations, modified_attributes
|
"variable", informations, modified_attributes, force_identifiers,
|
||||||
)
|
)
|
||||||
second_col.append(description)
|
second_col.append(description)
|
||||||
#
|
#
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue