|
7 | 7 | """ |
8 | 8 |
|
9 | 9 | import inspect |
10 | | -import os |
11 | 10 | import re |
12 | | -import subprocess |
13 | | -import webbrowser |
14 | 11 |
|
15 | 12 | from .. import setup_server |
16 | 13 | from .defaults import DashboardDefaults |
|
24 | 21 |
|
25 | 22 | class generalFunctions: |
26 | 23 | @staticmethod |
27 | | - def documentation(section_name): |
| 24 | + def open_documentation(section_name): |
28 | 25 | """ |
29 | | - Opens a tab to the specified section link in the documentation. |
30 | | - :param section_name (str): The name of the documentation section to open. |
| 26 | + Retrieves the documentation link with the provided section_name |
| 27 | + and opens the documentation sidebar on the dashoard. |
| 28 | +
|
| 29 | + :param section_name: The name for the input section. |
31 | 30 | """ |
32 | | - url_dict = { |
33 | | - "input_parameters": "https://impactx.readthedocs.io/en/latest/usage/python.html#general", |
34 | | - "lattice_configuration": "https://impactx.readthedocs.io/en/latest/usage/python.html#lattice-elements", |
35 | | - "distribution_parameters": "https://impactx.readthedocs.io/en/latest/usage/python.html#initial-beam-distributions", |
36 | | - "space_charge": "https://impactx.readthedocs.io/en/latest/usage/parameters.html#space-charge", |
37 | | - "csr": "https://impactx.readthedocs.io/en/latest/usage/parameters.html#coherent-synchrotron-radiation-csr", |
38 | | - } |
39 | | - |
40 | | - url = url_dict.get(section_name) |
41 | | - if url is None: |
42 | | - raise ValueError(f"Invalid section name: {section_name}") |
43 | | - |
44 | | - if "WSL_DISTRO_NAME" in os.environ: |
45 | | - subprocess.run(["explorer.exe", url]) |
| 31 | + |
| 32 | + new_url = DashboardDefaults.DOCUMENTATION.get(section_name) |
| 33 | + if state.documentation_drawer_open and state.documentation_url == new_url: |
| 34 | + state.documentation_drawer_open = False |
46 | 35 | else: |
47 | | - webbrowser.open_new_tab(url) |
| 36 | + state.documentation_url = new_url |
| 37 | + state.documentation_drawer_open = True |
48 | 38 |
|
49 | 39 | @staticmethod |
50 | 40 | def get_default(parameter, type): |
|
0 commit comments