robotframework-testdoc 0.2.6__tar.gz → 0.2.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of robotframework-testdoc might be problematic. Click here for more details.

Files changed (50) hide show
  1. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/PKG-INFO +55 -4
  2. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/README.md +54 -3
  3. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/atest/test_cli.py +1 -1
  4. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/pyproject.toml +1 -1
  5. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/robotframework_testdoc.egg-info/PKG-INFO +55 -4
  6. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/testdoc/cli.py +34 -33
  7. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/testdoc/default.toml +1 -1
  8. robotframework_testdoc-0.2.7/src/testdoc/helper/cliargs.py +100 -0
  9. robotframework_testdoc-0.2.7/src/testdoc/helper/pathconverter.py +30 -0
  10. robotframework_testdoc-0.2.7/src/testdoc/helper/toml_reader.py +50 -0
  11. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/testdoc/html/rendering/render.py +1 -1
  12. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/testdoc/html/themes/theme_config.py +6 -2
  13. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/testdoc/html/themes/themes.py +24 -2
  14. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/testdoc/parser/modifier/sourceprefixmodifier.py +1 -1
  15. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/testdoc/parser/modifier/suitefilemodifier.py +1 -1
  16. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/testdoc/parser/testcaseparser.py +1 -1
  17. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/testdoc/parser/testsuiteparser.py +1 -8
  18. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/testdoc/testdoc.py +2 -5
  19. robotframework_testdoc-0.2.6/src/testdoc/helper/cliargs.py +0 -83
  20. robotframework_testdoc-0.2.6/src/testdoc/helper/pathconverter.py +0 -62
  21. robotframework_testdoc-0.2.6/src/testdoc/helper/toml_reader.py +0 -11
  22. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/.github/workflows/build.yml +0 -0
  23. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/.github/workflows/release.yml +0 -0
  24. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/.gitignore +0 -0
  25. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/LICENSE +0 -0
  26. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/atest/config/config_with_colors.toml +0 -0
  27. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/atest/config/testdoc.toml +0 -0
  28. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/atest/config_pyproject/example_pyproject.toml +0 -0
  29. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/atest/test_cli.robot +0 -0
  30. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/docs/html_v1_common.png +0 -0
  31. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/docs/html_v2_root.png +0 -0
  32. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/docs/html_v2_suitefile.png +0 -0
  33. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/docs/style_blue.png +0 -0
  34. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/docs/style_dark.png +0 -0
  35. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/docs/style_robot.png +0 -0
  36. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/setup.cfg +0 -0
  37. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/robotframework_testdoc.egg-info/SOURCES.txt +0 -0
  38. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/robotframework_testdoc.egg-info/dependency_links.txt +0 -0
  39. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/robotframework_testdoc.egg-info/entry_points.txt +0 -0
  40. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/robotframework_testdoc.egg-info/requires.txt +0 -0
  41. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/robotframework_testdoc.egg-info/top_level.txt +0 -0
  42. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/testdoc/__init__.py +0 -0
  43. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/testdoc/__main__.py +0 -0
  44. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/testdoc/helper/datetimeconverter.py +0 -0
  45. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/testdoc/helper/logger.py +0 -0
  46. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/testdoc/html/images/robotframework.svg +0 -0
  47. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/testdoc/html/templates/v1/jinja_template_01.html +0 -0
  48. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/testdoc/html/templates/v1/jinja_template_02.html +0 -0
  49. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/testdoc/html/templates/v2/jinja_template_03.html +0 -0
  50. {robotframework_testdoc-0.2.6 → robotframework_testdoc-0.2.7}/src/testdoc/html/themes/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: robotframework-testdoc
3
- Version: 0.2.6
3
+ Version: 0.2.7
4
4
  Summary: A CLI Tool to generate a Test Documentation for your RobotFramework Test Scripts.
5
5
  Author-email: Marvin Klerx <marvinklerx20@gmail.com>
6
6
  License: Apache-2.0
@@ -118,6 +118,51 @@ For using this config file, just call the following command:
118
118
  testdoc -c path/to/config.toml tests/ TestDocumentation.html
