pawamoy / mkdocs-coverage

MkDocs plugin to integrate your coverage HTML report into your site.
https://pawamoy.github.io/mkdocs-coverage
ISC License
24 stars 1 forks source link

feature: Navigation icon for the coverage page #10

Open NikosAlexandris opened 9 months ago

NikosAlexandris commented 9 months ago

Problem

I can't seem to add an icon to the title of the coverage.md page. Specifically, I want to add the following, as I'd do in any other Markdown page :

---
icon: simple/pytest
---

Solution ?

Perhaps an icon option to the coverage plugin ?

Alternatives considered

Not really.

Boost priority

Fund with Polar

pawamoy commented 9 months ago

I suppose this icon feature comes from Material for MkDocs? I'll try to look into it.

NikosAlexandris commented 9 months ago

I tried something like :

        yaml_header = textwrap.dedent(
            """
            ---
            icon: simple/pytest
            ---
            """,
        )
        style = textwrap.dedent(
            """
            <style>
            article h1, article > a, .md-sidebar--secondary {
                display: none !important;
            }
            </style>
            """,
        )

        iframe = textwrap.dedent(
            f"""
            <iframe
                id="coviframe"
                src="{covindex}"
                frameborder="0"
                scrolling="no"
                onload="resizeIframe();"
                width="100%">
            </iframe>
            """,
        )

        script = textwrap.dedent(
            """
            <script>
            var coviframe = document.getElementById("coviframe");

            function resizeIframe() {
                coviframe.style.height = coviframe.contentWindow.document.documentElement.offsetHeight + 'px';
            }

            coviframe.contentWindow.document.body.onclick = function() {
                coviframe.contentWindow.location.reload();
            }
            </script>

            """,
        )
        page_contents = yaml_header + style + iframe + script

but no luck yet.