Refactor lots of functions to use camelCase names

This commit is contained in:
Robin Dunn
2016-05-19 23:53:40 -07:00
parent e2f853d0e0
commit a83ca5e94f
8 changed files with 204 additions and 205 deletions

View File

@@ -18,7 +18,7 @@ from subprocess import Popen, PIPE
# Phoenix-specific imports
from .utilities import Wx2Sphinx, FormatExternalLink
from .utilities import wx2Sphinx, formatExternalLink
from .constants import INHERITANCEROOT
ENOENT = getattr(errno, 'ENOENT', 0)
@@ -176,7 +176,7 @@ class InheritanceDiagram(object):
this_node_attrs['style'] = 'bold'
if self.main_class is None:
newname, fullname = Wx2Sphinx(name)
newname, fullname = wx2Sphinx(name)
else:
newname = name
@@ -190,7 +190,7 @@ class InheritanceDiagram(object):
if fullname in class_summary:
this_node_attrs['URL'] = '"%s.html"'%fullname
else:
full_page = FormatExternalLink(fullname, inheritance=True)
full_page = formatExternalLink(fullname, inheritance=True)
if full_page:
this_node_attrs['URL'] = full_page
@@ -205,7 +205,7 @@ class InheritanceDiagram(object):
this_edge_attrs['color'] = 'red'
if self.main_class is None:
base_name, dummy = Wx2Sphinx(base_name)
base_name, dummy = wx2Sphinx(base_name)
res.append(' "%s" -> "%s" [%s];\n' %
(base_name, newname,
@@ -216,7 +216,7 @@ class InheritanceDiagram(object):
# ----------------------------------------------------------------------- #
def MakeInheritanceDiagram(self, class_summary=None):
def makeInheritanceDiagram(self, class_summary=None):
"""
Actually generates the inheritance diagram as a PNG file plus the corresponding
MAP file for mouse navigation over the inheritance boxes.
@@ -242,7 +242,7 @@ class InheritanceDiagram(object):
if self.main_class is not None:
filename = self.main_class.name
else:
dummy, filename = Wx2Sphinx(self.specials[0])
dummy, filename = wx2Sphinx(self.specials[0])
outfn = os.path.join(static_root, filename + '_inheritance.png')
mapfile = outfn + '.map'

View File

@@ -12,8 +12,8 @@ else:
from inspect import getmro, getclasstree, getdoc, getcomments
from .utilities import MakeSummary, ChopDescription, WriteSphinxOutput, PickleFile
from .utilities import FindControlImages, FormatExternalLink, IsPython3
from .utilities import makeSummary, chopDescription, writeSphinxOutput, PickleFile
from .utilities import findControlImages, formatExternalLink, isPython3
from .constants import object_types, MODULE_TO_ICON, DOXY_2_REST, SPHINXROOT
from . import templates
@@ -79,16 +79,16 @@ def generic_summary(libraryItem, stream):
if item.is_redundant:
continue
item_docs = ReplaceWxDot(item.docs)
item_docs = KillEpydoc(item, item_docs)
docs = ChopDescription(item_docs)
item_docs = replaceWxDot(item.docs)
item_docs = killEpydoc(item, item_docs)
docs = chopDescription(item_docs)
table.append((item.name, docs))
if item.kind != object_types.FUNCTION:
toctree += ' %s\n'%item.name
if table:
summary = MakeSummary(libraryItem.name, table, templ[index], refs[index], add_tilde[index])
summary = makeSummary(libraryItem.name, table, templ[index], refs[index], add_tilde[index])
stream.write(summary)
if toctree and write_toc:
@@ -96,12 +96,12 @@ def generic_summary(libraryItem, stream):
stream.write('\n\n')
def MakeSphinxFile(name):
def makeSphinxFile(name):
return os.path.join(os.getcwd(), 'docs', 'sphinx', '%s.txt'%name)
def ReplaceWxDot(text):
def replaceWxDot(text):
# Double ticks with 'wx.' in them
text = re.sub(r'``wx\.(.*?)``', r'``\1`` ', text)
@@ -167,13 +167,13 @@ def GetTopLevelParent(klass):
return parents[-2]
def FindInHierarchy(klass, newlink):
def findInHierarchy(klass, newlink):
library = GetTopLevelParent(klass)
return library.FindItem(newlink)
def FindBestLink(klass, newlink):
def findBestLink(klass, newlink):
parent_class = klass.parent
@@ -195,7 +195,7 @@ def FindBestLink(klass, newlink):
else:
return ':attr:`~%s`'%child.name
full_loop = FindInHierarchy(klass, newlink)
full_loop = findInHierarchy(klass, newlink)
if full_loop:
return full_loop
@@ -203,7 +203,7 @@ def FindBestLink(klass, newlink):
return ':ref:`%s`'%newlink
def KillEpydoc(klass, newtext):
def killEpydoc(klass, newtext):
epydocs = re.findall(EPYDOC_PATTERN, newtext)
@@ -256,7 +256,7 @@ def KillEpydoc(klass, newtext):
newlink = '``%s``'%newlink
else:
# Try and reference it
bestlink = FindBestLink(klass, newlink)
bestlink = findBestLink(klass, newlink)
if bestlink:
newlink = bestlink
@@ -406,7 +406,7 @@ class Library(ParentBase):
self.obj_type = 'Library'
self.python_version = ''
self.sphinx_file = MakeSphinxFile(name)
self.sphinx_file = makeSphinxFile(name)
self.base_name = name
@@ -489,13 +489,13 @@ class Library(ParentBase):
header = templates.TEMPLATE_DESCRIPTION%(self.base_name, self.base_name)
stream.write(header)
newtext = ReplaceWxDot(self.docs)
newtext = KillEpydoc(self, newtext)
newtext = replaceWxDot(self.docs)
newtext = killEpydoc(self, newtext)
stream.write(newtext + '\n\n')
generic_summary(self, stream)
WriteSphinxOutput(stream, self.sphinx_file)
writeSphinxOutput(stream, self.sphinx_file)
def ClassesToPickle(self, obj, class_dict):
@@ -512,7 +512,7 @@ class Library(ParentBase):
if child.is_redundant:
continue
class_dict[child.name] = (child.method_list, child.bases, ChopDescription(child.docs))
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)
@@ -538,7 +538,7 @@ class Module(ParentBase):
ParentBase.__init__(self, name, kind)
self.filename = ''
self.sphinx_file = MakeSphinxFile(name)
self.sphinx_file = makeSphinxFile(name)
if kind == object_types.PACKAGE:
self.obj_type = 'Package'
@@ -574,8 +574,8 @@ class Module(ParentBase):
stream.write(header)
newtext = ReplaceWxDot(self.docs)
newtext = KillEpydoc(self, newtext)
newtext = replaceWxDot(self.docs)
newtext = killEpydoc(self, newtext)
stream.write(newtext + '\n\n')
@@ -589,7 +589,7 @@ class Module(ParentBase):
if self.kind != object_types.PACKAGE:
print(('%s - %s (module)'%(spacer, self.name)))
if self.inheritance_diagram:
png, map = self.inheritance_diagram.MakeInheritanceDiagram(class_summary)
png, map = self.inheritance_diagram.makeInheritanceDiagram(class_summary)
short_name = self.GetShortName()
image_desc = templates.TEMPLATE_INHERITANCE % ('module', short_name, png, short_name, map)
stream.write(image_desc)
@@ -614,7 +614,7 @@ class Module(ParentBase):
continue
fun.Write(stream)
WriteSphinxOutput(stream, self.sphinx_file)
writeSphinxOutput(stream, self.sphinx_file)
def Save(self):
@@ -691,7 +691,7 @@ class Class(ParentBase):
self.order = 3
self.obj_type = 'Class'
self.sphinx_file = MakeSphinxFile(name)
self.sphinx_file = makeSphinxFile(name)
def ToRest(self, class_summary):
@@ -707,32 +707,32 @@ class Class(ParentBase):
stream.write('.. currentmodule:: %s\n\n'%current_module)
stream.write('.. highlight:: python\n\n')
class_docs = ReplaceWxDot(self.docs)
class_docs = KillEpydoc(self, class_docs)
class_docs = replaceWxDot(self.docs)
class_docs = killEpydoc(self, class_docs)
header = templates.TEMPLATE_DESCRIPTION%(self.name, self.GetShortName())
stream.write(header)
stream.write(class_docs + '\n\n')
if self.inheritance_diagram:
png, map = self.inheritance_diagram.MakeInheritanceDiagram(class_summary)
png, map = self.inheritance_diagram.makeInheritanceDiagram(class_summary)
short_name = self.GetShortName()
image_desc = templates.TEMPLATE_INHERITANCE % ('class', short_name, png, short_name, map)
stream.write(image_desc)
appearance = FindControlImages(self.name.lower())
appearance = findControlImages(self.name.lower())
if appearance:
appearance_desc = templates.TEMPLATE_APPEARANCE % tuple(appearance)
stream.write(appearance_desc + '\n\n')
if self.subClasses:
subs = [FormatExternalLink(cls) for cls in self.subClasses]
subs = [formatExternalLink(cls) for cls in self.subClasses]
subs = ', '.join(subs)
subs_desc = templates.TEMPLATE_SUBCLASSES % subs
stream.write(subs_desc)
if self.superClasses:
sups = [FormatExternalLink(cls) for cls in self.superClasses]
sups = [formatExternalLink(cls) for cls in self.superClasses]
sups = ', '.join(sups)
sups_desc = templates.TEMPLATE_SUPERCLASSES % sups
stream.write(sups_desc)
@@ -757,7 +757,7 @@ class Class(ParentBase):
for prop in properties:
prop.Write(stream, short_name)
WriteSphinxOutput(stream, self.sphinx_file)
writeSphinxOutput(stream, self.sphinx_file)
self.bases = self.superClasses
@@ -937,12 +937,12 @@ class Method(ChildrenBase):
return
text = ''
newdocs = ReplaceWxDot(self.docs)
newdocs = replaceWxDot(self.docs)
for line in newdocs.splitlines(True):
text += indent + line
text = KillEpydoc(self, text)
text = killEpydoc(self, text)
text += '\n\n\n'
stream.write(text)
@@ -1002,7 +1002,7 @@ class Attribute(ChildrenBase):
def __init__(self, name, specs, value):
if IsPython3():
if isPython3():
specs = str(specs)
else:
specs = unicode(specs)

View File

@@ -29,7 +29,7 @@ from .librarydescription import Method, Property, Attribute
from . import inheritance
from .utilities import IsPython3, PickleFile
from .utilities import isPython3, PickleFile
from .constants import object_types, EXCLUDED_ATTRS, MODULE_TO_ICON
from .constants import CONSTANT_RE
@@ -156,7 +156,7 @@ def analyze_params(obj, signature):
pvalue = pvalue.strip()
if pname in pevals:
try:
if IsPython3():
if isPython3():
peval = str(pevals[pname])
else:
peval = unicode(pevals[pname])
@@ -224,7 +224,7 @@ def inspect_source(method_class, obj, source):
def is_classmethod(instancemethod):
""" Determine if an instancemethod is a classmethod. """
attribute = (IsPython3() and ['__self__'] or ['im_self'] )[0]
attribute = (isPython3() and ['__self__'] or ['im_self'])[0]
if hasattr(instancemethod, attribute):
return getattr(instancemethod, attribute) is not None
@@ -284,17 +284,17 @@ def describe_func(obj, parent_class, module_name):
try:
if method in [object_types.METHOD, object_types.METHOD_DESCRIPTOR, object_types.INSTANCE_METHOD]:
if IsPython3():
if isPython3():
code = obj.__func__.__code__
else:
code = obj.im_func.func_code
elif method == object_types.STATIC_METHOD:
if IsPython3():
if isPython3():
code = obj.__func__.__code__
else:
code = obj.im_func.func_code
else:
if IsPython3():
if isPython3():
obj.__code__
else:
code = obj.func_code

View File

@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
#---------------------------------------------------------------------------
# Name: sphinxtools/postprocess.py
# Author: Andrea Gavana
@@ -20,7 +19,7 @@ import random
from buildtools.config import copyIfNewer, writeIfChanged, newer, getVcsRev, textfile_open
from . import templates
from .utilities import Wx2Sphinx, PickleFile
from .utilities import wx2Sphinx, PickleFile
from .constants import HTML_REPLACE, TODAY, SPHINXROOT, SECTIONS_EXCLUDE
from .constants import CONSTANT_INSTANCES, WIDGETS_IMAGES_ROOT, SPHINX_IMAGES_ROOT
from .constants import DOCSTRING_KEY
@@ -28,7 +27,7 @@ from .constants import DOCSTRING_KEY
# ----------------------------------------------------------------------- #
def MakeHeadings():
def makeHeadings():
"""
Generates the "headings.inc" file containing the substitution reference
for the small icons used in the Sphinx titles, sub-titles and so on.
@@ -60,7 +59,7 @@ def MakeHeadings():
# ----------------------------------------------------------------------- #
def SphinxIndexes(sphinxDir):
def sphinxIndexes(sphinxDir):
"""
This is the main function called after the `etg` process has finished.
@@ -73,16 +72,16 @@ def SphinxIndexes(sphinxDir):
for file in pklfiles:
if file.endswith('functions.pkl'):
ReformatFunctions(file)
reformatFunctions(file)
elif 'classindex' in file:
MakeClassIndex(sphinxDir, file)
makeClassIndex(sphinxDir, file)
BuildEnumsAndMethods(sphinxDir)
buildEnumsAndMethods(sphinxDir)
# ----------------------------------------------------------------------- #
def BuildEnumsAndMethods(sphinxDir):
def buildEnumsAndMethods(sphinxDir):
"""
This function does some clean-up/refactoring of the generated ReST files by:
@@ -140,8 +139,8 @@ def BuildEnumsAndMethods(sphinxDir):
text = newtext
text = FindInherited(input, class_summary, enum_base, text)
text, unreferenced_classes = RemoveUnreferenced(input, class_summary, enum_base, unreferenced_classes, text)
text = findInherited(input, class_summary, enum_base, text)
text, unreferenced_classes = removeUnreferenced(input, class_summary, enum_base, unreferenced_classes, text)
text = text.replace('wx``', '``')
text = text.replace('wx.``', '``')
@@ -178,8 +177,8 @@ def BuildEnumsAndMethods(sphinxDir):
# Remove lines with "Event macros" in them...
text = text.replace('Event macros:', '')
text = TooltipsOnInheritance(text, class_summary)
text = AddSpacesToLinks(text)
text = tooltipsOnInheritance(text, class_summary)
text = addSpacesToLinks(text)
if text != orig_text:
fid = textfile_open(input, 'wt')
@@ -218,7 +217,7 @@ def BuildEnumsAndMethods(sphinxDir):
# ----------------------------------------------------------------------- #
def FindInherited(input, class_summary, enum_base, text):
def findInherited(input, class_summary, enum_base, text):
# Malformed inter-links
regex = re.findall(r'\S:meth:\S+', text)
@@ -307,7 +306,7 @@ def FindInherited(input, class_summary, enum_base, text):
# ----------------------------------------------------------------------- #
def RemoveUnreferenced(input, class_summary, enum_base, unreferenced_classes, text):
def removeUnreferenced(input, class_summary, enum_base, unreferenced_classes, text):
regex = re.findall(':ref:`(.*?)`', text)
@@ -342,7 +341,7 @@ def RemoveUnreferenced(input, class_summary, enum_base, unreferenced_classes, te
# ----------------------------------------------------------------------- #
def AddSpacesToLinks(text):
def addSpacesToLinks(text):
regex = re.findall('\w:ref:`(.*?)`', text)
@@ -353,7 +352,7 @@ def AddSpacesToLinks(text):
# ----------------------------------------------------------------------- #
def ReformatFunctions(file):
def reformatFunctions(file):
text_file = os.path.splitext(file)[0] + '.txt'
local_file = os.path.split(file)[1]
@@ -407,7 +406,7 @@ def ReformatFunctions(file):
# ----------------------------------------------------------------------- #
def MakeClassIndex(sphinxDir, file):
def makeClassIndex(sphinxDir, file):
text_file = os.path.splitext(file)[0] + '.txt'
local_file = os.path.split(file)[1]
@@ -456,13 +455,13 @@ def MakeClassIndex(sphinxDir, file):
out = classes[cls]
if '=====' in out:
out = ''
text += '%-80s %s\n' % (':ref:`%s`' % Wx2Sphinx(cls)[1], out)
text += '%-80s %s\n' % (':ref:`%s`' % wx2Sphinx(cls)[1], out)
text += 80*'=' + ' ' + 80*'=' + '\n\n'
contents = []
for cls in names:
contents.append(Wx2Sphinx(cls)[1])
contents.append(wx2Sphinx(cls)[1])
for enum in enum_base:
if enum.count('.') == enumDots:
@@ -481,7 +480,7 @@ def MakeClassIndex(sphinxDir, file):
# ----------------------------------------------------------------------- #
def GenGallery():
def genGallery():
link = '<div class="gallery_class">'
@@ -545,7 +544,7 @@ def GenGallery():
# ----------------------------------------------------------------------- #
def AddPrettyTable(text):
def addPrettyTable(text):
""" Unused at the moment. """
newtext = """<br>
@@ -566,7 +565,7 @@ def AddPrettyTable(text):
# ----------------------------------------------------------------------- #
def ClassToFile(line):
def classToFile(line):
if '&#8211' not in line:
return line
@@ -592,7 +591,7 @@ def ClassToFile(line):
# ----------------------------------------------------------------------- #
def AddJavaScript(text):
def addJavaScript(text):
jsCode = """\
<script>
@@ -622,7 +621,7 @@ def AddJavaScript(text):
# ----------------------------------------------------------------------- #
def PostProcess(folder):
def postProcess(folder):
fileNames = glob.glob(folder + "/*.html")
@@ -654,7 +653,7 @@ def PostProcess(folder):
split = os.path.split(files)[1]
if split in ['index.html', 'main.html']:
text = ChangeSVNRevision(text)
text = changeSVNRevision(text)
else:
text = text.replace('class="headerimage"', 'class="headerimage-noshow"')
@@ -699,7 +698,7 @@ def PostProcess(folder):
for old, new in list(enum_dict.items()):
newtext = newtext.replace(old, new)
newtext = AddJavaScript(newtext)
newtext = addJavaScript(newtext)
if orig_text != newtext:
fid = open(files, "wt")
@@ -709,14 +708,14 @@ def PostProcess(folder):
# ----------------------------------------------------------------------- #
def ChangeSVNRevision(text):
def changeSVNRevision(text):
REVISION = getVcsRev()
text = text.replace('|TODAY|', TODAY)
text = text.replace('|VCSREV|', REVISION)
return text
def TooltipsOnInheritance(text, class_summary):
def tooltipsOnInheritance(text, class_summary):
graphviz = re.findall(r'<p class="graphviz">(.*?)</p>', text, re.DOTALL)

View File

@@ -39,7 +39,8 @@ from .constants import DOXYROOT, SPHINXROOT, WIDGETS_IMAGES_ROOT
# ----------------------------------------------------------------------- #
class odict(UserDict):
class ODict(UserDict):
"""
An ordered dict (odict). This is a dict which maintains an order to its items;
the order is rather like that of a list, in that new items are, by default,
@@ -105,7 +106,7 @@ class odict(UserDict):
# ----------------------------------------------------------------------- #
def RemoveWxPrefix(name):
def removeWxPrefix(name):
"""
Removes the `wx` prefix from a string.
@@ -129,7 +130,7 @@ def RemoveWxPrefix(name):
# ----------------------------------------------------------------------- #
def IsNumeric(input_string):
def isNumeric(input_string):
"""
Checks if the string `input_string` actually represents a number.
@@ -150,7 +151,7 @@ def IsNumeric(input_string):
# ----------------------------------------------------------------------- #
def CountSpaces(text):
def countSpaces(text):
"""
Counts the number of spaces before and after a string.
@@ -169,7 +170,7 @@ def CountSpaces(text):
# ----------------------------------------------------------------------- #
def Underscore2Capitals(string):
def underscore2Capitals(string):
"""
Replaces the underscore letter in a string with the following letter capitalized.
@@ -189,7 +190,7 @@ def Underscore2Capitals(string):
# ----------------------------------------------------------------------- #
def ReplaceCppItems(line):
def replaceCppItems(line):
"""
Replaces various C++ specific stuff with more Pythonized version of them.
@@ -233,7 +234,7 @@ def ReplaceCppItems(line):
# ----------------------------------------------------------------------- #
def PythonizeType(ptype, is_param):
def pythonizeType(ptype, is_param):
"""
Replaces various C++ specific stuff with more Pythonized version of them,
for parameter lists and return types (i.e., the `:param:` and `:rtype:`
@@ -251,7 +252,7 @@ def PythonizeType(ptype, is_param):
elif 'wx.' in ptype:
ptype = ptype[3:]
else:
ptype = Wx2Sphinx(ReplaceCppItems(ptype))[1]
ptype = wx2Sphinx(replaceCppItems(ptype))[1]
ptype = ptype.replace('::', '.').replace('*&', '')
ptype = ptype.replace('int const', 'int')
@@ -263,7 +264,7 @@ def PythonizeType(ptype, is_param):
ptype = ptype.replace(item, 'int')
ptype = ptype.strip()
ptype = RemoveWxPrefix(ptype)
ptype = removeWxPrefix(ptype)
if '. wx' in ptype:
ptype = ptype.replace('. wx', '.')
@@ -312,7 +313,7 @@ def PythonizeType(ptype, is_param):
# ----------------------------------------------------------------------- #
def ConvertToPython(text):
def convertToPython(text):
"""
Converts the input `text` into a more ReSTified version of it.
@@ -344,7 +345,7 @@ def ConvertToPython(text):
spacer = ' '*(len(line) - len(line.lstrip()))
line = ReplaceCppItems(line)
line = replaceCppItems(line)
for word in RE_KEEP_SPACES.split(line):
@@ -362,8 +363,8 @@ def ConvertToPython(text):
continue
if newword not in IGNORE and not newword.startswith('wx.'):
word = RemoveWxPrefix(word)
newword = RemoveWxPrefix(newword)
word = removeWxPrefix(word)
newword = removeWxPrefix(newword)
if "::" in word and not word.endswith("::"):
# Bloody SetCursorEvent...
@@ -375,7 +376,7 @@ def ConvertToPython(text):
if newword.upper() == newword and newword not in PUNCTUATION and \
newword not in IGNORE and len(newword.strip()) > 1 and \
not IsNumeric(newword) and newword not in ['DC', 'GCDC']:
not isNumeric(newword) and newword not in ['DC', 'GCDC']:
if '``' not in newword and '()' not in word and '**' not in word:
word = word.replace(newword, "``%s``"%newword)
@@ -396,7 +397,7 @@ def ConvertToPython(text):
# ----------------------------------------------------------------------- #
def FindDescendants(element, tag, descendants=None):
def findDescendants(element, tag, descendants=None):
"""
Finds and returns all descendants of a specific `xml.etree.ElementTree.Element`
whose tag matches the input `tag`.
@@ -420,14 +421,14 @@ def FindDescendants(element, tag, descendants=None):
if childElement.tag == tag:
descendants.append(childElement)
descendants = FindDescendants(childElement, tag, descendants)
descendants = findDescendants(childElement, tag, descendants)
return descendants
# ----------------------------------------------------------------------- #
def FindControlImages(elementOrString):
def findControlImages(elementOrString):
"""
Given the input `element` (an instance of `xml.etree.ElementTree.Element`
or a plain string)
@@ -457,15 +458,15 @@ def FindControlImages(elementOrString):
class_name = py_class_name = elementOrString.lower()
else:
element = elementOrString
class_name = RemoveWxPrefix(element.name) or element.pyName
py_class_name = Wx2Sphinx(class_name)[1]
class_name = removeWxPrefix(element.name) or element.pyName
py_class_name = wx2Sphinx(class_name)[1]
class_name = class_name.lower()
py_class_name = py_class_name.lower()
image_folder = os.path.join(DOXYROOT, 'images')
appearance = odict()
appearance = ODict()
for sub_folder in ['wxmsw', 'wxmac', 'wxgtk']:
@@ -504,7 +505,7 @@ def FindControlImages(elementOrString):
# ----------------------------------------------------------------------- #
def MakeSummary(class_name, item_list, template, kind, add_tilde=True):
def makeSummary(class_name, item_list, template, kind, add_tilde=True):
"""
This function generates a table containing a method/property name
and a shortened version of its docstrings.
@@ -564,7 +565,7 @@ def MakeSummary(class_name, item_list, template, kind, add_tilde=True):
# ----------------------------------------------------------------------- #
def WriteSphinxOutput(stream, filename, append=False):
def writeSphinxOutput(stream, filename, append=False):
"""
Writes the text contained in the `stream` to the `filename` output file.
@@ -586,7 +587,7 @@ def WriteSphinxOutput(stream, filename, append=False):
# ----------------------------------------------------------------------- #
def ChopDescription(text):
def chopDescription(text):
"""
Given the (possibly multiline) input text, this function will get the
first non-blank line up to the next newline character.
@@ -641,7 +642,7 @@ class PickleFile(object):
# ----------------------------------------------------------------------- #
def PickleItem(description, current_module, name, kind):
def pickleItem(description, current_module, name, kind):
"""
This function pickles/unpickles a dictionary containing class names as keys
and class brief description (chopped docstrings) as values to build the
@@ -669,7 +670,7 @@ def PickleItem(description, current_module, name, kind):
# ----------------------------------------------------------------------- #
def PickleClassInfo(class_name, element, short_description):
def pickleClassInfo(class_name, element, short_description):
"""
Saves some information about a class in a pickle-compatible file., i.e. the
list of methods in that class and its super-classes.
@@ -684,7 +685,7 @@ def PickleClassInfo(class_name, element, short_description):
method_list.append(method)
for base in element.bases:
bases.append(Wx2Sphinx(base)[1])
bases.append(wx2Sphinx(base)[1])
pickle_file = os.path.join(SPHINXROOT, 'class_summary.lst')
with PickleFile(pickle_file) as pf:
@@ -698,10 +699,9 @@ def PickleClassInfo(class_name, element, short_description):
# many items added on the fly to try and keep track of them separately. We
# can add the module name to the saved data while in the etg/generator stage.
global ALL_ITEMS
ALL_ITEMS = {}
def Class2Module():
def class2Module():
global ALL_ITEMS
@@ -719,7 +719,7 @@ def Class2Module():
for item in module.ITEMS:
item = RemoveWxPrefix(item)
item = removeWxPrefix(item)
ALL_ITEMS[item] = current_module
ALL_ITEMS.update(NO_MODULE)
@@ -727,7 +727,7 @@ def Class2Module():
return ALL_ITEMS
def Wx2Sphinx(name):
def wx2Sphinx(name):
"""
Converts a wxWidgets specific string into a Phoenix-ReST-ready string.
@@ -738,7 +738,7 @@ def Wx2Sphinx(name):
name = name[0:name.index('<')]
name = name.strip()
newname = fullname = RemoveWxPrefix(name)
newname = fullname = removeWxPrefix(name)
if '.' in newname and len(newname) > 3:
lookup, remainder = newname.split('.')
@@ -747,7 +747,7 @@ def Wx2Sphinx(name):
lookup = newname
remainder = ''
all_items = Class2Module()
all_items = class2Module()
if lookup in all_items:
fullname = all_items[lookup] + lookup + remainder
@@ -772,7 +772,7 @@ RAW_2 = """
"""
def FormatContributedSnippets(kind, contrib_snippets):
def formatContributedSnippets(kind, contrib_snippets):
"""
This method will include and properly ReST-ify contributed snippets
of wxPython code (at the moment only 2 snippets are available), by
@@ -821,7 +821,7 @@ def FormatContributedSnippets(kind, contrib_snippets):
return text
def FormatExternalLink(fullname, inheritance=False):
def formatExternalLink(fullname, inheritance=False):
"""
Analyzes the input `fullname` string to check whether a class description
is actually coming from an external documentation tool
@@ -872,7 +872,7 @@ def FormatExternalLink(fullname, inheritance=False):
return full_page
def IsPython3():
def isPython3():
""" Returns ``True`` if we are using Python 3.x. """
return sys.version_info >= (3, )