119
119
  ```
120
120
 
121
+ ### pyproject.toml vs. custom toml file
122
+
123
+ Using the ``pyproject`` requires to define the ``testdoc`` sections with the prefix ``tool.``
124
+ Example section start: ``[tool.testdoc]``
125
+
126
+ Using your own custom toml-file, does not require you to use the prefix. Here, you can just use ``[testdoc]`` as section header.
127
+
128
+
129
+ ### Example Configuration File
130
+ ```toml
131
+ [tool.testdoc]
132
+ title = "New title of HTML document"
133
+ name = "New name of root suite element"
134
+ doc = "New doc text of root suite element"
135
+ sourceprefix = "gitlab::https://gitlab.com/myrepo/repo_path"
136
+ include = ["TagA", "TagB"]
137
+ exclude = ["TagC"]
138
+ hide_tags = true
139
+ hide_test_doc = true
140
+ hide_suite_doc = true
141
+ hide_source = true
142
+ hide_keywords = true
143
+ style = "blue"
144
+ verbose_mode = false
145
+
146
+ [tool.testdoc.metadata]
147
+ Author = "Your-Name"
148
+ Version = "1.0.0"
149
+ Source = "AnySourceAsMetaData"
150
+
151
+ [tool.testdoc.colors]
152
+ # Use predefined theme:
153
+ default = "blue"
154
+ # OR
155
+ # Use custom colors:
156
+ background = "#000028"
157
+ inner_color = "#000028"
158
+ button_active_color = "#193966"
159
+ button_hover_color = "#193966"
160
+ border_color = "#CCCCCC"
161
+ text_color = "#CCCCCC"
162
+ title_color = "#00ffb9"
163
+ robot_icon = "#00ffb9"
164
+ ```
165
+
121
166
  ## HTML Template Selection
122
167
 
123
168
  You can choose between multiple HTML template for the design of your test documentation.
@@ -165,15 +210,21 @@ Therefore, please use the following syntax: for the toml file
165
210
  # Use the default theme
166
211
  default = "default"
167
212
  default = 0
168
- # Use the default theme
213
+ # Use the dark theme
169
214
  default = "dark"
170
215
  default = 1
171
- # Use the default theme
216
+ # Use the blue theme
172
217
  default = "blue"
173
218
  default = 2
174
- # Use the default theme
219
+ # Use the robot theme
175
220
  default = "robot"
176
221
  default = 3
222
+ # Use the dark robot theme
223
+ default = "robot_dark"
224
+ default = 4
225
+ # Use the green theme
226
+ default = "green"
227
+ default = 5
177
228
  ```
178
229
 
179
230
  For setting it via CLI, please use the following:
@@ -95,6 +95,51 @@ For using this config file, just call the following command:
95
95
  testdoc -c path/to/config.toml tests/ TestDocumentation.html
96
96
  ```
97
97
 
98
+ ### pyproject.toml vs. custom toml file
99
+
100
+ Using the ``pyproject`` requires to define the ``testdoc`` sections with the prefix ``tool.``
101
+ Example section start: ``[tool.testdoc]``
102
+
103
+ Using your own custom toml-file, does not require you to use the prefix. Here, you can just use ``[testdoc]`` as section header.
104
+
105
+
106
+ ### Example Configuration File
107
+ ```toml
108
+ [tool.testdoc]
109
+ title = "New title of HTML document"
110
+ name = "New name of root suite element"
111
+ doc = "New doc text of root suite element"
112
+ sourceprefix = "gitlab::https://gitlab.com/myrepo/repo_path"
113
+ include = ["TagA", "TagB"]
114
+ exclude = ["TagC"]
115
+ hide_tags = true
116
+ hide_test_doc = true
117
+ hide_suite_doc = true
118
+ hide_source = true
119
+ hide_keywords = true
120
+ style = "blue"
121
+ verbose_mode = false
122
+
123
+ [tool.testdoc.metadata]
124
+ Author = "Your-Name"
125
+ Version = "1.0.0"
126
+ Source = "AnySourceAsMetaData"
127
+
128
+ [tool.testdoc.colors]
129
+ # Use predefined theme:
130
+ default = "blue"
131
+ # OR
132
+ # Use custom colors:
133
+ background = "#000028"
134
+ inner_color = "#000028"
135
+ button_active_color = "#193966"
136
+ button_hover_color = "#193966"
137
+ border_color = "#CCCCCC"
138
+ text_color = "#CCCCCC"
139
+ title_color = "#00ffb9"
140
+ robot_icon = "#00ffb9"
141
+ ```
142
+
98
143
  ## HTML Template Selection
99
144
 
100
145
  You can choose between multiple HTML template for the design of your test documentation.
@@ -142,15 +187,21 @@ Therefore, please use the following syntax: for the toml file
142
187
  # Use the default theme
143
188
  default = "default"
144
189
  default = 0
145
- # Use the default theme
190
+ # Use the dark theme
146
191
  default = "dark"
147
192
  default = 1
148
- # Use the default theme
193
+ # Use the blue theme
149
194
  default = "blue"
150
195
  default = 2
151
- # Use the default theme
196
+ # Use the robot theme
152
197
  default = "robot"
153
198
  default = 3
199
+ # Use the dark robot theme
200
+ default = "robot_dark"
201
+ default = 4
202
+ # Use the green theme
203
+ default = "green"
204
+ default = 5
154
205
  ```
