Skip to content

Commit 52a1166

Browse files
authored
Merge pull request #2456 from strictdoc-project/stanislaw/html2pdf_update
feat(HTML2PDF): integrate --strict mode, split normal tests and HTML2PDF tests
2 parents f2e294c + 190a9b4 commit 52a1166

File tree

12 files changed

+57
-12
lines changed

12 files changed

+57
-12
lines changed

.github/workflows/ci-linux-ubuntu-latest.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
python-version: [
1616
"3.9", "3.12"
1717
]
18+
itest_group: [ "main_group", "html2pdf_group" ]
1819

1920
steps:
2021
- uses: actions/checkout@v3
@@ -38,4 +39,8 @@ jobs:
3839
3940
- name: Run tests
4041
run: |
41-
invoke test
42+
if [ "${{ matrix.itest_group }}" = "html2pdf_group" ]; then
43+
invoke test-integration --html2pdf
44+
else
45+
invoke test
46+
fi

.github/workflows/ci-mac.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ jobs:
1515
python-version: [
1616
"3.9", "3.13"
1717
]
18+
itest_group: [ "main_group", "html2pdf_group" ]
1819

1920
steps:
2021
- uses: actions/checkout@v3
@@ -38,4 +39,8 @@ jobs:
3839
3940
- name: Run tests
4041
run: |
41-
invoke test
42+
if [ "${{ matrix.itest_group }}" = "html2pdf_group" ]; then
43+
invoke test-integration --html2pdf
44+
else
45+
invoke test
46+
fi

.github/workflows/ci-windows-powershell.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
matrix:
1515
python-version: ["3.9"]
1616
shard: ["1/2", "2/2"]
17+
itest_group: [ "main_group", "html2pdf_group" ]
1718

1819
steps:
1920
- uses: actions/checkout@v3
@@ -52,6 +53,11 @@ jobs:
5253
$tidyPath = (Get-ChildItem "C:\ProgramData\chocolatey\lib\html-tidy" -Recurse -Filter tidy.exe | Select-Object -First 1).DirectoryName
5354
echo "$tidyPath" | Out-File -Append -Encoding ascii $env:GITHUB_PATH
5455
55-
- name: Run tests (Powershell)
56+
- name: Run tests
57+
shell: bash
5658
run: |
57-
invoke test --shard=${{ matrix.shard }}
59+
if [ "${{ matrix.itest_group }}" = "html2pdf_group" ]; then
60+
invoke test-integration --html2pdf --shard=${{ matrix.shard }}
61+
else
62+
invoke test --shard=${{ matrix.shard }}
63+
fi

.github/workflows/ci-windows.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ jobs:
1414
matrix:
1515
python-version: ["3.12"]
1616
shard: ["1/2", "2/2"]
17+
itest_group: [ "main_group", "html2pdf_group" ]
1718

