Skip to content

Commit

Permalink
Improve write_markdown_doc (#23)
Browse files Browse the repository at this point in the history
Signed-off-by: hoangtungdinh <11166240+hoangtungdinh@users.noreply.github.com>
  • Loading branch information
hoangtungdinh authored Aug 19, 2024
1 parent 361e3c2 commit c1ac8b4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 30 deletions.
39 changes: 22 additions & 17 deletions qc_baselib/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,43 +106,48 @@ def write_markdown_doc(self, markdown_file_path: str) -> None:
"Report documentation dump with empty report, the report needs to be loaded first"
)

bundles_text = "# Checker bundles\n\n"
full_text = """
This is the automatically generated documentation.
The lists of checkers and addressed rules were exported from the
information registered in the Result object for a particular run.
Therefore, some checkers and addressed rules might be missing if
they are not registered in that particular run. Double check with
the implementation before using this generated documentation.\n\n"""

for bundle in self._report_results.checker_bundles:
bundle_text = ""
bundle_text += f"## Checker bundle: **{bundle.name}**\n"
bundle_text += f"- Build date: {bundle.build_date}\n"
bundle_text += f"- Build version: {bundle.version}\n"
bundle_text += f"- Description: {bundle.description}\n"
bundle_text += f"- Summary: {bundle.summary}\n"
bundle_text += f"# Checker bundle: {bundle.name}\n\n"
bundle_text += f"* Build version: {bundle.version}\n"
bundle_text += f"* Description: {bundle.description}\n"
bundle_text += f"* Summary: {bundle.summary}\n"

bundle_text += "\n"
bundle_text += f"### Parameters:\n"
bundle_text += f"## Parameters\n\n"
param_text = ""
for param in bundle.params:
param_text += f"1. {param.name} = {param.value}\n"
param_text += f"* {param.name}: \n"

if len(param_text) == 0:
param_text += f"* None\n"

bundle_text += param_text

bundle_text += "\n"
bundle_text += f"### Checkers:\n"
bundle_text += f"## Checkers\n"
checker_text = ""
for checker in bundle.checkers:
checker_text += "\n"
checker_text += f"#### Checker: {checker.checker_id}\n"
checker_text += f"### {checker.checker_id}\n\n"
checker_text += f"* Description: {checker.description}\n"
checker_text += f"* Status: {checker.status.value if checker.status is not None else ''}\n"
checker_text += f"* Summary: {checker.summary}\n"
checker_text += f"* Summary: {checker.summary}\n"

checker_text += f"+ Addressed rules:\n"
checker_text += f"* Addressed rules:\n"
rule_text = ""
for rule in checker.addressed_rule:
rule_text += f" 1. {rule.rule_uid}\n"
rule_text += f" * {rule.rule_uid}\n"

if len(rule_text) == 0:
rule_text += f" * None"
rule_text += f" * None"

checker_text += rule_text

Expand All @@ -151,10 +156,10 @@ def write_markdown_doc(self, markdown_file_path: str) -> None:

bundle_text += checker_text

bundles_text += bundle_text
full_text += bundle_text

with open(markdown_file_path, "wb") as doc_file:
doc_file.write(bundles_text.encode())
doc_file.write(full_text.encode())

def set_result_version(self, version: str) -> None:
if self._report_results is None:
Expand Down
33 changes: 20 additions & 13 deletions tests/data/result_markdown_docs.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
# Checker bundles

## Checker bundle: **TestBundle**
- Build date: 2024-05-31
- Build version: 0.0.1
- Description: Example checker bundle
- Summary: Tested example checkers
This is the automatically generated documentation.
The lists of checkers and addressed rules were exported from the
information registered in the Result object for a particular run.
Therefore, some checkers and addressed rules might be missing if
they are not registered in that particular run. Double check with
the implementation before using this generated documentation.

# Checker bundle: TestBundle

* Build version: 0.0.1
* Description: Example checker bundle
* Summary: Tested example checkers

## Parameters

### Parameters:
* None

### Checkers:
## Checkers

### TestChecker

#### Checker: TestChecker
* Description: Test checker
* Status: completed
* Summary: Executed evaluation
+ Addressed rules:
1. test.com:qc:1.0.0:qwerty.qwerty
* Summary: Executed evaluation
* Addressed rules:
* test.com:qc:1.0.0:qwerty.qwerty

0 comments on commit c1ac8b4

Please sign in to comment.