Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions atest/second_test_cli.robot
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*** Settings ***
Name Suite 2
Documentation Basic Console Logging - Suite Doc
... Documentation in second line
Metadata Author=Marvin Klerx
Metadata Creation=January 2026
Test Tags Global-Tag
Expand Down
8 changes: 7 additions & 1 deletion atest/test_cli.robot
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
*** Settings ***
Documentation Basic Console Logging - Suite Doc
Metadata Author=Marvin Klerx
Metadata Creation=March 2025
Test Tags Global-Tag
Expand All @@ -8,11 +7,18 @@ Test Tags Global-Tag
*** Test Cases ***
Log Message
[Documentation] Basic Console Logging
... Test Doc in second line
...
... Test doc in third line
... \nfourth line
[Tags] RobotTestDoc

# this is my commentary
Log RobotFramework Test Documentation Generator!

Test without docs
Log Test without Doc


*** Keywords ***
MyUserKeword
Expand Down
10 changes: 5 additions & 5 deletions src/testdoc/html/templates/v2/jinja_template_03.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
{% if suite.doc is not none %}
<tr>
<td style="width: 15%; font-weight: bold; vertical-align: top;">📝 Docs:</td>
<td style="text-align: left;">{{ suite.doc }}</td>
<td style="text-align: left;">{{ suite.doc | join('<br>') }}</td>
</tr>
{% endif %}
{% if suite.source is not none %}
Expand All @@ -50,7 +50,7 @@
{% if suite.metadata is not none %}
<tr>
<td style="width: 15%; font-weight: bold; vertical-align: top;">⚙️ Metadata:</td>
<td style="text-align: left;">{{ suite.metadata }}</td>
<td style="text-align: left;">{{ suite.metadata | join('<br>') }}</td>
</tr>
{% endif %}
</table>
Expand Down Expand Up @@ -82,7 +82,7 @@
{% if test.doc is not none %}
<tr>
<td style="width: 10%; font-weight: bold; vertical-align: top;">📝 Docs:</td>
<td style="text-align: left;">{{ test.doc }}</td>
<td style="text-align: left;">{{ test.doc | join('<br>') }}</td>
</tr>
{% endif %}
{% if test.source is not none %}
Expand Down Expand Up @@ -141,7 +141,7 @@
{% if suite.doc is not none %}
<tr>
<td style="width: 15%; font-weight: bold; vertical-align: top;">📝 Docs:</td>
<td style="text-align: left;">{{ suite.doc }}</td>
<td style="text-align: left;">{{ suite.doc | join('<br>') }}</td>
</tr>
{% endif %}
{% if suite.source is not none %}
Expand All @@ -155,7 +155,7 @@
{% if suite.metadata is not none %}
<tr>
<td style="width: 15%; font-weight: bold; vertical-align: top;">⚙️ Metadata:</td>
<td style="text-align: left;">{{ suite.metadata }}</td>
<td style="text-align: left;">{{ suite.metadata | join('<br>') }}</td>
</tr>
{% endif %}
</table>
Expand Down
8 changes: 4 additions & 4 deletions src/testdoc/parser/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ class SuiteInfoModel(BaseModel):
id: str
filename: str
name: str
doc: str | None
doc: list[str] | None
is_folder: bool
num_tests: int
source: str
total_tests: int = 0
tests: list = []
user_keywords: list | None = None
sub_suites: list = []
metadata: str | None
metadata: list[str] | None

class TestInfoModel(BaseModel):
name: str
doc: str
tags: list
doc: list[str] | None
tags: list | None
source: str
keywords: list[str] | list
17 changes: 17 additions & 0 deletions src/testdoc/parser/parser.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from robot.model.metadata import Metadata
import re

class Parser:

def get_formatted_docs(
self,
doc_string: str | None,
):
if doc_string and doc_string != "":
return re.split(r'(?:\\n|\r?\n)', doc_string.strip())
return None

def get_formatted_metadata(self, metadata_object: Metadata):
if metadata_object:
return [f"{k}" for k, v in metadata_object.items()]
return None
6 changes: 3 additions & 3 deletions src/testdoc/parser/testcaseparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from robot.errors import DataError
from ..helper.cliargs import CommandLineArguments
from .models import SuiteInfoModel, TestInfoModel
from .parser import Parser
import textwrap

class TestCaseParser():
Expand All @@ -18,9 +19,8 @@ def parse_test(self,
for test in suite.tests:
test_info: TestInfoModel = TestInfoModel(
name=test.name,
doc="<br>".join(line.replace("\\n","") for line in test.doc.splitlines()
if line.strip()) if test.doc else "No Test Case Documentation Available",
tags=test.tags if test.tags else ["No Tags Configured"],
doc=Parser().get_formatted_docs(test.doc),
tags=test.tags if test.tags else None,
source=str(test.source),
keywords=self._keyword_parser(test.body)
)
Expand Down
21 changes: 3 additions & 18 deletions src/testdoc/parser/testsuiteparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from ..helper.cliargs import CommandLineArguments
from ..helper.pathconverter import PathConverter
from .models import SuiteInfoModel
from .parser import Parser

from robot.conf import RobotSettings
from robot.running import TestSuiteBuilder
Expand All @@ -37,30 +38,14 @@ def visit_suite(self, suite):
id=str(suite.longname).lower().replace(".", "_").replace(" ", "_"),
filename=str(Path(suite.source).name) if suite.source else suite.name,
name=suite.name,
doc="<br>".join(line.replace("\\n","") for line in suite.doc.splitlines() if line.strip()) if suite.doc else None,
doc=Parser().get_formatted_docs(suite.doc),
is_folder=self._is_directory(suite),
num_tests=len(suite.tests),
source=str(suite.source),
metadata="<br>".join([f"{k} {v}" for k, v in suite.metadata.items()]) if suite.metadata else None,
metadata=Parser().get_formatted_metadata(suite.metadata),
user_keywords=None
)

# Test Suite Parser
# suite_info = {
# "id": str(suite.longname).lower().replace(".", "_").replace(" ", "_"),
# "filename": str(Path(suite.source).name) if suite.source else suite.name,
# "name": suite.name,
# "doc": "<br>".join(line.replace("\\n","") for line in suite.doc.splitlines() if line.strip()) if suite.doc else None,
# "is_folder": self._is_directory(suite),
# "num_tests": len(suite.tests),
# "source": str(suite.source),
# "total_tests": 0,
# "tests": [],
# "user_keywords": [],
# "sub_suites": [],
# "metadata": "<br>".join([f"{k}: {v}" for k, v in suite.metadata.items()]) if suite.metadata else None
# }

# Parse Test Cases
suite_info = TestCaseParser().parse_test(suite, suite_info)

Expand Down