|
1 |
| -# Mantid Repository : https://github.com/mantidproject/mantid |
2 |
| -# |
3 | 1 | # Copyright © 2017 ISIS Rutherford Appleton Laboratory UKRI,
|
4 | 2 | # NScD Oak Ridge National Laboratory, European Spallation Source,
|
5 | 3 | # Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
|
6 | 4 | # SPDX - License - Identifier: GPL - 3.0 +
|
7 |
| -import os |
8 | 5 | import sys
|
9 |
| -import argparse |
10 | 6 |
|
11 | 7 | from qtpy.QtWidgets import QApplication
|
12 | 8 | from mantidqt.widgets.helpwindow.helpwindowpresenter import HelpWindowPresenter
|
13 | 9 |
|
14 | 10 | _presenter = None
|
15 | 11 |
|
16 | 12 |
|
17 |
| -def show_help_page(relativeUrl, localDocs=None, onlineBaseUrl="https://docs.mantidproject.org/"): |
| 13 | +def show_help_page(relativeUrl, onlineBaseUrl="https://docs.mantidproject.org/"): |
18 | 14 | """
|
19 | 15 | Show the help window at the given relative URL path.
|
| 16 | + Local docs path is now determined internally via ConfigService. |
20 | 17 | """
|
21 | 18 | global _presenter
|
22 | 19 | if _presenter is None:
|
23 |
| - # Create a Presenter once. Re-use it on subsequent calls. |
24 |
| - _presenter = HelpWindowPresenter(localDocs=localDocs, onlineBaseUrl=onlineBaseUrl) |
| 20 | + _presenter = HelpWindowPresenter(onlineBaseUrl=onlineBaseUrl) |
25 | 21 |
|
26 |
| - # Ask the Presenter to load the requested page |
27 | 22 | _presenter.show_help_page(relativeUrl)
|
28 | 23 |
|
29 | 24 |
|
30 | 25 | def main(cmdargs=sys.argv):
|
31 | 26 | """
|
32 | 27 | Run this script standalone to test the Python-based Help Window.
|
| 28 | + Local docs path is determined from Mantid's ConfigService. |
33 | 29 | """
|
| 30 | + import argparse |
| 31 | + |
34 | 32 | parser = argparse.ArgumentParser(description="Standalone test of the Python-based Mantid Help Window.")
|
35 | 33 | parser.add_argument(
|
36 | 34 | "relativeUrl", nargs="?", default="", help="Relative doc path (e.g. 'algorithms/Load-v1.html'), defaults to 'index.html' if empty."
|
37 | 35 | )
|
38 |
| - parser.add_argument("--local-docs", default=None, help="Path to local Mantid HTML docs. Overrides environment if set.") |
| 36 | + |
39 | 37 | parser.add_argument(
|
40 | 38 | "--online-base-url",
|
41 | 39 | default="https://docs.mantidproject.org/",
|
42 |
| - help="Base URL for online docs if local docs are not set or invalid.", |
| 40 | + help="Base URL for online docs if local docs path from config is invalid or not found.", |
43 | 41 | )
|
44 | 42 | args = parser.parse_args(cmdargs or sys.argv[1:])
|
45 | 43 |
|
46 |
| - # If user gave no --local-docs, fall back to environment |
47 |
| - if args.local_docs is None: |
48 |
| - args.local_docs = os.environ.get("MANTID_LOCAL_DOCS_BASE", None) |
| 44 | + try: |
| 45 | + import mantid.kernel |
| 46 | + |
| 47 | + log = mantid.kernel.Logger("HelpWindowBridge") |
| 48 | + log.information("Mantid kernel imported successfully.") |
| 49 | + except ImportError as e: |
| 50 | + print(f"ERROR: Failed to import Mantid Kernel: {e}", file=sys.stderr) |
| 51 | + print( |
| 52 | + "Ensure Mantid is built and PYTHONPATH is set correctly (e.g., export PYTHONPATH=/path/to/mantid/build/bin:$PYTHONPATH)", |
| 53 | + file=sys.stderr, |
| 54 | + ) |
| 55 | + sys.exit(1) |
49 | 56 |
|
50 | 57 | app = QApplication(sys.argv)
|
51 | 58 |
|
52 |
| - # Show the requested help page |
53 |
| - show_help_page(relativeUrl=args.relativeUrl, localDocs=args.local_docs, onlineBaseUrl=args.online_base_url) |
| 59 | + show_help_page(relativeUrl=args.relativeUrl, onlineBaseUrl=args.online_base_url) |
54 | 60 |
|
55 | 61 | sys.exit(app.exec_())
|
56 | 62 |
|
|
0 commit comments