Skip to content

renderer

Module for converting RobotFramework result XML file (output.xml) to markdown.

Renderer

Renderer(theme: str = 'mkdocs-material')

Renderer class responsible for converting RobotFramework result files to markdown.

Parameters:

  • theme (str, default: 'mkdocs-material' ) –

    The theme (Jinja templates) to be used

Source code in src/robot_markdown/renderer.py
15
16
17
18
19
20
21
22
23
24
25
26
27
def __init__(self, theme: str = "mkdocs-material") -> None:
    """Creates a new renderer that will the given theme.

    Parameters:
        theme: The theme (Jinja templates) to be used
    """
    self.theme = theme
    self.jinjaEnv = Environment(
        loader=PackageLoader("robot_markdown", f"templates/{theme}"),
        autoescape=select_autoescape(),
        trim_blocks=True,
    )
    self.template = self.jinjaEnv.get_template("testreport.md.jinja")

render

render(
    robot_result_file: str, env_file: str | None = None
) -> str

Convert a RobotFramework result XML to markdown.

Read and parse the given file and convert it to markdown using Jinja templates.

Parameters:

  • robot_result_file (str) –

    A RobotFramework test execution result file.

  • env_file (str | None, default: None ) –

    Optional .env file.

Returns:

  • str

    A markdown string.

Source code in src/robot_markdown/renderer.py
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
def render(self, robot_result_file: str, env_file: str | None = None) -> str:
    """Convert a RobotFramework result XML to markdown.

    Read and parse the given file and convert it to markdown using Jinja templates.

    Parameters:
        robot_result_file: A RobotFramework test execution result file.
        env_file: Optional .env file.

    Returns:
        A markdown string.
    """
    robot_env = None
    robot_env = dotenv_values(env_file) if env_file else None
    output_dir = os.path.abspath(os.path.dirname(robot_result_file)) + "/"
    result = ExecutionResult(robot_result_file)
    util = TemplateUtil(output_dir)
    return self.template.render(robot=result, robot_env=robot_env, output_dir=output_dir, robot_util=util)