mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2025-12-16 01:30: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:
@@ -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)
|
||||
|
||||
@@ -96,7 +96,7 @@ def BuildEnumsAndMethods(sphinxDir):
|
||||
fid = open(os.path.join(sphinxDir, 'class_summary.lst'), 'rb')
|
||||
class_summary = cPickle.load(fid)
|
||||
fid.close()
|
||||
|
||||
|
||||
unreferenced_classes = {}
|
||||
|
||||
textfiles = glob.glob(sphinxDir + '/*.txt')
|
||||
@@ -162,7 +162,9 @@ 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