diff --git a/atest/second_test_cli.robot b/atest/second_test_cli.robot
index ef5bb1f..a2ab41b 100644
--- a/atest/second_test_cli.robot
+++ b/atest/second_test_cli.robot
@@ -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
diff --git a/atest/test_cli.robot b/atest/test_cli.robot
index d669cda..476fa3c 100644
--- a/atest/test_cli.robot
+++ b/atest/test_cli.robot
@@ -1,5 +1,4 @@
*** Settings ***
-Documentation Basic Console Logging - Suite Doc
Metadata Author=Marvin Klerx
Metadata Creation=March 2025
Test Tags Global-Tag
@@ -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
diff --git a/src/testdoc/html/templates/v2/jinja_template_03.html b/src/testdoc/html/templates/v2/jinja_template_03.html
index f8114b7..fc9a3e0 100644
--- a/src/testdoc/html/templates/v2/jinja_template_03.html
+++ b/src/testdoc/html/templates/v2/jinja_template_03.html
@@ -36,7 +36,7 @@
{% if suite.doc is not none %}
| 📝 Docs: |
- {{ suite.doc }} |
+ {{ suite.doc | join(' ') }} |
{% endif %}
{% if suite.source is not none %}
@@ -50,7 +50,7 @@
{% if suite.metadata is not none %}
| ⚙️ Metadata: |
- {{ suite.metadata }} |
+ {{ suite.metadata | join(' ') }} |
{% endif %}
@@ -82,7 +82,7 @@
{% if test.doc is not none %}
| 📝 Docs: |
- {{ test.doc }} |
+ {{ test.doc | join(' ') }} |
{% endif %}
{% if test.source is not none %}
@@ -141,7 +141,7 @@
{% if suite.doc is not none %}
| 📝 Docs: |
- {{ suite.doc }} |
+ {{ suite.doc | join(' ') }} |
{% endif %}
{% if suite.source is not none %}
@@ -155,7 +155,7 @@
{% if suite.metadata is not none %}
| ⚙️ Metadata: |
- {{ suite.metadata }} |
+ {{ suite.metadata | join(' ') }} |
{% endif %}
diff --git a/src/testdoc/parser/models.py b/src/testdoc/parser/models.py
index 0d6f501..341ef85 100644
--- a/src/testdoc/parser/models.py
+++ b/src/testdoc/parser/models.py
@@ -4,7 +4,7 @@ class SuiteInfoModel(BaseModel):
id: str
filename: str
name: str
- doc: str | None
+ doc: list[str] | None
is_folder: bool
num_tests: int
source: str
@@ -12,11 +12,11 @@ class SuiteInfoModel(BaseModel):
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
\ No newline at end of file
diff --git a/src/testdoc/parser/parser.py b/src/testdoc/parser/parser.py
new file mode 100644
index 0000000..f3a3472
--- /dev/null
+++ b/src/testdoc/parser/parser.py
@@ -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
diff --git a/src/testdoc/parser/testcaseparser.py b/src/testdoc/parser/testcaseparser.py
index fabca84..681c869 100644
--- a/src/testdoc/parser/testcaseparser.py
+++ b/src/testdoc/parser/testcaseparser.py
@@ -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():
@@ -18,9 +19,8 @@ def parse_test(self,
for test in suite.tests:
test_info: TestInfoModel = TestInfoModel(
name=test.name,
- doc="
".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)
)
diff --git a/src/testdoc/parser/testsuiteparser.py b/src/testdoc/parser/testsuiteparser.py
index 0658a00..574dc46 100644
--- a/src/testdoc/parser/testsuiteparser.py
+++ b/src/testdoc/parser/testsuiteparser.py
@@ -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
@@ -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="
".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="
".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": "
".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": "
".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)