12
12
from dagster_dg .component_key import GlobalComponentKey
13
13
from dagster_dg .config import normalize_cli_config
14
14
from dagster_dg .context import DgContext
15
- from dagster_dg .docs import markdown_for_component_type , render_markdown_in_browser
15
+ from dagster_dg .docs import html_from_markdown , markdown_for_component_type , open_html_in_browser
16
16
from dagster_dg .scaffold import scaffold_component_type
17
17
from dagster_dg .utils import (
18
18
DgClickCommand ,
@@ -61,11 +61,13 @@ def component_type_scaffold_command(
61
61
62
62
@component_type_group .command (name = "docs" , cls = DgClickCommand )
63
63
@click .argument ("component_type" , type = str )
64
+ @click .option ("--output" , type = click .Choice (["browser" , "cli" ]), default = "browser" )
64
65
@dg_global_options
65
66
@click .pass_context
66
67
def component_type_docs_command (
67
68
context : click .Context ,
68
69
component_type : str ,
70
+ output : str ,
69
71
** global_options : object ,
70
72
) -> None :
71
73
"""Get detailed information on a registered Dagster component type."""
@@ -76,7 +78,11 @@ def component_type_docs_command(
76
78
if not registry .has_global (component_key ):
77
79
exit_with_error (f"Component type`{ component_type } ` not found." )
78
80
79
- render_markdown_in_browser (markdown_for_component_type (registry .get_global (component_key )))
81
+ markdown = markdown_for_component_type (registry .get_global (component_key ))
82
+ if output == "browser" :
83
+ open_html_in_browser (html_from_markdown (markdown ))
84
+ else :
85
+ click .echo (html_from_markdown (markdown ))
80
86
81
87
82
88
# ########################
0 commit comments