Help explorer widget supplying a simple web browser and a plain text help viewer
Classes:
|
A widget for showing the documentation. |
Base class for providing help on an object |
|
|
A thread to render sphinx documentation in a separate process |
|
Class to show plain text rst docstrings |
|
Very simple browser with session history and autocompletion based upon the |
|
A editable ComboBox with autocompletion |
|
Class to convert rst docstrings to html and show browsers |
Functions:
|
|
|
- class psyplot_gui.help_explorer.HelpExplorer(*args, **kwargs)[source]
Bases:
QWidget
,DockMixin
A widget for showing the documentation. It behaves somewhat similar to spyders object inspector plugin and can show restructured text either as html (if sphinx is installed) or as plain text. It furthermore has a browser to show html content
Warning
The
HelpBrowser
class is known to crash under PyQt4 when new web page domains are loaded. Hence you should disable the browsing to different remote websites and even disable intersphinxMethods:
close
(self)set_viewer
(name)Sets the current documentation viewer
show_help
(obj[, oname, files])Show the documentaion of the given object
show_intro
([text])Show an intro text
show_rst
(text[, oname, files])Show restructured text
Attributes:
The viewer classes used by the help explorer.
- show_help(obj, oname='', files=None)[source]
Show the documentaion of the given object
We first try to use the current viewer based upon it’s
HelpMixin.can_document_object
attribute. If this does not work, we check the other viewers
- show_intro(text='')[source]
Show an intro text
We first try to use the current viewer based upon it’s
HelpMixin.can_show_rst
attribute. If this does not work, we check the other viewers- Parameters:
s (str) – A string in reStructured Text format to show
- show_rst(text, oname='', files=None)[source]
Show restructured text
We first try to use the current viewer based upon it’s
HelpMixin.can_show_rst
attribute. If this does not work, we check the other viewers
- viewers = {'HTML help': <class 'psyplot_gui.help_explorer.UrlHelp'>, 'Plain text': <class 'psyplot_gui.help_explorer.TextHelp'>}
The viewer classes used by the help explorer.
HelpExplorer
instances replace this attribute with the corresponding HelpMixin instance
- class psyplot_gui.help_explorer.HelpMixin[source]
Bases:
object
Base class for providing help on an object
Attributes:
bool
determining whether the documentation of an object can be shown or notbool
determining whether this class can show restructured textMethods:
describe_object
(obj[, oname])Return an instance of the
object_descriptor
classget_doc
(descriptor)Get the documentation of the object in the given descriptor
header
(descriptor, sig)Format the header and include object name and signature sig
process_docstring
(lines, descriptor)Make final modification on the rst lines
show_help
(obj[, oname, files])Show the rst documentation for the given object
show_intro
([text])Show an intro message
show_rst
(text[, oname, descriptor, files])Abstract method which needs to be implemented by th widget to show restructured text
Classes:
Object containing the necessary fields to describe an object given to the help widget.
- can_document_object = True
bool
determining whether the documentation of an object can be shown or not
- describe_object(obj, oname='')[source]
Return an instance of the
object_descriptor
class- Returns:
The descriptor containing the information on the object
- Return type:
- get_doc(descriptor)[source]
Get the documentation of the object in the given descriptor
- Parameters:
descriptor (instance of
object_descriptor
) – The descriptor containig the information on the specific object- Returns:
The header and documentation of the object in the descriptor
- Return type:
Notes
This method uses the
IPython.core.oinspect.getdoc()
function to get the documentation and theIPython.core.oinspect.signature()
function to get the signature. Those function (different from the inspect module) do not fail when the object is not saved
- header(descriptor, sig)[source]
Format the header and include object name and signature sig
- Returns:
The header for the documentation
- Return type:
- object_descriptor
Object containing the necessary fields to describe an object given to the help widget. The descriptor is set up by the
describe_object()
method.alias of
ObjectDescriptor
Attributes:name
Alias for field number 1
obj
Alias for field number 0
- process_docstring(lines, descriptor)[source]
Make final modification on the rst lines
- Returns:
The docstring
- Return type:
- show_intro(text='')[source]
Show an intro message
- Parameters:
s (str) – A string in reStructured Text format to show
- show_rst(text, oname='', descriptor=None, files=None)[source]
Abstract method which needs to be implemented by th widget to show restructured text
- Parameters:
text (str) – The text to show
oname (str) – The object name
descriptor (instance of
object_descriptor
) – The object descriptor holding the informationsfiles (list of str) – A path to additional files that shall be used to display the docs
- Returns:
True if the text is displayed
- Return type:
- class psyplot_gui.help_explorer.SphinxThread(outdir, html_text_no_doc='')[source]
Bases:
QThread
A thread to render sphinx documentation in a separate process
Attributes:
html_error
(*args, **kwargs)html_ready
(*args, **kwargs)A signal to be emitted when the rendering finished.
Methods:
render
(doc, name)Render the given rst string and save the file as
name + '.rst'
run
()Create the html file.
- html_error(*args, **kwargs)
- html_ready(*args, **kwargs)
A signal to be emitted when the rendering finished. The url is the file location
- run()[source]
Create the html file. When called the first time, it may take a while because the
sphinx.application.Sphinx
app is build, potentially with intersphinxWhen finished, the html_ready signal is emitted
- class psyplot_gui.help_explorer.TextHelp(*args, **kwargs)[source]
Bases:
QFrame
,HelpMixin
Class to show plain text rst docstrings
Attributes:
The
PyQt5.QtWidgets.QPlainTextEdit
instance used for displaying the documentationMethods:
show_rst
(text, *args, **kwargs)Show the given text in the editor window
- editor
The
PyQt5.QtWidgets.QPlainTextEdit
instance used for displaying the documentation
- class psyplot_gui.help_explorer.UrlBrowser(*args, **kwargs)[source]
Bases:
QFrame
Very simple browser with session history and autocompletion based upon the
PyQt5.QtWebEngineWidgets.QWebEngineView
classWarning
This class is known to crash under PyQt4 when new web page domains are loaded. Hence it should be handled with care
Methods:
browse
(url)Make a web browse on the given url and show the page on the Webview widget.
Disable (or enable) the changing of the current webpage
Disable (or enable) the loading of web pages in www
update_url_lock_from_rc
(online)url_changed
(url)Triggered when the url is changed to update the adress line
Attributes:
button to go to next url
button to go to previous url
button to go lock to the current url
default value for
bt_lock
.refresh the current url
button to disable browsing in www
default value for
bt_url_lock
.The upper part of the browser containing all the buttons
Boolean whether the html page loading is completed.
The initial url showed in the webview.
The actual widget showing the html content
adress line
The upper most layout aranging the button box and the html widget
- bt_ahead = None
button to go to next url
- bt_back = None
button to go to previous url
- bt_lock = None
button to go lock to the current url
- bt_refresh = None
refresh the current url
- bt_url_lock = None
button to disable browsing in www
- bt_url_lock_default = None
default value for
bt_url_lock
. Is set during browser initialization
- button_box = None
The upper part of the browser containing all the buttons
- property completed
Boolean whether the html page loading is completed.
- default_url = None
The initial url showed in the webview. If None, nothing will be displayed
- doc_urls = {'cartopy': 'http://scitools.org.uk/cartopy/docs/latest/index.html', 'numpy': 'https://docs.scipy.org/doc/numpy/reference/routines.html', 'pandas': 'http://pandas.pydata.org/pandas-docs/stable/', 'psyplot': 'http://psyplot.github.io/psyplot/', 'pyplot': 'http://matplotlib.org/api/pyplot_api.html', 'seaborn': 'http://stanford.edu/~mwaskom/software/seaborn/api.html', 'startpage': 'https://startpage.com/', 'xarray': 'http://xarray.pydata.org/en/stable/'}
- html
The actual widget showing the html content
- tb_url = None
adress line
- url_like_re = re.compile('^\\w+://')
- vbox = None
The upper most layout aranging the button box and the html widget
- class psyplot_gui.help_explorer.UrlCombo(*args, **kwargs)[source]
Bases:
QComboBox
A editable ComboBox with autocompletion
Methods:
add_text_on_top
([text, block])Add the given text as the first item
keyPressEvent
(event)Handle key press events
setModel
(model)Reimplemented to also set the model of the filter and completer
- class psyplot_gui.help_explorer.UrlHelp(*args, **kwargs)[source]
Bases:
UrlBrowser
,HelpMixin
Class to convert rst docstrings to html and show browsers
Methods:
browse
(url)Reimplemented to add file paths to the url string
close
(self)describe_object
(obj[, oname])Describe an object using additionaly the object type from the
get_objtype()
methodget_doc
(descriptor)Reimplemented to (potentially) use the features from sphinx.ext.autodoc
get_objtype
(obj)Get the object type of the given object and determine wheter the object is considered a class, a module, a function, method or data
header
(descriptor, sig)Format the header and include object name and signature sig
is_importable
(modname)Determine whether members of the given module can be documented with sphinx by using the
sphinx.util.get_module_source()
functionprocess_docstring
(lines, descriptor)Process the lines with the napoleon sphinx extension
reset_sphinx
(value)Method that is called if the configuration changes
show_help
(obj[, oname, files])Render the rst docu for the given object with sphinx and show it
show_intro
([text])Show the intro text in the explorer
show_rst
(text[, oname, descriptor, files])Render restructured text with sphinx and show it
Disable (or enable) the loading of web pages in www
Disable (or enable) the loading of web pages in www
update_connect_console
(connect)url_changed
(url)Reimplemented to remove file paths from the url string
Attributes:
menu button with different urls
bool
determining whether the documentation of an object can be shown or notbool
determining whether this class can show restructured textClasses:
Object containing the necessary fields to describe an object given to the help widget.
menu button with different urls
- can_document_object = True
bool
determining whether the documentation of an object can be shown or not
- describe_object(obj, oname='')[source]
Describe an object using additionaly the object type from the
get_objtype()
method- Returns:
The descriptor of the object
- Return type:
instance of
object_descriptor
- get_doc(descriptor)[source]
Reimplemented to (potentially) use the features from sphinx.ext.autodoc
- get_objtype(obj)[source]
Get the object type of the given object and determine wheter the object is considered a class, a module, a function, method or data
- header(descriptor, sig)[source]
Format the header and include object name and signature sig
- Returns:
The header for the documentation
- Return type:
- is_importable(modname)[source]
Determine whether members of the given module can be documented with sphinx by using the
sphinx.util.get_module_source()
function
- object_descriptor
Object containing the necessary fields to describe an object given to the help widget. The descriptor is set up by the
describe_object()
method and contains an additional objtype attributealias of
ObjectDescriptor
Attributes:name
Alias for field number 1
obj
Alias for field number 0
objtype
Alias for field number 2
- show_help(obj, oname='', files=None)[source]
Render the rst docu for the given object with sphinx and show it
- show_intro(text='')[source]
Show the intro text in the explorer
- Parameters:
s (str) – A string in reStructured Text format to show
- show_rst(text, oname='', descriptor=None, files=None)[source]
Render restructured text with sphinx and show it
- Parameters:
%(HelpMixin.show_rst.parameters)s –
- sphinx_thread = None