|
3 | 3 | # STDLIB
|
4 | 4 | import json
|
5 | 5 | import os
|
6 |
| -import re |
7 | 6 |
|
8 | 7 | # THIRD-PARTY
|
9 | 8 | from astropy.utils.misc import JsonCustomEncoder
|
|
19 | 18 | pass
|
20 | 19 |
|
21 | 20 | # STGINGA
|
22 |
| -import stginga |
23 | 21 | from stginga import utils
|
24 | 22 |
|
25 | 23 | __all__ = ['HelpMixin', 'MEFMixin', 'ParamMixin']
|
26 | 24 |
|
27 | 25 |
|
28 |
| -# base of our online documentation |
29 |
| -rtd_base_url = "https://stginga.readthedocs.io/en/" |
30 |
| - |
31 |
| - |
32 | 26 | class HelpMixin(object):
|
33 | 27 | def help(self):
|
34 | 28 | """Display online help for the plugin."""
|
35 |
| - url = get_online_docs_url(self) |
36 |
| - self.fv.help_plugin(self, url=url) |
| 29 | + if self.fv.gpmon.has_plugin('WBrowser') and Widgets.has_webkit: |
| 30 | + # ginga < v5.x |
| 31 | + self.fv.start_global_plugin('WBrowser') |
| 32 | + |
| 33 | + # need to let GUI finish processing, it seems |
| 34 | + self.fv.update_pending() |
| 35 | + |
| 36 | + obj = self.fv.gpmon.get_plugin('WBrowser') |
| 37 | + |
| 38 | + # Unlike Ginga, we do not attempt to download offline doc |
| 39 | + # but just point to online doc directly. |
| 40 | + obj.browse(self.help_url) |
| 41 | + return |
| 42 | + |
| 43 | + if not hasattr(self.fv, 'help_plugin'): |
| 44 | + # ginga < v5.x but somehow user doesn't have WBrowser plugin |
| 45 | + self._help_docstring() # works same as in v4.x |
| 46 | + return |
| 47 | + |
| 48 | + # ginga v5.x |
| 49 | + self.fv.help_plugin(self, url=self.help_url) |
37 | 50 |
|
38 | 51 |
|
39 | 52 | class MEFMixin(object):
|
@@ -285,34 +298,3 @@ def ingest_params(self, pardict):
|
285 | 298 | """Ingest dictionary containing plugin parameters into plugin
|
286 | 299 | GUI and internal variables."""
|
287 | 300 | raise NotImplementedError('To be implemented by Ginga local plugin')
|
288 |
| - |
289 |
| - |
290 |
| -def get_online_docs_url(plugin=None): |
291 |
| - """ |
292 |
| - Return URL to online documentation closest to this stginga version. |
293 |
| -
|
294 |
| - Parameters |
295 |
| - ---------- |
296 |
| - plugin : obj or `None` |
297 |
| - Plugin object. If given, URL points to plugin doc directly. |
298 |
| - If this function is called from within plugin class, |
299 |
| - pass ``self`` here. |
300 |
| -
|
301 |
| - Returns |
302 |
| - ------- |
303 |
| - url : str |
304 |
| - URL to online documentation (top-level, if plugin == None). |
305 |
| -
|
306 |
| - """ |
307 |
| - stginga_ver = stginga.__version__ |
308 |
| - if re.match(r'^\d+\.\d+\.\d+$', stginga_ver): |
309 |
| - rtd_version = stginga_ver |
310 |
| - else: |
311 |
| - # default to latest |
312 |
| - rtd_version = 'latest' |
313 |
| - url = f"{rtd_base_url}{rtd_version}" |
314 |
| - if plugin is not None: |
315 |
| - plugin_name = str(plugin) |
316 |
| - url += f'/stginga/plugins_manual/{plugin_name}.html' |
317 |
| - |
318 |
| - return url |
0 commit comments