Example #1
0
def GenGallery():

    link = '<div class="gallery_class">'

    link_template = """\
    <table><caption align="bottom"><a href="%s"<b>%s</b></a</caption>
    <tr>
    <td><a href="%s"><img src="_static/images/widgets/fullsize/%s/%s" border="20" alt="%s"/></a>
    </td>
    </tr>
    </table>
    """

    image_folder = WIDGETS_IMAGES_ROOT
    platforms = ['wxmsw', 'wxgtk', 'wxmac']

    image_files = {}

    pwd = os.getcwd()

    for folder in platforms:
        plat_folder = os.path.join(image_folder, folder)
        os.chdir(plat_folder)
        
        image_files[folder] = glob.glob('*.png')

    os.chdir(pwd)

    txt_files = glob.glob(SPHINXROOT + '/*.txt')
    html_files = {}

    for text in txt_files:
        simple = os.path.split(os.path.splitext(text)[0])[1]
        possible = simple.split('.')[-1]
        possible = possible.lower()
        html_files[possible + '.png'] = simple + '.html'

    keys = list(html_files.keys())
    keys.sort()

    text = ''
    
    for key in keys:
        possible_png = key
        html = html_files[possible_png]

        rand_list = list(range(3))
        random.shuffle(rand_list)

        for plat_index in rand_list:
            platform = platforms[plat_index]
            plat_images = image_files[platform]

            if possible_png in plat_images:
                text += link_template%(html, os.path.splitext(html)[0], html, platform, possible_png, os.path.splitext(html)[0])
                text += '\n'
                break

    gallery = os.path.join(SPHINXROOT, '_templates', 'gallery.html')
    writeIfChanged(gallery, templates.TEMPLATE_GALLERY % text)