155
206
 
156
207
  For setting it via CLI, please use the following:
@@ -30,5 +30,5 @@ def test_cli_cmd_verbose():
30
30
  assert result.exit_code == 0
31
31
  assert "Generated" in result.output
32
32
  assert "output.html" in result.output
33
- assert "test_cli.robot" in result.output
33
+ assert "Saving" in result.output
34
34
  assert os.path.exists(output)
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "robotframework-testdoc"
7
- version = "0.2.6"
7
+ version = "0.2.7"
8
8
  description = "A CLI Tool to generate a Test Documentation for your RobotFramework Test Scripts."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.7"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: robotframework-testdoc
3
- Version: 0.2.6
3
+ Version: 0.2.7
4
4
  Summary: A CLI Tool to generate a Test Documentation for your RobotFramework Test Scripts.
5
5
  Author-email: Marvin Klerx <marvinklerx20@gmail.com>
6
6
  License: Apache-2.0
@@ -118,6 +118,51 @@ For using this config file, just call the following command:
118
118
  testdoc -c path/to/config.toml tests/ TestDocumentation.html
119
119
  ```
120
120
 
121
+ ### pyproject.toml vs. custom toml file
122
+
123
+ Using the ``pyproject`` requires to define the ``testdoc`` sections with the prefix ``tool.``
124
+ Example section start: ``[tool.testdoc]``
125
+
126
+ Using your own custom toml-file, does not require you to use the prefix. Here, you can just use ``[testdoc]`` as section header.
127
+
128
+
129
+ ### Example Configuration File
130
+ ```toml
131
+ [tool.testdoc]
132
+ title = "New title of HTML document"
133
+ name = "New name of root suite element"
134
+ doc = "New doc text of root suite element"
135
+ sourceprefix = "gitlab::https://gitlab.com/myrepo/repo_path"
136
+ include = ["TagA", "TagB"]
137
+ exclude = ["TagC"]
138
+ hide_tags = true
139
+ hide_test_doc = true
140
+ hide_suite_doc = true
141
+ hide_source = true
142
+ hide_keywords = true
143
+ style = "blue"
144
+ verbose_mode = false
145
+
146
+ [tool.testdoc.metadata]
147
+ Author = "Your-Name"
148
+ Version = "1.0.0"
149
+ Source = "AnySourceAsMetaData"
150
+
151
+ [tool.testdoc.colors]
152
+ # Use predefined theme:
153
+ default = "blue"
154
+ # OR
155
+ # Use custom colors:
156
+ background = "#000028"
157
+ inner_color = "#000028"
158
+ button_active_color = "#193966"
159
+ button_hover_color = "#193966"
160
+ border_color = "#CCCCCC"
161
+ text_color = "#CCCCCC"
162
+ title_color = "#00ffb9"
163
+ robot_icon = "#00ffb9"
164
+ ```
165
+
121
166
  ## HTML Template Selection
122
167
 
123
168
  You can choose between multiple HTML template for the design of your test documentation.
@@ -165,15 +210,21 @@ Therefore, please use the following syntax: for the toml file
165
210
  # Use the default theme
166
211
  default = "default"
167
212
  default = 0
168
- # Use the default theme
213
+ # Use the dark theme
169
214
  default = "dark"
170
215
  default = 1
171
- # Use the default theme
216
+ # Use the blue theme
172
217
  default = "blue"
173
218
  default = 2
174
- # Use the default theme
219
+ # Use the robot theme
175
220
  default = "robot"
176
221
  default = 3
222
+ # Use the dark robot theme
223
+ default = "robot_dark"
224
+ default = 4
225
+ # Use the green theme
226
+ default = "green"
227
+ default = 5
177
228
  ```
