|
37 | 37 | from dash.development.base_component import Component |
38 | 38 | from dash.exceptions import PreventUpdate |
39 | 39 |
|
40 | | -from deepcave import ROOT_DIR, DOC_ROOT, interactive |
| 40 | +from deepcave import ROOT_DIR, interactive |
41 | 41 | from deepcave.layouts import Layout |
42 | 42 | from deepcave.runs import AbstractRun |
43 | 43 | from deepcave.runs.group import Group, NotMergeableError |
@@ -856,23 +856,45 @@ def __call__(self, render_button: bool = False) -> List[Component]: |
856 | 856 | components = [] |
857 | 857 |
|
858 | 858 | if self.help is not None: |
859 | | - doc_path = DOC_ROOT + self.help |
| 859 | + doc_path = ROOT_DIR / self.help |
| 860 | + if not doc_path.exists(): |
| 861 | + raise FileNotFoundError(doc_path) |
| 862 | + |
| 863 | + if doc_path.name.endswith(".rst"): |
| 864 | + data = rst_to_md(doc_path) |
| 865 | + else: |
| 866 | + with doc_path.open("r") as file: |
| 867 | + data = file.read() |
| 868 | + |
| 869 | + modal = html.Div( |
| 870 | + [ |
| 871 | + dbc.Modal( |
| 872 | + [ |
| 873 | + dbc.ModalBody([dcc.Markdown(data)]), |
| 874 | + ], |
| 875 | + id=self.get_internal_id("help"), |
| 876 | + size="xl", |
| 877 | + scrollable=True, |
| 878 | + is_open=False, |
| 879 | + ), |
| 880 | + ] |
| 881 | + ) |
| 882 | + |
860 | 883 | components += [ |
861 | 884 | html.H1( |
862 | 885 | [ |
863 | 886 | html.Span(self.name), |
864 | 887 | dbc.Button( |
865 | 888 | [html.I(className="far fa-question-circle")], |
866 | 889 | id=self.get_internal_id("show_help"), |
867 | | - href=doc_path, |
868 | | - target="_blank", |
869 | 890 | style={"float": "right"}, |
870 | 891 | color="primary", |
871 | 892 | outline=True, |
872 | 893 | n_clicks=0, |
873 | 894 | ), |
874 | 895 | ] |
875 | 896 | ), |
| 897 | + modal, |
876 | 898 | ] |
877 | 899 | else: |
878 | 900 | components += [html.H1(self.name)] |
|
0 commit comments