Skip to content

Commit

Permalink
Update exporter.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mchilvers committed Mar 1, 2024
1 parent 10bba97 commit a5faaad
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/invent/ui/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ def as_python_code(app):

APP_TEMPLATE = """
App(
name={name},
name='{name}',
content=[
{pages}
{pages}
],
)
"""
Expand All @@ -128,16 +128,22 @@ def as_python_code(app):
def _pretty_repr_app(app):
"""Generate a pretty repr of the App's UI."""

lines = []
for page in app.content:
_pretty_repr_component(page, lines=lines, indent=" "*8)

return APP_TEMPLATE.format(
name=app.name,
pages="\n".join(lines),
pages=_pretty_repr_pages(app.content)
)


def _pretty_repr_pages(pages):
"""Generate a pretty repr of the pages in an App's UI."""

lines = []
for page in pages:
_pretty_repr_component(page, lines=lines, indent=" "*8)

return "\n".join(lines)


def _pretty_repr_component(component, lines, indent=""):
"""Generate a pretty repr as a LIST of lines of code.
Expand Down

0 comments on commit a5faaad

Please sign in to comment.