MCPcopy Create free account
hub / github.com/datapane/datapane / build_md_view

Function build_md_view

python-client/src/datapane/builtins.py:45–72  ·  view source on GitHub ↗

An easy way to build a complete report from a single top-level markdown text / file template. Any additional context can be passed in and will be inserted into the Markdown template. Args: text_or_file: The markdown text, or path to a markdown file, using {{}} for templating

(
    text_or_file: t.Union[str, NPath],
    *args: b.BlockOrPrimitive,
    **kwargs: b.BlockOrPrimitive,
)

Source from the content-addressed store, hash-verified

43
44
45def build_md_view(
46 text_or_file: t.Union[str, NPath],
47 *args: b.BlockOrPrimitive,
48 **kwargs: b.BlockOrPrimitive,
49) -> Blocks:
50 """
51 An easy way to build a complete report from a single top-level markdown text / file template.
52 Any additional context can be passed in and will be inserted into the Markdown template.
53
54 Args:
55 text_or_file: The markdown text, or path to a markdown file, using {{}} for templating
56 *args: positional template context arguments
57 **kwargs: keyword template context arguments
58
59 Returns:
60 A datapane App object for saving or uploading
61
62 ..tip:: Either text or file is required as input
63 ..tip:: Context, via args/kwargs can be plain Python objects, e.g. dataframes, and plots, or Datapane blocks, e.g. dp.Plot, etc.
64
65 """
66 try:
67 b_text = b.Text(file=text_or_file) if Path(text_or_file).exists() else b.Text(text=t.cast(str, text_or_file))
68 except OSError:
69 b_text = b.Text(text=t.cast(str, text_or_file))
70
71 group = b_text.format(*args, **kwargs)
72 return Blocks(group)
73
74
75def gen_df(dim: int = 4) -> pd.DataFrame:

Callers

nothing calls this directly

Calls 2

formatMethod · 0.95
BlocksClass · 0.90

Tested by

no test coverage detected