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

64 lines
2.3 KiB
Python
Raw Normal View History

2025-11-29 22:21:06 +01:00
"""
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 .three_columns import Table as ThreeTable
class Table(ThreeTable):
"""The four columns table"""
name = "four_columns"
level = 50
def __init__(self, *args) -> None:
super().__init__(*args)
def _add(self) -> tuple:
first_column = self.get_column(self.paths, self.properties, self.commandlines, self.environments)
if first_column:
self.first_column = True
second_column = self.get_column(self.description, self.help_, self.validators, self.examples, self.tags, *self.calculated_properties)
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_columns = self.get_column(types, self.choices)
return first_column, second_column, third_column, four_columns
def headers(self) -> tuple:
header = super().headers()
header.append(_("Type"))
return header
def get_columns(self):
if not self.second_column or not self.third_column:
raise Exception()
return [[col1] for col1, col2, c in self.columns]
return self.columns
def set_properties(self):
self.properties = self.formatter.property_to_string(
self.informations, self.calculated_properties, self.modified_attributes, contents="properties",
)