rougail-output-doc/src/rougail/output_doc/tabular/six_columns.py

91 lines
3.3 KiB
Python

"""
Silique (https://www.silique.fr)
Copyright (C) 2025
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the
Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
from ..i18n import _
from ..config import ROUGAIL_VARIABLE_TYPE
from .five_columns import Table as FiveTable
class Table(FiveTable):
"""The six columns table"""
name = "six_columns"
level = 70
def clear(self):
super().clear()
self.six_column = False
def _add(self) -> tuple:
first_column = self.add_first_column()
second_column = self.get_column(self.description, self.help_, self.choices, self.examples, self.tags)
if second_column:
self.second_column = True
third_column = self.get_column(self.default)
if third_column:
self.third_column = True
types = self.formatter.property_to_string(
self.informations, self.calculated_properties, self.modified_attributes, contents=["type"],
)
four_column = self.get_column(types)
if four_column:
self.four_column = True
mode = self.formatter.property_to_string(
self.informations, self.calculated_properties, self.modified_attributes, contents=["mode", "access_control"],
)
five_column = self.get_column(mode, *self.calculated_properties)
if five_column:
self.five_column = True
validators = self.formatter.property_to_string(
self.informations, self.calculated_properties, self.modified_attributes, contents=["validator"],
)
six_column = self.get_column(validators, self.validators)
if six_column:
self.six_column = True
return first_column, second_column, third_column, four_column, five_column, six_column
def headers(self) -> tuple:
header = super().headers()
if self.six_column:
header.append(_("Validator"))
return header
def get_columns(self):
for column in self.columns:
ret = [column[0]]
if self.second_column:
ret.append(column[1])
if self.third_column:
ret.append(column[2])
if self.four_column:
ret.append(column[3])
if self.five_column:
ret.append(column[4])
if self.six_column:
ret.append(column[5])
yield ret
def set_properties(self):
self.properties = self.formatter.property_to_string(
self.informations, self.calculated_properties, self.modified_attributes, contents=["properties"],
)
def set_validators(self):
self.validators = self.formatter.convert_section_to_string(
"validators", self.informations, self.modified_attributes, multi=True, section_name=False, with_to_phrase=True,
)