77import textwrap
88from typing import Any , Literal , Optional , Sequence , TypeVar
99
10+ from brand_yml import Brand
1011from htmltools import HTMLDependency
1112
1213from .._docstring import add_example
@@ -460,25 +461,29 @@ def _dep_create(self, css_path: str | pathlib.Path) -> HTMLDependency:
460461 "href" : css_path .name ,
461462 "data-shiny-theme" : self .name or self ._preset , # type: ignore
462463 },
464+ # Branded themes re-use this tempdir
465+ all_files = False ,
463466 )
464467
465468 def _html_dependency_precompiled (self ) -> HTMLDependency :
466469 return self ._dep_create (css_path = self ._dep_css_precompiled_path ())
467470
468- def _html_dependency (self ) -> HTMLDependency :
471+ def _html_dependency (self ) -> list [ HTMLDependency ] :
469472 """
470473 Create an `HTMLDependency` object from the theme.
471474
472475 Returns
473476 -------
474477 :
475- An :class:`~htmltools.HTMLDependency` object representing the theme. In
476- most cases, you should not need to call this method directly. Instead, pass
477- the `Theme` object directly to the `theme` argument of any Shiny page
478- function.
478+ An list of :class:`~htmltools.HTMLDependency` objects representing the
479+ theme. In most cases, you should not need to call this method directly.
480+ Instead, pass the `Theme` object directly to the `theme` argument of any
481+ Shiny page function.
479482 """
483+ # Note: return a list so that this method can be overridden in subclasses of
484+ # Theme that want to attach additional dependencies to the theme dependency.
480485 if self ._can_use_precompiled ():
481- return self ._html_dependency_precompiled ()
486+ return [ self ._html_dependency_precompiled ()]
482487
483488 css_name = self ._dep_css_name ()
484489 css_path = os .path .join (self ._get_css_tempdir (), css_name )
@@ -487,7 +492,7 @@ def _html_dependency(self) -> HTMLDependency:
487492 with open (css_path , "w" ) as css_file :
488493 css_file .write (self .to_css ())
489494
490- return self ._dep_create (css_path )
495+ return [ self ._dep_create (css_path )]
491496
492497 def tagify (self ) -> None :
493498 raise SyntaxError (
@@ -497,6 +502,12 @@ def tagify(self) -> None:
497502 "or any `shiny.ui.page_*()` function (Shiny Core)."
498503 )
499504
505+ @classmethod
506+ def from_brand (cls , brand : str | pathlib .Path | Brand ):
507+ from ._theme_brand import theme_from_brand # avoid circular import
508+
509+ return theme_from_brand (brand )
510+
500511
501512def path_pkg_preset (preset : ShinyThemePreset , * args : str ) -> str :
502513 """
0 commit comments