1819
steps:
1920
- uses: actions/checkout@v3
@@ -56,7 +57,11 @@ jobs:
5657
run: |
5758
invoke lint
5859
59-
- name: Run tests (Bash)
60-
run: |
61-
invoke test --shard=${{ matrix.shard }}
60+
- name: Run tests
6261
shell: bash
62+
run: |
63+
if [ "${{ matrix.itest_group }}" = "html2pdf_group" ]; then
64+
invoke test-integration --html2pdf --shard=${{ matrix.shard }}
65+
else
66+
invoke test --shard=${{ matrix.shard }}
67+
fi

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ dependencies = [
9191
"WebSockets",
9292

9393
# HTML2PDF dependencies
94-
"html2pdf4doc >= 0.0.21",
94+
"html2pdf4doc >= 0.0.22",
9595

9696
# Robot Framework dependencies
9797
"robotframework >= 4.0.0",

strictdoc.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ features = [
2828
"NESTOR",
2929
]
3030

31-
statistics_generator = "docs.sdoc_project_statistics.SDocStatisticsGenerator"
32-
3331
include_doc_paths = [
3432
"docs/**",
3533
"docs_extra/**",
@@ -66,3 +64,7 @@ test_report_root_dict = [
6664
{ "reports/tests_integration.lit.junit.xml" = "tests/integration" },
6765
{ "reports/tests_integration_html2pdf.lit.junit.xml" = "tests/integration" },
6866
]
67+
68+
html2pdf_strict = false
69+
70+
statistics_generator = "docs.sdoc_project_statistics.SDocStatisticsGenerator"

strictdoc/core/project_config.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ def __init__(
9797
exclude_source_paths: List[str],
9898
test_report_root_dict: Dict[str, str],
9999
source_nodes: List[Dict[str, str]],
100+
html2pdf_strict: bool,
100101
html2pdf_template: Optional[str],
101102
bundle_document_version: Optional[str],
102103
bundle_document_date: Optional[str],
@@ -172,6 +173,7 @@ def __init__(
172173

173174
self.excel_export_fields: Optional[List[str]] = None
174175

176+
self.html2pdf_strict: bool = html2pdf_strict
175177
self.html2pdf_template: Optional[str] = html2pdf_template
176178
self.bundle_document_version: Optional[str] = bundle_document_version
177179
self.bundle_document_date: Optional[str] = bundle_document_date
@@ -226,6 +228,7 @@ def default_config(environment: SDocRuntimeEnvironment) -> "ProjectConfig":
226228
exclude_source_paths=[],
227229
test_report_root_dict={},
228230
source_nodes=[],
231+
html2pdf_strict=False,
229232
html2pdf_template=None,
230233
bundle_document_version=ProjectConfig.DEFAULT_BUNDLE_DOCUMENT_VERSION,
231234
bundle_document_date=ProjectConfig.DEFAULT_BUNDLE_DOCUMENT_COMMIT_DATE,
@@ -505,6 +508,7 @@ def _load_from_dictionary(
505508
exclude_source_paths: List[str] = []
506509
test_report_root_dict: Dict[str, str] = {}
507510
source_nodes: List[Dict[str, str]] = []
511+
html2pdf_strict: bool = False
508512
html2pdf_template: Optional[str] = None
509513
bundle_document_version = ProjectConfig.DEFAULT_BUNDLE_DOCUMENT_VERSION
510514
bundle_document_date = ProjectConfig.DEFAULT_BUNDLE_DOCUMENT_COMMIT_DATE
@@ -626,6 +630,16 @@ def _load_from_dictionary(
626630
f"{exception_} Provided string: '{exclude_source_path}'."
627631
) from exception_
628632

633+
html2pdf_strict = project_content.get(
634+
"html2pdf_strict", html2pdf_strict
635+
)
636+
if html2pdf_strict is not None:
637+
if not isinstance(html2pdf_strict, bool):
638+
raise ValueError(
639+
"strictdoc.toml: 'html2pdf_strict': "
640+
f"must be a true/false value: {html2pdf_strict}."
641+
)
642+
629643
html2pdf_template = project_content.get(
630644
"html2pdf_template", html2pdf_template
631645
)
@@ -757,6 +771,7 @@ def _load_from_dictionary(
757771
exclude_source_paths=exclude_source_paths,
758772
test_report_root_dict=test_report_root_dict,
759773
source_nodes=source_nodes,
774+
html2pdf_strict=html2pdf_strict,
760775
html2pdf_template=html2pdf_template,
761776
bundle_document_version=bundle_document_version,
762777
bundle_document_date=bundle_document_date,

strictdoc/export/html2pdf/pdf_print_driver.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def get_pdf_from_html(
3939
project_config.chromedriver,
4040
]
4141
)
42+
if project_config.html2pdf_strict:
43+
cmd.append("--strict")
4244
for path_to_print_ in paths_to_print:
4345
cmd.append(path_to_print_[0])
4446
cmd.append(path_to_print_[1])

tasks.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,6 @@ def test(context, shard=None):
686686
test_unit(context)
687687
test_unit_server(context)
688688
test_integration(context, shard=shard)
689-
test_integration(context, shard=shard, html2pdf=True)
690689

691690

692691
@task(aliases=["ta"])
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
REQUIRES: PYTHON_39_OR_HIGHER
2+
REQUIRES: PLATFORM_IS_NOT_WINDOWS
3+
REQUIRES: TEST_HTML2PDF
4+
5+
RUN: cd "%strictdoc_root/" && %strictdoc export "%strictdoc_root/" --formats=html2pdf --output-dir="%T"

0 commit comments

Comments
 (0)