# -*- coding: utf-8 -*

"""
View object documentation HTML in a separate GUI window.

Requires PyQt4 or PySide. Original code by
anatoly techtonik <techtonik@gmail.com> is placed in
public domain.

[ ] position window at the center of the screen
    (right now it is middle bottom)
[x] implement lazy loading for PyQt4/PySide
[ ] remove external dependency on
    IPython.core.oinspect.Inspector
[ ] ensure that tmp is cleaned
"""


import sys

try:
    from PySide import QtGui, QtWebKit
except ImportError:
    try:
        from PyQt4 import  QtGui, QtWebKit
    except ImportError:
        QtGui = QtWebKit = False

try:
    from IPython.core.oinspect import Inspector
except ImportError:
    Inspector = False

    
from .sphinxify import rich_repr, sphinxify


def show_window(url):
    app = QtGui.QApplication([])

    view = QtWebKit.QWebView()
    view.load(url)
    view.show()

    app.exec_()

def webview(obj, oname=''):
    """ Render HTML in tmp and show from tmp """
    if not QtGui:
        sys.exit("WebView requires PySide or PyQt4 for GUI window")

    if not Inspector:
        sys.exit("WebView requires IPython for dumping object info")

    oinfo = Inspector().info(obj, oname)

    #from pprint import pprint
    #pprint(oinfo)

    path = rich_repr(oinfo)
    #print path
    #print sphinxify(oinfo['docstring'])
    show_window('file:///' + path.replace('\\', '/'))

@@ -1163,180 +1163,203 @@
     
-oinfo = Inspector().info(obj, oname)%0A%0A    #from pprint import pprint%0A    #pprint(oinfo)%0A%0A    path = rich_repr(oinfo)%0A    #print path%0A    #print sphinxify(oinfo%5B'docstring'%5D
+# See https://github.com/ipython/ipython/issues/8774 for documenting%0A    # oinspect format. Use pprint(oinfo) in the meanwhile.%0A    oinfo = Inspector().info(obj, oname)%0A    path = rich_repr(oinfo
 )%0A  

Remove comments per review request.