Example #2
0
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.

    The small icons are stored into the ``SPHINX_IMAGES_ROOT`` folder.    

    .. note:: The "headings.inc" file is created in the ``SPHINXROOT`` folder
       (see `sphinxtools/constants.py`).
    """

    images = glob.glob(SPHINX_IMAGES_ROOT + '/*.png')
    images.sort()
    
    heading_file = os.path.join(SPHINXROOT, 'headings.inc')

    text = ""
    for img in images:
        name = os.path.split(os.path.splitext(img)[0])[1]
        rel_path_index = img.find('_static')
        rel_path = img[rel_path_index:]

        width = 32
        if 'overload' in name or 'contributed' in name:
            width = 16

        text += templates.TEMPLATE_HEADINGS % (name, os.path.normpath(rel_path), width)

    writeIfChanged(heading_file, text)    
Example #3
0
def MakeClassIndex(sphinxDir, file):

    text_file = os.path.splitext(file)[0] + '.txt'
    local_file = os.path.split(file)[1]

    if not newer(file, text_file):
        return
    
    fid = open(file, 'rb')
    classes = pickle.load(fid)
    fid.close()
    
    if local_file.count('.') == 1:
        # Core functions
        label = 'Core'
        module = ''
        enumDots = 1
    else:
        label = local_file.split('.')[0:-2][0]
        module = label
        enumDots = 2

    enum_files = glob.glob(sphinxDir + '/%s*.enumeration.txt'%module)
    enum_base = [os.path.split(os.path.splitext(enum)[0])[1] for enum in enum_files]

    names = list(classes.keys())
    names.sort()

    text = ''
    if module:
        text += '\n\n.. module:: %s\n\n'%module
        
    text += templates.TEMPLATE_CLASS_INDEX % (label, label)

    text += 80*'=' + ' ' + 80*'=' + '\n'
    text += '%-80s **Short Description**\n'%'**Class**'
    text += 80*'=' + ' ' + 80*'=' + '\n'

    for cls in names:
        text += '%-80s %s\n'%(':ref:`%s`'%Wx2Sphinx(cls)[1], classes[cls])

    text += 80*'=' + ' ' + 80*'=' + '\n\n'

    contents = []
    for cls in names:
        contents.append(Wx2Sphinx(cls)[1])

    for enum in enum_base:
        if enum.count('.') == enumDots:
            contents.append(enum)

    contents.sort()
    
    toctree = ''
    for item in contents:
        toctree += '   %s\n'%item

    text += templates.TEMPLATE_TOCTREE%toctree
        
    writeIfChanged(text_file, text)
Example #4
0
def reformatFunctions(file):

    text_file = os.path.splitext(file)[0] + '.txt'
    local_file = os.path.split(file)[1]

    if not newer(file, text_file):
        return

    pf = PickleFile(file)
    functions = pf.read()

    if local_file.count('.') == 2:
        # Core functions
        label = 'wx'
    else:
        label = '.'.join(local_file.split('.')[0:2])

    names = list(functions.keys())
    names = [name.lower() for name in names]
    names.sort()

    text = templates.TEMPLATE_FUNCTION_SUMMARY % (label, label)

    letters = []
    for fun in names:
        upper = fun[0].upper()
        if upper not in letters:
            letters.append(upper)

    text += '  |  '.join(
        [':ref:`%s <%s %s>`' % (letter, label, letter) for letter in letters])
    text += '\n\n\n'

    names = list(functions.keys())
    names = sorted(names, key=str.lower)
    imm = ItemModuleMap()

    for letter in letters:
        text += '.. _%s %s:\n\n%s\n^\n\n' % (label, letter, letter)
        for fun in names:
            if fun[0].upper() != letter:
                continue

            text += '* :func:`%s`\n' % imm.get_fullname(fun)

        text += '\n\n'

    text += 'Functions\n=============\n\n'

    for fun in names:
        text += functions[fun] + '\n'

    writeIfChanged(text_file, text)
Example #5
0
def ReformatFunctions(file):

    text_file = os.path.splitext(file)[0] + '.txt'
    local_file = os.path.split(file)[1]

    if not newer(file, text_file):
        return

    fid = open(file, 'rb')
    functions = pickle.load(fid)
    fid.close()

    if local_file.count('.') == 1:
        # Core functions
        label = 'Core'
    else:
        label = local_file.split('.')[0:-2][0]

    names = list(functions.keys())
    names = [name.lower() for name in names]
    names.sort()

    text = templates.TEMPLATE_FUNCTION_SUMMARY % (label, label)

    letters = []
    for fun in names:
        upper = fun[0].upper()
        if upper not in letters:
            letters.append(upper)

    text += '  |  '.join(
        [':ref:`%s <%s %s>`' % (letter, label, letter) for letter in letters])
    text += '\n\n\n'

    names = list(functions.keys())
    names = sorted(names, key=str.lower)

    for letter in letters:
        text += '.. _%s %s:\n\n%s\n^\n\n' % (label, letter, letter)
        for fun in names:
            if fun[0].upper() != letter:
                continue

            text += '* :func:`%s`\n' % fun

        text += '\n\n'

    text += 'Functions\n=============\n\n'

    for fun in names:
        text += functions[fun] + '\n'

    writeIfChanged(text_file, text)
Example #6
0
def ReformatFunctions(file):

    text_file = os.path.splitext(file)[0] + '.txt'
    local_file = os.path.split(file)[1]
    
    if not newer(file, text_file):
        return
    
    fid = open(file, 'rb')
    functions = pickle.load(fid)
    fid.close()
    
    if local_file.count('.') == 1:
        # Core functions
        label = 'Core'
    else:
        label = local_file.split('.')[0:-2][0]

    names = list(functions.keys())
    names = [name.lower() for name in names]
    names.sort()

    text = templates.TEMPLATE_FUNCTION_SUMMARY % (label, label)

    letters = []
    for fun in names:
        upper = fun[0].upper()
        if upper not in letters:
            letters.append(upper)

    text += '  |  '.join([':ref:`%s <%s %s>`'%(letter, label, letter) for letter in letters])
    text += '\n\n\n'

    names = list(functions.keys())
    names = sorted(names, key=str.lower)

    for letter in letters:
        text += '.. _%s %s:\n\n%s\n^\n\n'%(label, letter, letter)
        for fun in names:
            if fun[0].upper() != letter:
                continue

            text += '* :func:`%s`\n'%fun

        text += '\n\n'

    text += 'Functions\n=============\n\n'

    for fun in names:
        text += functions[fun] + '\n'
    
    writeIfChanged(text_file, text)
Example #7
0
def reformatFunctions(file):

    text_file = os.path.splitext(file)[0] + '.txt'
    local_file = os.path.split(file)[1]

    if not newer(file, text_file):
        return

    pf = PickleFile(file)
    functions = pf.read()

    if local_file.count('.') == 2:
        # Core functions
        label = 'wx'
    else:
        label = '.'.join(local_file.split('.')[0:2])

    names = list(functions.keys())
    names = [name.lower() for name in names]
    names.sort()

    text = templates.TEMPLATE_FUNCTION_SUMMARY % (label, label)

    letters = []
    for fun in names:
        upper = fun[0].upper()
        if upper not in letters:
            letters.append(upper)

    text += '  |  '.join([':ref:`%s <%s %s>`'%(letter, label, letter) for letter in letters])
    text += '\n\n\n'

    names = list(functions.keys())
    names = sorted(names, key=str.lower)
    imm = ItemModuleMap()

    for letter in letters:
        text += '.. _%s %s:\n\n%s\n^\n\n'%(label, letter, letter)
        for fun in names:
            if fun[0].upper() != letter:
                continue

            text += '* :func:`%s`\n' % imm.get_fullname(fun)

        text += '\n\n'

    text += 'Functions\n=============\n\n'

    for fun in names:
        text += functions[fun] + '\n'

    writeIfChanged(text_file, text)
Example #8
0
def ReformatFunctions(file):

    text_file = os.path.splitext(file)[0] + ".txt"
    local_file = os.path.split(file)[1]

    if not newer(file, text_file):
        return

    fid = open(file, "rb")
    functions = pickle.load(fid)
    fid.close()

    if local_file.count(".") == 1:
        # Core functions
        label = "Core"
    else:
        label = local_file.split(".")[0:-2][0]

    names = list(functions.keys())
    names = [name.lower() for name in names]
    names.sort()

    text = templates.TEMPLATE_FUNCTION_SUMMARY % (label, label)

    letters = []
    for fun in names:
        upper = fun[0].upper()
        if upper not in letters:
            letters.append(upper)

    text += "  |  ".join([":ref:`%s <%s %s>`" % (letter, label, letter) for letter in letters])
    text += "\n\n\n"

    names = list(functions.keys())
    names = sorted(names, key=str.lower)

    for letter in letters:
        text += ".. _%s %s:\n\n%s\n^\n\n" % (label, letter, letter)
        for fun in names:
            if fun[0].upper() != letter:
                continue

            text += "* :func:`%s`\n" % fun

        text += "\n\n"

    text += "Functions\n=============\n\n"

    for fun in names:
        text += functions[fun] + "\n"

    writeIfChanged(text_file, text)
def makeModuleIndex(sphinxDir, file):

    text_file = os.path.splitext(file)[0] + '.txt'
    local_file = os.path.split(file)[1]

    if not newer(file, text_file):
        return

    pf = PickleFile(file)
    classes = pf.read()
    module_docstring = classes.get(DOCSTRING_KEY)
    if module_docstring is not None:
        del classes[DOCSTRING_KEY]

    if local_file.startswith('wx.1'):
        # Core functions
        label = 'wx'
        module = 'wx'
        enumDots = 2
        # Take care to get only files starting with "wx.UpperName", not
        # "wx.lower.UpperName". This is so we don't put all the enums in the
        # submodules in the core wx module too.
        # TODO: This may not work on case-insensitive file systems, check it.
        enum_files = glob.glob(sphinxDir + '/wx.[A-Z]*.enumeration.txt')
    else:
        label = '.'.join(local_file.split('.')[0:2])
        module = label
        enumDots = 3
        enum_files = glob.glob(sphinxDir + '/%s*.enumeration.txt' % module)

    enum_base = [os.path.split(os.path.splitext(enum)[0])[1] for enum in enum_files]

    imm = ItemModuleMap()
    names = list(classes.keys())
    names.sort(key=lambda n: imm.get_fullname(n))

    # Workaround to sort names in a case-insensitive way
    lower_to_name = {}
    for name in names:
        lower_to_name[name.lower()] = name

    text = ''
    if module:
        text += '\n\n.. module:: %s\n\n' % module

    text += templates.TEMPLATE_CLASS_INDEX % (label, module_docstring)

    text += 80*'=' + ' ' + 80*'=' + '\n'
    text += '%-80s **Short Description**\n' % '**Class**'
    text += 80*'=' + ' ' + 80*'=' + '\n'

    lower_names = list(lower_to_name.keys())
    lower_names.sort()

    for lower in lower_names:
        cls = lower_to_name[lower]
        out = classes[cls]
        if '=====' in out:
            out = ''
        text += '%-80s %s\n' % (':ref:`~%s`' % wx2Sphinx(cls)[1], out)

    text += 80*'=' + ' ' + 80*'=' + '\n\n'

    contents = []
    for lower in lower_names:
        cls = lower_to_name[lower]
        contents.append(wx2Sphinx(cls)[1])

    for enum in enum_base:
        if enum.count('.') == enumDots:
            contents.append(enum)

    contents.sort()

    # Are there functions for this module too?
    functionsFile = os.path.join(sphinxDir, module + '.functions.pkl')
    if os.path.exists(functionsFile):
        pf = PickleFile(functionsFile)
        functions = list(pf.read().keys())
        functions.sort(key=lambda n: imm.get_fullname(n))

        pf = PickleFile(os.path.join(SPHINXROOT, 'function_summary.pkl'))
        function_summaries = pf.read()

        text += templates.TEMPLATE_MODULE_FUNCTION_SUMMARY
        text += 80*'=' + ' ' + 80*'=' + '\n'
        text += '%-80s **Short Description**\n' % '**Function**'
        text += 80*'=' + ' ' + 80*'=' + '\n'

        for func_name in functions:
            fullname = imm.get_fullname(func_name)
            doc = function_summaries.get(fullname, '')
            text += '%-80s %s\n' % (':func:`~%s`' % fullname, doc)

        text += 80 * '=' + ' ' + 80 * '=' + '\n\n'
        contents.append(module + '.functions')

    toctree = ''
    for item in contents:
        toctree += '   %s\n' % item

    text += templates.TEMPLATE_TOCTREE % toctree

    writeIfChanged(text_file, text)
Example #10
0
def MakeClassIndex(sphinxDir, file):

    text_file = os.path.splitext(file)[0] + ".txt"
    local_file = os.path.split(file)[1]

    if not newer(file, text_file):
        return

    fid = open(file, "rb")
    classes = pickle.load(fid)
    fid.close()

    if local_file.count(".") == 1:
        # Core functions
        label = "Core"
        module = ""
        enumDots = 1
    else:
        label = local_file.split(".")[0:-2][0]
        module = label
        enumDots = 2

    enum_files = glob.glob(sphinxDir + "/%s*.enumeration.txt" % module)
    enum_base = [os.path.split(os.path.splitext(enum)[0])[1] for enum in enum_files]

    names = list(classes.keys())
    names.sort()

    text = ""
    if module:
        text += "\n\n.. module:: %s\n\n" % module

    text += templates.TEMPLATE_CLASS_INDEX % (label, label)

    text += 80 * "=" + " " + 80 * "=" + "\n"
    text += "%-80s **Short Description**\n" % "**Class**"
    text += 80 * "=" + " " + 80 * "=" + "\n"

    for cls in names:
        out = classes[cls]
        if "=====" in out:
            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])

    for enum in enum_base:
        if enum.count(".") == enumDots:
            contents.append(enum)

    contents.sort()

    toctree = ""
    for item in contents:
        toctree += "   %s\n" % item

    text += templates.TEMPLATE_TOCTREE % toctree

    writeIfChanged(text_file, text)