mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-12-16 09:40:07 +01:00
Phoenix:
- Add support for tooltips over inheritance diagram boxes containing the first line(s) of documentation instead of simply the default useless class name. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxPython/Phoenix/trunk@71160 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -2712,6 +2712,7 @@ class XMLDocString(object):
|
||||
|
||||
if self.kind == 'class':
|
||||
desc = ChopDescription(docstrings)
|
||||
self.short_description = desc
|
||||
class_name = self.class_name.lower()
|
||||
PickleItem(desc, self.current_module, self.class_name, 'class')
|
||||
|
||||
@@ -2890,8 +2891,6 @@ class SphinxGenerator(generators.DocsGeneratorBase):
|
||||
simple_docs = self.createPropertyLinks(class_name, item)
|
||||
self.current_class.property_list.append(('%s.%s'%(class_name, item.name), simple_docs))
|
||||
|
||||
PickleClassInfo(self.current_module + class_name, self.current_class)
|
||||
|
||||
if init_position >= 0:
|
||||
init_method = class_items.pop(init_position)
|
||||
class_items.insert(0, init_method)
|
||||
@@ -2907,6 +2906,8 @@ class SphinxGenerator(generators.DocsGeneratorBase):
|
||||
|
||||
docstring.Dump()
|
||||
|
||||
PickleClassInfo(self.current_module + class_name, self.current_class, docstring.short_description)
|
||||
|
||||
# these are the only kinds of items allowed to be items in a PyClass
|
||||
dispatch = [(extractors.PyFunctionDef, self.generateMethod),
|
||||
(extractors.PyPropertyDef, self.generatePyProperty),
|
||||
@@ -3004,8 +3005,6 @@ class SphinxGenerator(generators.DocsGeneratorBase):
|
||||
method_name, simple_docs = self.getName(item)
|
||||
self.current_class.method_list.insert(0, ('%s.__init__'%name, simple_docs))
|
||||
|
||||
PickleClassInfo(self.current_module + name, self.current_class)
|
||||
|
||||
docstring = XMLDocString(klass)
|
||||
|
||||
filename = self.current_module + "%s.txt"%name
|
||||
@@ -3014,6 +3013,8 @@ class SphinxGenerator(generators.DocsGeneratorBase):
|
||||
|
||||
docstring.Dump()
|
||||
|
||||
PickleClassInfo(self.current_module + name, self.current_class, docstring.short_description)
|
||||
|
||||
for item in ctors:
|
||||
if item.isCtor:
|
||||
self.generateMethod(item, name='__init__', docstring=klass.pyDocstring)
|
||||
|
||||
@@ -507,7 +507,7 @@ class Library(ParentBase):
|
||||
if child.is_redundant:
|
||||
continue
|
||||
|
||||
class_dict[child.name] = (child.method_list, child.bases)
|
||||
class_dict[child.name] = (child.method_list, child.bases, ChopDescription(child.docs))
|
||||
|
||||
# recursively scan other folders, appending results
|
||||
class_dict = self.ClassesToPickle(child, class_dict)
|
||||
|
||||
@@ -163,6 +163,8 @@ def BuildEnumsAndMethods(sphinxDir):
|
||||
for cpp in ['ArrayString()', 'ArrayInt()', 'ArrayDouble()']:
|
||||
text = text.replace(cpp, '[]')
|
||||
|
||||
text = TooltipsOnInheritance(text, class_summary)
|
||||
|
||||
if text != orig_text:
|
||||
fid = open(input, 'wt')
|
||||
fid.write(text)
|
||||
@@ -248,7 +250,7 @@ def FindInherited(input, class_summary, enum_base, text):
|
||||
if curr_class not in class_summary:
|
||||
continue
|
||||
|
||||
methods, bases = class_summary[curr_class]
|
||||
methods, bases, short_description = class_summary[curr_class]
|
||||
|
||||
if meth_name in methods:
|
||||
continue
|
||||
@@ -259,7 +261,7 @@ def FindInherited(input, class_summary, enum_base, text):
|
||||
if cls not in class_summary:
|
||||
continue
|
||||
|
||||
submethods, subbases = class_summary[cls]
|
||||
submethods, subbases, subshort = class_summary[cls]
|
||||
|
||||
if meth_name in submethods:
|
||||
if not hasdot:
|
||||
@@ -673,3 +675,51 @@ def ChangeSVNRevision(text):
|
||||
|
||||
text = text.replace('|SVN|', SVN_REVISION)
|
||||
return text
|
||||
|
||||
|
||||
def TooltipsOnInheritance(text, class_summary):
|
||||
|
||||
graphviz = re.findall(r'<p class="graphviz">(.*?)</p>', text, re.DOTALL)
|
||||
|
||||
if not graphviz:
|
||||
return text
|
||||
|
||||
graphviz = graphviz[0]
|
||||
original = graphviz[:]
|
||||
|
||||
html_links = re.findall('href="(.*?)"', graphviz)
|
||||
titles = re.findall('title="(.*?)"', graphviz)
|
||||
|
||||
ReST = ['ref', 'class', 'mod', 'meth', 'attr']
|
||||
|
||||
for link, title in zip(html_links, titles):
|
||||
if 'http://' in link:
|
||||
# No tooltip for this one
|
||||
continue
|
||||
|
||||
class_name = os.path.splitext(link)[0]
|
||||
|
||||
if class_name not in class_summary:
|
||||
continue
|
||||
|
||||
methods, bases, short_description = class_summary[class_name]
|
||||
|
||||
if not short_description.strip():
|
||||
# Leave the default tooltip
|
||||
continue
|
||||
|
||||
replace_string = 'title="%s"'%title
|
||||
description = short_description.replace('\n', ' ').lstrip()
|
||||
|
||||
for item in ReST:
|
||||
description = re.sub(':%s:`~(.*?)`'%item, r'\1', description)
|
||||
description = re.sub(':%s:`(.*?)`'%item, r'\1', description)
|
||||
|
||||
description = description.replace('"', "'")
|
||||
graphviz = graphviz.replace(replace_string, 'title="%s"'%description)
|
||||
|
||||
text = text.replace(original, graphviz)
|
||||
|
||||
return text
|
||||
|
||||
|
||||
@@ -590,13 +590,14 @@ def PickleItem(description, current_module, name, kind):
|
||||
|
||||
# ----------------------------------------------------------------------- #
|
||||
|
||||
def PickleClassInfo(class_name, element):
|
||||
def PickleClassInfo(class_name, element, short_description):
|
||||
"""
|
||||
Saves some information about a class in a cPickle-compatible file., i.e. the
|
||||
list of methods in that class and its super-classes.
|
||||
|
||||
:param string `class_name`: the name of the class we want to pickle;
|
||||
:param xml.etree.ElementTree.Element `element`: the XML element we want to examine.
|
||||
:param xml.etree.ElementTree.Element `element`: the XML element we want to examine;
|
||||
:param string `short_description`: the class short description (if any).
|
||||
"""
|
||||
|
||||
pickle_file = os.path.join(SPHINXROOT, 'class_summary.lst')
|
||||
@@ -615,7 +616,7 @@ def PickleClassInfo(class_name, element):
|
||||
for base in element.bases:
|
||||
bases.append(Wx2Sphinx(base)[1])
|
||||
|
||||
items[class_name] = (method_list, bases)
|
||||
items[class_name] = (method_list, bases, short_description)
|
||||
fid = open(pickle_file, 'wb')
|
||||
cPickle.dump(items, fid)
|
||||
fid.close()
|
||||
|
||||
Reference in New Issue
Block a user