diffdf icon indicating copy to clipboard operation
diffdf copied to clipboard

Abstract report design

Open gowerc opened this issue 7 months ago • 8 comments

@kieranjmartin

In order to support the generation of html / md as well as allowing users to customise the output as they see fit I think we need to abstract out the report creation to some light weight template structure.

My initial thoughts are something like follows:

Report
    - Components: a list of ReportComponent's
    - title: string

ReportComponent:
    - id: string
    - order: number
    - content: list of tags

tags are then just html style content tags. I would keep it minimal so perhaps just: h1, h2, h3, h4, p, table

order is so that the components appear in the correct order in the report e.g. separates report ordering from the literal object / list order which would make it easier for users to append / prepend additional components.

id is so that users could extract content by name again without having to worry about order in which the list is constructed.

As an example one of our tests would thus produce something like:

ReportComponent(
    id = "rows_in_base_not_compare",
    order = 500,
    content = ComponentBody(
        tag_p("Some rows were found in base that do not appear in compare"),
        tag_table(rows_in_base_not_compare)
        tag_p("Only 10 rows shown of x")
    )    
)

If users want to modify a component they could then do something like:

report["rows_in_base_not_compare"]<- append(
    report["rows_in_base_not_compare"],
    ComponentBody(tag_p("some additional footnote"))
)

Or if they wanted to inject an entirely new section:

report <- append(
    report,
    ReportComponent(
        id = "header_info",
        order = 10,
        content = ComponentBody(
            tag_p("Some additional info that I want to print into the report"),
        )    
    )
)

gowerc avatar Jul 08 '24 14:07 gowerc