Coverage for sphinx_reports / Workaround.py: 25%
18 statements
« prev ^ index » next coverage.py v7.14.0, created at 2026-05-16 00:05 +0000
« prev ^ index » next coverage.py v7.14.0, created at 2026-05-16 00:05 +0000
1# ==================================================================================================================== #
2# _ _ _ #
3# ___ _ __ | |__ (_)_ __ __ __ _ __ ___ _ __ ___ _ __| |_ ___ #
4# / __| '_ \| '_ \| | '_ \\ \/ /____| '__/ _ \ '_ \ / _ \| '__| __/ __| #
5# \__ \ |_) | | | | | | | |> <_____| | | __/ |_) | (_) | | | |_\__ \ #
6# |___/ .__/|_| |_|_|_| |_/_/\_\ |_| \___| .__/ \___/|_| \__|___/ #
7# |_| |_| #
8# ==================================================================================================================== #
9# Authors: #
10# Patrick Lehmann #
11# #
12# License: #
13# ==================================================================================================================== #
14# Copyright 2023-2026 Patrick Lehmann - Bötzingen, Germany #
15# #
16# Licensed under the Apache License, Version 2.0 (the "License"); #
17# you may not use this file except in compliance with the License. #
18# You may obtain a copy of the License at #
19# #
20# http://www.apache.org/licenses/LICENSE-2.0 #
21# #
22# Unless required by applicable law or agreed to in writing, software #
23# distributed under the License is distributed on an "AS IS" BASIS, #
24# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
25# See the License for the specific language governing permissions and #
26# limitations under the License. #
27# #
28# SPDX-License-Identifier: Apache-2.0 #
29# ==================================================================================================================== #
30#
31"""
32Workarounds for Sphinx and Docutils problems.
33"""
34from docutils.nodes import table
35from docutils.transforms import Transform
36from sphinx.util.logging import getLogger
38logger = getLogger(__name__)
40class FixLatexTableWidths(Transform):
41 default_priority = 500
43 def apply(self):
44 sphinxEnvironment = self.document.settings.env
46 if sphinxEnvironment.app.builder.format != "latex":
47 return
49 # Tables used with Landscape node
50 tableClasses = ("report-unittest-table", "report-codecov-table")
52 # search for all table nodes
53 for tableNode in self.document.findall(table):
54 if (cssClasses := tableNode.get("classes", None)) is None:
55 continue
57 if any(tableClass in cssClasses for tableClass in tableClasses):
58 if 'colwidths-given' not in cssClasses:
59 cssClasses.append('colwidths-given')
61 logger.info("Applied 'colwidths-given' to a table via FixLatexTableWidths transform.", location=tableNode)