178
229
 
179
230
  For setting it via CLI, please use the following:
@@ -1,5 +1,4 @@
1
1
  import click
2
- import os
3
2
 
4
3
  from .testdoc import TestDoc
5
4
  from .helper.cliargs import CommandLineArguments
@@ -47,8 +46,12 @@ def main(
47
46
  path,
48
47
  output,
49
48
  ):
50
- """
51
- Welcome to robotframework-testdoc - the new test documentation generator for your Robot Framework tests!
49
+ """Welcome to robotframework-testdoc - the new test documentation generator for your Robot Framework tests!
50
+
51
+ # Basic Usage:
52
+ $ testdoc tests/ TestDocumentation.html
53
+
54
+ See more in the README.md of the GitHub Project: https://github.com/MarvKler/robotframework-testdoc/blob/main/README.md
52
55
  """
53
56
  color = "green"
54
57
  entrypoint_msg = """
@@ -62,38 +65,36 @@ def main(
62
65
  click.echo(click.style(entrypoint_msg, fg=color)
63
66
  )
64
67
 
65
- args_instance = CommandLineArguments()
66
- if configfile:
67
- if os.path.exists(configfile):
68
- args_instance.load_from_config_file(configfile)
69
- else:
70
- click.echo(click.style(f"⚠️ Config File not found: {configfile}", fg="yellow"))
68
+ args_to_set = dict(
69
+ title=title,
70
+ name=name,
71
+ doc=doc,
72
+ metadata=dict(item.split("=", 1) for item in metadata) if metadata else None,
73
+ sourceprefix=sourceprefix,
74
+ include=list(include),
75
+ exclude=list(exclude),
76
+ hide_tags=hide_tags,
77
+ hide_test_doc=hide_test_doc,
78
+ hide_suite_doc=hide_suite_doc,
79
+ hide_source=hide_source,
80
+ hide_keywords=hide_keywords,
81
+ style=style,
82
+ html_template=html_template,
83
+ config_file=configfile,
84
+ verbose_mode=verbose,
85
+ suite_file=list(path),
86
+ output_file=output,
87
+ )
88
+
89
+ # Expose CLI args
90
+ args_to_set = {k: v for k, v in args_to_set.items() if v is not None}
91
+ CommandLineArguments().set_args(**args_to_set)
71
92
 
72
- args = args_instance.data
73
- cli_params = {
74
- "title": title or None,
75
- "name": name or None,
76
- "doc": doc or None,
77
- "metadata": dict(item.split("=", 1) for item in metadata) if metadata else None,
78
- "sourceprefix": sourceprefix,
79
- "include": list(include) if include else None,
80
- "exclude": list(exclude) if exclude else None,
81
- "hide_tags": hide_tags or None,
82
- "hide_test_doc": hide_test_doc or None,
83
- "hide_suite_doc": hide_suite_doc or None,
84
- "hide_source": hide_source or None,
85
- "hide_keywords": hide_keywords or None,
86
- "verbose_mode": verbose or None,
87
- "style": style or None,
88
- "html_template": html_template or None,
89
- "config_file": configfile or None,
90
- }
91
- args.suite_file = path
92
- args.output_file = output
93
+ # Read & expose TOML args
94
+ if configfile:
95
+ from .helper.toml_reader import TOMLReader
96
+ TOMLReader().load_from_config_file(configfile)
93
97
 
94
- for key, value in cli_params.items():
95
- if value is not None:
96
- setattr(args, key, value)
97
98
  TestDoc().main()
98
99
 
99
100
  if __name__ == "__main__":
@@ -1,3 +1,3 @@
1
1
  # Find here some default settings like the used default theme
2
2
  [default]
3
- theme = "dark"
3
+ theme = "robot_dark"
@@ -0,0 +1,100 @@
1
+ class CommandLineArguments:
2
+ _instance = None
3
+ def __new__(cls):
4
+ if cls._instance is None:
5
+ cls._instance = super().__new__(cls)
6
+ cls._instance._args = {}
7
+ return cls._instance
8
+
9
+ def update_args_if_not_set(self, **kwargs):
10
+ for key, value in kwargs.items():
11
+ if key not in self._args:
12
+ self._args[key] = value
13
+
14
+ def set_args(self, **kwargs):
15
+ self._args = kwargs
16
+
17
+ def __getattr__(self, name):
18
+ if name in self._args:
19
+ return self._args[name]
20
+ raise AttributeError(f"'CommandLineArguments' object has no attribute '{name}'")
21
+
22
+ @property
23
+ def title(self):
24
+ return self._args.get("title", "Robot Framework - Test Documentation")
25
+
26
+ @property
27
+ def name(self):
28
+ return self._args.get("name", None)
29
+
30
+ @property
31
+ def doc(self):
32
+ return self._args.get("doc", None)
33
+
34
+ @property
35
+ def metadata(self):
36
+ return self._args.get("metadata", None)
37
+
38
+ @property
39
+ def sourceprefix(self):
40
+ return self._args.get("sourceprefix", None)
41
+
42
+ @property
43
+ def include(self):
44
+ return self._args.get("include", [])
45
+
46
+ @property
47
+ def exclude(self):
48
+ return self._args.get("exclude", [])
49
+
50
+ @property
51
+ def hide_tags(self):
52
+ return self._args.get("hide_tags", False)
53
+
54
+ @property
55
+ def hide_test_doc(self):
56
+ return self._args.get("hide_test_doc", False)
57
+
58
+ @property
59
+ def hide_suite_doc(self):
60
+ return self._args.get("hide_suite_doc", False)
61
+
62
+ @property
63
+ def hide_source(self):
64
+ return self._args.get("hide_source", False)
65
+
66
+ @property
67
+ def hide_keywords(self):
68
+ return self._args.get("hide_keywords", False)
69
+
70
+ @property
71
+ def config_file(self):
72
+ return self._args.get("config_file", None)
73
+
74
+ @property
75
+ def verbose_mode(self):
76
+ return self._args.get("verbose_mode", False)
77
+
78
+ @property
79
+ def suite_file(self):
80
+ return self._args.get("suite_file", None)
81
+
82
+ @property
83
+ def style(self):
84
+ return self._args.get("style", None)
85
+
86
+ @property
87
+ def html_template(self):
88
+ return self._args.get("html_template", "v2")
89
+
90
+ @property
91
+ def output_file(self):
92
+ return self._args.get("output_file", None)
93
+
94
+ @property
95
+ def colors(self):
96
+ return self._args.get("colors", None)
97
+
98
+ @property
99
+ def all_as_dict(self):
100
+ return self._args
@@ -0,0 +1,30 @@
1
+ import os
2
+
3
+ from .cliargs import CommandLineArguments
4
+ from .logger import Logger
5
+
6
+ class PathConverter():
7
+
8
+ def __init__(self):
9
+ self.args = CommandLineArguments()
10
+
11
+ def path_convertion(self) -> str:
12
+ output_path = self.args.output_file
13
+ output_path = PathConverter().conv_generic_path(path=output_path)
14
+
15
+ # Print to console
16
+ if self.args.verbose_mode:
17
+ Logger().LogKeyValue("Saving to output file: ", output_path)
18
+ return output_path
19
+
20
+ def conv_generic_path(self,
21
+ path: str
22
+ ) -> str:
23
+ """
24
+ Generate OS independent path.
25
+ """
26
+ abs_path = os.path.abspath(path)
27
+ generic_path = os.path.normpath(abs_path)
28
+ if os.name == "nt":
29
+ generic_path = generic_path.replace("\\", "/")
30
+ return generic_path
@@ -0,0 +1,50 @@
1
+ from .cliargs import CommandLineArguments
2
+
3
+ import tomli
4
+ import os
5
+
6
+ class TOMLReader():
7
+
8
+ ###
9
+ ### Generic function to read toml files
10
+ ###
11
+ def _read_toml(self, file_path:str):
12
+ try:
13
+ with open(file_path, "rb") as f:
14
+ config = tomli.load(f)
15
+ return config
16
+ except Exception as e:
17
+ raise ImportError(f"Cannot read toml file in: {file_path} with error: \n{e}")
18
+
19
+
20
+ ###
21
+ ### Functions to handle TOML files with configuration for testdoc tool
22
+ ###
23
+ def load_from_config_file(self, file_path: str):
24
+ config = TOMLReader()._read_toml(file_path)
25
+ is_pyproject = self._is_pyproject_config(file_path)
26
+
27
+ if is_pyproject:
28
+ self._handle_pyproject_config(config)
29
+ else:
30
+ self._handle_custom_config(config)
31
+
32
+ def _handle_pyproject_config(self, config: dict):
33
+ testdoc_config = config.get("tool", {}).get("testdoc", {})
34
+ self._apply_config_to_cliargs(testdoc_config)
35
+
36
+ def _handle_custom_config(self, config: dict):
37
+ self._apply_config_to_cliargs(config)
38
+
39
+ def _apply_config_to_cliargs(self, config: dict):
40
+ args_to_set = {}
41
+
42
+ for key, value in config.items():
43
+ if isinstance(value, tuple):
44
+ value = list(value)
45
+ args_to_set[key] = value
46
+
47
+ CommandLineArguments().update_args_if_not_set(**args_to_set)
48
+
49
+ def _is_pyproject_config(self, file_path) -> bool:
50
+ return os.path.basename(file_path) == "pyproject.toml"
@@ -9,7 +9,7 @@ from ...helper.logger import Logger
9
9
  class TestDocHtmlRendering():
10
10
 
11
11
  def __init__(self):
12
- self.args = CommandLineArguments().data
12
+ self.args = CommandLineArguments()
13
13
  self._html_templ_selection()
14
14
 
15
15
  def _html_templ_selection(self):
@@ -1,5 +1,5 @@
1
1
  from ...helper.cliargs import CommandLineArguments
2
- from .themes import DEFAULT_THEME, ROBOT_THEME, DARK_THEME, BLUE_THEME
2
+ from .themes import DEFAULT_THEME, ROBOT_THEME, DARK_THEME, BLUE_THEME, ROBOT_THEME_DARK, GREEN_THEME
3
3
 
4
4
  import os
5
5
  import tomli
@@ -9,7 +9,7 @@ class ThemeConfig():
9
9
  default_config = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "default.toml")
