Skip to content

Commit bc27fee

Browse files
authored
Merge pull request #2028 from strictdoc-project/stanislaw/strictdoc
Bugfix: project_statistics: fix the "Sections without any text" metric
2 parents a8d615c + a2f83f5 commit bc27fee

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

strictdoc/export/html/generators/project_statistics.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ def export(
3939
):
4040
if isinstance(node, SDocSection):
4141
document_tree_stats.total_sections += 1
42-
if len(node.free_texts) == 0:
42+
43+
contains_text_nodes = any(
44+
isinstance(node_, SDocNode)
45+
and node_.node_type == "TEXT"
46+
for node_ in node.section_contents
47+
)
48+
if contains_text_nodes:
4349
document_tree_stats.sections_without_free_text += 1
4450

4551
if isinstance(node, SDocNode):
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
[DOCUMENT]
2+
TITLE: Hello world doc
3+
4+
[SECTION]
5+
TITLE: Section 1 (with text)
6+
7+
[TEXT]
8+
STATEMENT: >>>
9+
Text
10+
<<<
11+
12+
[/SECTION]
13+
14+
[SECTION]
15+
TITLE: Section 2 (with text)
16+
17+
[TEXT]
18+
STATEMENT: >>>
19+
Text
20+
<<<
21+
22+
[/SECTION]
23+
24+
[SECTION]
25+
TITLE: Section 3 (without text)
26+
27+
[/SECTION]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[project]
2+
title = "Test project"
3+
4+
features = [
5+
"PROJECT_STATISTICS_SCREEN",
6+
]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
RUN: %strictdoc export %S --output-dir Output | filecheck %s --dump-input=fail
2+
CHECK: Published: Hello world doc
3+
4+
RUN: %check_exists --file "%S/Output/html/project_statistics.html"
5+
6+
RUN: %cat "%S/Output/html/project_statistics.html" | filecheck %s --dump-input=fail --check-prefix CHECK-HTML
7+
CHECK-HTML: Total sections
8+
CHECK-HTML: 3
9+
CHECK-HTML: Sections without any text
10+
CHECK-HTML: 2
11+
CHECK-HTML: Total requirements
12+
CHECK-HTML: 1

0 commit comments

Comments
 (0)