diff --git a/.github/workflows/build-publish.yml b/.github/workflows/build-publish.yml index 3481b54..8e02768 100644 --- a/.github/workflows/build-publish.yml +++ b/.github/workflows/build-publish.yml @@ -28,21 +28,23 @@ jobs: - name: Install Build Dependencies run: | python -m pip install --upgrade pip - pip install build ruff + pip install build ruff pytest - - name: Lint with ruff + - name: Lint with Ruff run: ruff check . - - name: Build package + - name: Build Package run: python -m build - - name: Test CLI command + - name: Test CLI Command run: | pip install . testdoc --help - # - name: Publish to TestPyPI (only on main) - # if: github.event_name == 'push' && github.ref == 'refs/heads/main' + - name: Run Unit Tests + run: pytest atest/ + + # - name: Publish to TestPyPI # env: # TWINE_USERNAME: __token__ # TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..bef0f1d --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,49 @@ +name: Release on Tag + +on: + push: + tags: + - 'v*.*.*' + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.12' + + - name: Install Dependencies + run: | + python -m pip install --upgrade pip + pip install build twine tomli + + - name: Check Tag Matches pyproject.toml Version + run: | + VERSION_IN_FILE=$(python -c "import tomli; print(tomli.load(open('pyproject.toml', 'rb'))['project']['version'])") + TAG_VERSION=${GITHUB_REF#refs/tags/v} + echo "Version in pyproject.toml: $VERSION_IN_FILE" + echo "Git Tag Version: $TAG_VERSION" + if [ "$VERSION_IN_FILE" != "$TAG_VERSION" ]; then + echo "Version mismatch between createdxtag and pyproject.toml" + exit 1 + fi + + - name: Build Package + run: python -m build + + - name: Publish to PyPI + env: + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: twine upload dist/* + + - name: Create GitHub Release + uses: softprops/action-gh-release@v1 + with: + generate_release_notes: true diff --git a/.gitignore b/.gitignore index cf8df6f..2e1f4a9 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,8 @@ src/robotframework_testdoc.egg-info/** .vscode/launch.json .vscode/ dist/ -*.egg-info/ \ No newline at end of file +*.egg-info/ +output_doc.html +output.html +src/testdoc/html/templates/jinja_template_02.html +image.png diff --git a/README.md b/README.md index 9f1c384..8db1aae 100644 --- a/README.md +++ b/README.md @@ -82,3 +82,52 @@ For using this config file, just call the following command: # Generate docu with options defined in TOML file testdoc -c path/to/config.toml tests/ TestDocumentation.html ``` + +## Theme Selection / Color Configuration + +You can select between several themes (color configurations) for your HTML document to create! + +> [!CAUTION] +> This is only possible via toml-configuration file, but not via cmd args directly! + +### Default Themes + +There are a few predefined default themes available that you can choose via the toml-configuration file. +Therefore, please use the following syntax: +```toml +[colors] +# Use the default theme +default = "default" +default = 0 +# Use the default theme +default = "dark" +default = 1 +# Use the default theme +default = "blue" +default = 2 +# Use the default theme +default = "robot" +default = 3 +``` + +> [!TIP] +> You can select the default theme using either a string value or an integer value. + +### Custom Themes + +You can apply your own custom theme to modify the colors of the created HTML document. +Use the following syntax & parameters in your toml-configuration file, to overwrite the predefined themes: +```toml +[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" +```^ + +> [!TIP] +> Please make sure to configure all available color values from this example — missing values may cause layout or rendering issues in the generated HTML document! diff --git a/atest/config/config_with_colors.toml b/atest/config/config_with_colors.toml new file mode 100644 index 0000000..193392a --- /dev/null +++ b/atest/config/config_with_colors.toml @@ -0,0 +1,16 @@ +sourceprefix = "gitlab::https://gitlab.com/myrepo/repo_path" +hide_suite_doc = true +verbose_mode = true + +[colors] +# DEFAULT THEME: +default = "robot" +# OR CUSTOM THEME: +# 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" diff --git a/atest/test_cli.py b/atest/test_cli.py new file mode 100644 index 0000000..686bdcb --- /dev/null +++ b/atest/test_cli.py @@ -0,0 +1,34 @@ +import os +from click.testing import CliRunner +from testdoc.cli import main + +def test_cli_help(): + runner = CliRunner() + result = runner.invoke(main, ["--help"]) + assert result.exit_code == 0 + assert "Usage" in result.output + assert "Welcome" in result.output + +def test_cli_cmd(): + current_dir = os.path.dirname(os.path.abspath(__file__)) + robot = os.path.join(current_dir, "test_cli.robot") + output = os.path.join(current_dir, "output.html") + runner = CliRunner() + result = runner.invoke(main, [robot, output]) + assert result.exit_code == 0 + assert "Generated" in result.output + assert "output.html" in result.output + assert os.path.exists(output) + + +def test_cli_cmd_verbose(): + current_dir = os.path.dirname(os.path.abspath(__file__)) + robot = os.path.join(current_dir, "test_cli.robot") + output = os.path.join(current_dir, "output.html") + runner = CliRunner() + result = runner.invoke(main, [robot, output, "-v"]) + assert result.exit_code == 0 + assert "Generated" in result.output + assert "output.html" in result.output + assert "test_cli.robot" in result.output + assert os.path.exists(output) diff --git a/atest/test_cli.robot b/atest/test_cli.robot new file mode 100644 index 0000000..4cb86c5 --- /dev/null +++ b/atest/test_cli.robot @@ -0,0 +1,12 @@ +*** Settings *** +Documentation Basic Console Logging - Suite Doc +Metadata Author=Marvin Klerx +Metadata Creation=March 2025 +Test Tags Global-Tag + + +*** Test Cases *** +Log Message + [Documentation] Basic Console Logging + [Tags] RobotTestDoc + Log RobotFramework Test Documentation Generator! \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 5f269c4..482737f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "robotframework-testdoc" -version = "0.1.0" +version = "0.1.1" description = "A CLI Tool to generate a Test Documentation for your RobotFramework Test Scripts." readme = "README.md" requires-python = ">=3.7" @@ -12,7 +12,6 @@ authors = [{ name = "Marvin Klerx", email = "marvinklerx1@gmail.com" }] license = { text = "MIT" } dependencies = [ - "setuptools", "click", "robotframework", "jinja2", @@ -24,6 +23,6 @@ testdoc = "testdoc.cli:main" [tool.ruff] line-length = 150 -lint.select = ["E", "F"] # z. B. nur Pyflakes & pycodestyle +lint.select = ["E", "F"] # Pyflakes & pycodestyle lint.ignore = ["E722"] exclude = ["build", "dist"] \ No newline at end of file diff --git a/src/testdoc/__main__.py b/src/testdoc/__main__.py index 502a396..95f3538 100644 --- a/src/testdoc/__main__.py +++ b/src/testdoc/__main__.py @@ -1,4 +1,3 @@ from testdoc.cli import main - if __name__ == "__main__": main() \ No newline at end of file diff --git a/src/testdoc/cli.py b/src/testdoc/cli.py index 145cc3d..1052117 100644 --- a/src/testdoc/cli.py +++ b/src/testdoc/cli.py @@ -82,7 +82,6 @@ def main( args.suite_file = path args.output_file = output - # If CLI arg was set -> set / overwrite toml arg value for key, value in cli_params.items(): if value is not None: setattr(args, key, value) diff --git a/src/testdoc/helper/cliargs.py b/src/testdoc/helper/cliargs.py index b03b75c..764734b 100644 --- a/src/testdoc/helper/cliargs.py +++ b/src/testdoc/helper/cliargs.py @@ -20,6 +20,7 @@ class CommandLineArgumentsData: verbose_mode: bool = False suite_file: str = None output_file: str = None + colors: dict = None class CommandLineArguments: _instance = None @@ -34,6 +35,9 @@ def load_from_config_file(self, file_path: str): with open(file_path, "rb") as f: config = tomli.load(f) + 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) \ No newline at end of file diff --git a/src/testdoc/html/templates/jinja_template_01.html b/src/testdoc/html/templates/jinja_template_01.html index f6d8540..957276b 100644 --- a/src/testdoc/html/templates/jinja_template_01.html +++ b/src/testdoc/html/templates/jinja_template_01.html @@ -2,27 +2,35 @@ {% macro render_suite(suite, index, first) %}