Skip to content

Commit

Permalink
Add API to generate HTML and CSS strings without writing to file (#690)
Browse files Browse the repository at this point in the history
### Summary

This is handy if a third party wants to inject this into an existing
page.
  • Loading branch information
frankharkins authored Apr 3, 2024
1 parent 3ac5c64 commit 4989ec5
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions ecosystem/cli/website.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,23 @@ def build_website(resources: str, output: str) -> None:
"""
Generates the ecosystem web page from data in `resources` dir, writing to `output` dir.
"""
html, css = build_website_strings(resources)
Path(output).write_text(html)
(Path(output).parent / "style.css").write_text(css)


def build_website_strings(resources: str) -> tuple[str, str]:
"""
Generates the ecosystem web page and css from data in `resources` dir.
"""
projects, web_data, label_descriptions, templates, custom_css = _load_from_file(
Path(resources)
)
html = _build_html(projects, web_data, label_descriptions, templates)
Path(output).write_text(html)

css = templates["css"].render(
custom_css=custom_css, standalone=web_data.get("standalone", True)
)
(Path(output).parent / "style.css").write_text(css)
return html, css


def _load_from_file(
Expand Down

0 comments on commit 4989ec5

Please sign in to comment.