Skip to content
Merged
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
32 changes: 32 additions & 0 deletions atest/config_pyproject/example_pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[tool.testdoc]
title = "New title of HTML document"
name = "New name of root suite element"
doc = "New doc text of root suite element"
sourceprefix = "gitlab::https://gitlab.com/myrepo/repo_path"
include = ["TagA", "TagB"]
exclude = ["TagC"]
hide_tags = true
hide_test_doc = true
hide_suite_doc = true
hide_source = true
hide_keywords = true
style = "blue"
verbose_mode = false

[tool.testdoc.metadata]
Author = "Your-Name"
Version = "1.0.0"
Source = "AnySourceAsMetaData"

[tool.testdoc.colors]
# Use predefined theme:
default = "blue"
# or custom colors:
background = "#000028"
inner_color = "#000028"
button_active_color = "#193966"
button_hover_color = "#193966"
border_color = "#CCCCCC"
text_color = "#CCCCCC"
title_color = "#00ffb9"
robot_icon = "#00ffb9"
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "robotframework-testdoc"
version = "0.1.7"
version = "0.1.8"
description = "A CLI Tool to generate a Test Documentation for your RobotFramework Test Scripts."
readme = "README.md"
requires-python = ">=3.7"
Expand All @@ -25,4 +25,4 @@ testdoc = "testdoc.cli:main"
line-length = 150
lint.select = ["E", "F"] # Pyflakes & pycodestyle
lint.ignore = ["E722"]
exclude = ["build", "dist"]
exclude = ["build", "dist"]
5 changes: 3 additions & 2 deletions src/testdoc/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ def main(
Welcome to robotframework-testdoc - the new test documentation generator for your Robot Framework tests!
"""
color = "green"
click.echo(click.style("""
entrypoint_msg = """
████████╗███████╗███████╗████████╗██████╗ ███████╗███████╗
╚══██╔══╝██╔════╝██╔════╝╚══██╔══╝██ ██╗██ ██║██╔════╝
██║ █████╗ ███████╗ ██║ ██ ██║██ ██║██║
██║ ██╔══╝ ╚════██║ ██║ ██ ██║██ ██║██║
██║ ███████╗███████║ ██║ ██████╔╝███████║███████╗
╚═╝ ╚══════╝╚══════╝ ╚═╝ ╚═════╝ ╚══════╝ ╚═════╝
""", fg=color)
"""
click.echo(click.style(entrypoint_msg, fg=color)
)

args_instance = CommandLineArguments()
Expand Down
44 changes: 42 additions & 2 deletions src/testdoc/helper/cliargs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from dataclasses import dataclass, field
from typing import List
from typing import Any, List
import tomli
import os

@dataclass
class CommandLineArgumentsData:
Expand Down Expand Up @@ -32,13 +33,52 @@ def __new__(cls):
cls.data = CommandLineArgumentsData()
return cls._instance

###
### Load configuration file
###
def load_from_config_file(self, file_path: str):
with open(file_path, "rb") as f:
config = tomli.load(f)

_is_pyproject = self._is_pyproject_config(file_path)
if _is_pyproject:
self._handle_pyproject_config(config)
else:
self._handle_custom_config(config)

###
### Read pyproject.toml
###
def _handle_pyproject_config(self, config: dict[str, Any]):
testdoc_config = config.get("tool", {}).get("testdoc", {})

if "colors" in testdoc_config:
self.data.colors = testdoc_config["colors"]

if "metadata" in testdoc_config:
if hasattr(self.data, "metadata"):
setattr(self.data, "metadata", testdoc_config["metadata"])

for key, value in testdoc_config.items():
if key in ("colors", "metadata"):
continue
if hasattr(self.data, key):
setattr(self.data, key, value)

###
### Read custom.toml
###
def _handle_custom_config(self, config: dict[str, Any]):
if "colors" in config:
self.data.colors = config["colors"]

for key, value in config.items():
if hasattr(self.data, key):
setattr(self.data, key, value)
setattr(self.data, key, value)

#####################################################################################

def _is_pyproject_config(self, file_path) -> bool:
return os.path.basename(file_path) == "pyproject.toml"

#####################################################################################
14 changes: 9 additions & 5 deletions src/testdoc/parser/testcaseparser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from robot.api import TestSuite
from robot.errors import DataError
from ..helper.cliargs import CommandLineArguments

class TestCaseParser():
Expand All @@ -25,8 +26,11 @@ def parse_test(self,

# Consider tags via officially provided robot api
def consider_tags(self, suite: TestSuite) -> TestSuite:
if len(self.args.include) > 0:
suite.configure(include_tags=self.args.include)
if len(self.args.exclude) > 0:
suite.configure(exclude_tags=self.args.exclude)
return suite
try:
if len(self.args.include) > 0:
suite.configure(include_tags=self.args.include)
if len(self.args.exclude) > 0:
suite.configure(exclude_tags=self.args.exclude)
return suite
except DataError as e:
raise DataError(e.message)