Skip to content

Commit

Permalink
Tweaks to key function visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrudy committed Mar 22, 2024
1 parent ca4160b commit eb3e0ee
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/bootlace/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
from . import __about__
from ._version import __version__
from .util import _monkey_patch_dominate
from .util import as_tag
from .util import render

__all__ = ["__version__", "__about__"]
__all__ = ["__version__", "__about__", "as_tag", "render"]


_monkey_patch_dominate()
11 changes: 11 additions & 0 deletions src/bootlace/table/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ def get_declared_columns(mcls, cls: type) -> dict[str, ColumnBase]:


class Table(metaclass=TableMetaclass):
"""Base class for class-defined tables.
Subclasses should define columns as class attributes, e.g.:
class MyTable(Table):
name = Column(Heading("Name"))
age = Column(Heading("Age"))
Use :meth:`render` to render a table from a list of items as
:class:`dominate.tags.table`.
"""

decorated_classes: set[str] = set()
columns: ClassVar[dict[str, ColumnBase]]
Expand Down
5 changes: 3 additions & 2 deletions src/bootlace/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from dominate.util import container
from dominate.util import text
from flask import request
from markupsafe import Markup

T = TypeVar("T")

Expand Down Expand Up @@ -51,8 +52,8 @@ def as_tag(item: Taggable) -> tags.html_tag:
return container(text(str(item)), tags.comment(f"Rendered type {item.__class__.__name__} not supported"))


def render(item: Taggable) -> str:
return as_tag(item).render()
def render(item: Taggable) -> Markup:
return Markup(as_tag(item).render())


class Classes:
Expand Down

0 comments on commit eb3e0ee

Please sign in to comment.