Skip to content
This repository was archived by the owner on Mar 19, 2025. It is now read-only.

Commit d8168ef

Browse files
committed
Fix issue when user has ginga < v5.x installed
1 parent 9ac3e1a commit d8168ef

File tree

1 file changed

+21
-39
lines changed

1 file changed

+21
-39
lines changed

stginga/plugins/local_plugin_mixin.py

Lines changed: 21 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# STDLIB
44
import json
55
import os
6-
import re
76

87
# THIRD-PARTY
98
from astropy.utils.misc import JsonCustomEncoder
@@ -19,21 +18,35 @@
1918
pass
2019

2120
# STGINGA
22-
import stginga
2321
from stginga import utils
2422

2523
__all__ = ['HelpMixin', 'MEFMixin', 'ParamMixin']
2624

2725

28-
# base of our online documentation
29-
rtd_base_url = "https://stginga.readthedocs.io/en/"
30-
31-
3226
class HelpMixin(object):
3327
def help(self):
3428
"""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)
3750

3851

3952
class MEFMixin(object):
@@ -285,34 +298,3 @@ def ingest_params(self, pardict):
285298
"""Ingest dictionary containing plugin parameters into plugin
286299
GUI and internal variables."""
287300
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

Comments
 (0)