Skip to content

Welcome to MkDocs

For full documentation visit mkdocs.org.

Commands

  • mkdocs new [dir-name] - Create a new project.
  • mkdocs serve - Start the live-reloading docs server.
  • mkdocs build - Build the documentation site.
  • mkdocs -h - Print help message and exit.

Project layout

mkdocs.yml    # The configuration file.
docs/
    index.md  # The documentation homepage.
    ...       # Other markdown pages, images and other files.

Termynal

uv -h
...

Bases: DashObject

Abstract class for defining pages in a Dash application.

Example

import dash
from dash import html
from dash_builder import DashPage


dash.register_page(__name__, path="/")


class Homepage(Dash):
    @classmethod
    def valid_layout(cls, **kwargs):
        return html.H1("This is the Homepage")


def layout(**kwargs):
    return Homepage.layout(**kwargs)
Source code in src/dash_builder/dash_page.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class DashPage(DashObject):
    """Abstract class for defining pages in a Dash application.

    # Example
    ```python
    import dash
    from dash import html
    from dash_builder import DashPage


    dash.register_page(__name__, path="/")


    class Homepage(Dash):
        @classmethod
        def valid_layout(cls, **kwargs):
            return html.H1("This is the Homepage")


    def layout(**kwargs):
        return Homepage.layout(**kwargs)
    ```
    """

valid_layout(**kwargs) abstractmethod classmethod

Generate the desired page layout.

Parameters:

Name Type Description Default
kwargs

additional keyword arguments.

{}

Raises:

Type Description
`NotImplementedError`

must be implemented by the subclass.

Source code in src/dash_builder/_dash_object.py
67
68
69
70
71
72
73
74
75
76
77
78
79
@classmethod
@abc.abstractmethod
def valid_layout(cls, **kwargs):
    """Generate the desired page layout.

    Args:
        kwargs: additional keyword arguments.

    Raises:
        `NotImplementedError`: must be implemented by the subclass.

    """
    raise NotImplementedError

layout(*args, **kwargs) classmethod

Generate the page layout.

Parameters:

Name Type Description Default
*args

additional positional arguments.

()
**kwargs

additional keyword arguments.

{}

Returns:

Type Description

dash.html.Div container.

Source code in src/dash_builder/_dash_object.py
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
@classmethod
def layout(cls, *args, **kwargs):
    """Generate the page layout.

    Args:
        *args: additional positional arguments.
        **kwargs: additional keyword arguments.

    Returns:
        `dash.html.Div` container.

    """
    try:
        return cls.valid_layout(*args, **kwargs)
    except Exception:
        return cls.error_container(traceback.format_exc())