rougail-output-doc/src/rougail/output_doc/table/two_columns.py

52 lines
1.8 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 ..utils import CommonTable
class Table(CommonTable):
"""The two columns table"""
name = "two_columns"
level = 10
def __init__(self, *args) -> None:
super().__init__(*args)
self.second_column = False
def _add(self) -> tuple:
default = self.default if not self.default_is_already_set else None
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.choices, default, self.examples, self.tags, *self.calculated_properties)
if second_column:
self.second_column = True
return first_column, second_column
def headers(self) -> tuple:
header = [_("Variable")]
if self.second_column:
header.append(_("Description"))
return header
def get_columns(self):
if not self.second_column:
return [[col1] for col1, col2 in self.columns]
return self.columns