10
10
 
11
11
  def __init__(self):
12
- self.args = CommandLineArguments().data
12
+ self.args = CommandLineArguments()
13
13
  with open(self.default_config, "rb") as file:
14
14
  self.config = tomli.load(file)
15
15
 
@@ -38,4 +38,8 @@ class ThemeConfig():
38
38
  return ROBOT_THEME
39
39
  if theme == "blue" or theme == 3:
40
40
  return BLUE_THEME
41
+ if theme == "robot_dark" or theme == 4:
42
+ return ROBOT_THEME_DARK
43
+ if theme == "green" or theme == 5:
44
+ return GREEN_THEME
41
45
 
@@ -13,14 +13,36 @@ DEFAULT_THEME = {
13
13
  ROBOT_THEME = {
14
14
  "background": "#f8f9fa",
15
15
  "inner_color": "#f8f9fa",
16
- "button_active_color": "#C2C2C2",
17
- "button_hover_color": "#C2C2C2",
16
+ "button_active_color": "#dcdcdc",
17
+ "button_hover_color": "#dcdcdc",
18
18
  "border_color": "black",
19
19
  "text_color": "black",
20
20
  "title_color": "black",
21
21
  "robot_icon": "#00c0b5",
22
22
  }
23
23
 
24
+ ROBOT_THEME_DARK = {
25
+ "background": "#1b1b1d",
26
+ "inner_color": "#1b1b1d",
27
+ "button_active_color": "#272729",
28
+ "button_hover_color": "#5F5F5F",
29
+ "border_color": "#e3e3e3",
30
+ "text_color": "#e3e3e3",
31
+ "title_color": "#e3e3e3",
32
+ "robot_icon": "#00c0b5",
33
+ }
34
+
35
+ GREEN_THEME = {
36
+ "background": "#1e1e1e",
37
+ "inner_color": "#1e1e1e",
38
+ "button_active_color": "#272729",
39
+ "button_hover_color": "#5F5F5F",
40
+ "border_color": "#e3e3e3",
41
+ "text_color": "#009770",
42
+ "title_color": "#009770",
43
+ "robot_icon": "#009770",
44
+ }
45
+
24
46
  DARK_THEME = {
25
47
  "background": "#303030",
26
48
  "inner_color": "#303030",
@@ -39,7 +39,7 @@ class SourcePrefixModifier():
39
39
  GITLAB_CONNECTOR = "-/blob/main/"
40
40
 
41
41
  def __init__(self):
42
- self.args = CommandLineArguments().data
42
+ self.args = CommandLineArguments()
43
43
 
44
44
  def _prefix_validation(self, prefix: str) -> list:
45
45
  if "::" not in prefix:
@@ -7,7 +7,7 @@ from .sourceprefixmodifier import SourcePrefixModifier
7
7
  class SuiteFileModifier():
8
8
 
9
9
  def __init__(self):
10
- self.args = CommandLineArguments().data
10
+ self.args = CommandLineArguments()
11
11
  self.suite = None
12
12
 
13
13
  #############################################################################################################################
@@ -7,7 +7,7 @@ import textwrap
7
7
  class TestCaseParser():
8
8
 
9
9
  def __init__(self):
10
- self.args = CommandLineArguments().data
10
+ self.args = CommandLineArguments()
11
11
 
12
12
  def parse_test(self,
13
13
  suite: TestSuite,
@@ -21,7 +21,7 @@ class RobotSuiteParser(SuiteVisitor):
21
21
  self.suite_counter = 0
22
22
  self.suites = []
23
23
  self.tests = []
24
- self.args = CommandLineArguments().data
24
+ self.args = CommandLineArguments()
25
25
 
26
26
  def visit_suite(self, suite):
27
27
 
@@ -95,13 +95,6 @@ class RobotSuiteParser(SuiteVisitor):
95
95
  _include = self.args.include
96
96
  _exclude = self.args.exclude
97
97
  _source = self.args.suite_file
98
- # Type Conversions
99
- if type(_include) is not list:
100
- _include = list(_include)
101
- if type(_exclude) is not list:
102
- _exclude = list(_exclude)
103
- if type(_source) is not list:
104
- _source = list(_source)
105
98
 
106
99
  # Format / Syntax Conversions
107
100
  robot_options = []
@@ -5,10 +5,7 @@ from .parser.modifier.suitefilemodifier import SuiteFileModifier
5
5
 
6
6
  class TestDoc():
7
7
 
8
- def main(self):
9
- # Convert to correct pathes
10
- suite_path, output_path, config_path = PathConverter().path_convertion()
11
-
8
+ def main(self):
12
9
  # Parse suite object & return complete suite object with all information
13
10
  suite_object = RobotSuiteParser().parse_suite()
14
11
 
@@ -16,4 +13,4 @@ class TestDoc():
16
13
  suite_object = SuiteFileModifier().run(suite_object)
17
14
 
18
15
  # Render HTML file
19
- TestDocHtmlRendering().render_testdoc(suite_object, output_path)
16
+ TestDocHtmlRendering().render_testdoc(suite_object, PathConverter().path_convertion())
@@ -1,83 +0,0 @@
1
- from dataclasses import dataclass, field
2
- from typing import Any, List
3
- from .toml_reader import TOMLReader
4
- import os
5
-
6
- @dataclass
7
- class CommandLineArgumentsData:
8
- title: str = "Robot Framework - Test Documentation"
9
- name: str = None
10
- doc: str = None
11
- metadata: dict = None
12
- sourceprefix: str = None
13
- include: List[str] = field(default_factory=list)
14
- exclude: List[str] = field(default_factory=list)
15
- hide_tags: bool = False
16
- hide_test_doc: bool = False
17
- hide_suite_doc: bool = False
18
- hide_source: bool = False
19
- hide_keywords: bool = False
20
- config_file: str = None
21
- verbose_mode: bool = False
22
- suite_file: str = None
23
- style: str = None
24
- html_template: str = "v2"
25
- output_file: str = None
26
- colors: dict = None
27
-
28
- class CommandLineArguments:
29
- _instance = None
30
- def __new__(cls):
31
- if cls._instance is None:
32
- cls._instance = super().__new__(cls)
33
-
34
- cls.data = CommandLineArgumentsData()
35
- return cls._instance
36
-
37
- ###
38
- ### Load configuration file
39
- ###
40
- def load_from_config_file(self, file_path: str):
41
- config = TOMLReader()._read_toml(file_path)
42
- _is_pyproject = self._is_pyproject_config(file_path)
43
- if _is_pyproject:
44
- self._handle_pyproject_config(config)
45
- else:
46
- self._handle_custom_config(config)
47
-
48
- ###
49
- ### Read pyproject.toml
50
- ###
51
- def _handle_pyproject_config(self, config: dict[str, Any]):
52
- testdoc_config = config.get("tool", {}).get("testdoc", {})
53
-
54
- if "colors" in testdoc_config:
55
- self.data.colors = testdoc_config["colors"]
56
-
57
- if "metadata" in testdoc_config:
58
- if hasattr(self.data, "metadata"):
59
- setattr(self.data, "metadata", testdoc_config["metadata"])
60
-
61
- for key, value in testdoc_config.items():
62
- if key in ("colors", "metadata"):
63
- continue
64
- if hasattr(self.data, key):
65
- setattr(self.data, key, value)
66
-
67
- ###
68
- ### Read custom.toml
69
- ###
70
- def _handle_custom_config(self, config: dict[str, Any]):
71
- if "colors" in config:
72
- self.data.colors = config["colors"]
73
-
74
- for key, value in config.items():
75
- if hasattr(self.data, key):
76
- setattr(self.data, key, value)
77
-
78
- #####################################################################################
79
-
80
- def _is_pyproject_config(self, file_path) -> bool:
81
- return os.path.basename(file_path) == "pyproject.toml"
82
-
83
- #####################################################################################
@@ -1,62 +0,0 @@
1
- import os
2
-
3
- from .cliargs import CommandLineArguments
4
- from .logger import Logger
5
-
6
- class PathConverter():
7
-
8
- def __init__(self):
9
- self.args = CommandLineArguments().data
10
-
11
- def path_convertion(self) -> str:
12
-
13
- suite_path = self.args.suite_file
14
- output_path = self.args.output_file
15
- config_path = self.args.config_file
16
-
17
- # Convert path to suite file / directory
18
- if type(suite_path) is tuple:
19
- suite_path = list(suite_path)
20
- for idx, item in enumerate(suite_path):
21
- _mod = PathConverter().conv_generic_path(item)
22
- suite_path[idx] = _mod
23
- else:
24
- suite_path = PathConverter().conv_generic_path(path=suite_path)
25
-
26
- # Convert path to output file
27
- output_path = PathConverter().conv_generic_path(path=output_path)
28
-
29
- # Convert path to config file
30
- if self.args.config_file:
31
- config_path = PathConverter().conv_generic_path(path=config_path)
32
-
33
- # Print to console
34
- if self.args.verbose_mode:
35
- msg = ""
36
- if type(suite_path) is not list:
37
- suite_path = list(suite_path)
38
-
39
- for item in suite_path:
40
- if ".robot" in suite_path:
41
- msg += f'Suite File: "{str(suite_path).split("/")[-1]}"\n'
42
- else:
43
- msg += f"Suite Directory: '{suite_path}'\n"
44
-
45
- Logger().Log("=== TestDoc ===")
46
- Logger().LogKeyValue("Generating Test Documentation for: ", msg)
47
- Logger().LogKeyValue("Saving to output file: ", output_path)
48
- Logger().LogKeyValue("Using config file: ", config_path) if config_path else None
49
-
50
- return suite_path, output_path, config_path
51
-
52
- def conv_generic_path(self,
53
- path: str
54
- ) -> str:
55
- """
56
- Generate OS independent path.
57
- """
58
- abs_path = os.path.abspath(path)
59
- generic_path = os.path.normpath(abs_path)
60
- if os.name == "nt":
61
- generic_path = generic_path.replace("\\", "/")
62
- return generic_path
@@ -1,11 +0,0 @@
1
- import tomli
2
-
3
- class TOMLReader():
4
-
5
- def _read_toml(self, file_path:str):
6
- try:
7
- with open(file_path, "rb") as f:
8
- config = tomli.load(f)
9
- return config
10
- except Exception as e:
11
- raise ImportError(f"Cannot read toml file in: {file_path} with error: \n{e}")