Esempio n. 1
0
def egg_index_page(docs_path, template_path, eggs_path, copy_eggs=False, eggs_dir='eggs'):
    from dreamweavertemplate import DreamweaverTemplateInstance
    if not os.path.exists(os.path.join(docs_path, eggs_dir)):
        os.mkdir(os.path.join(docs_path, eggs_dir))
    if copy_eggs:
        filenames = []
        for filename in os.listdir(eggs_path):
            if filename.endswith('.tar.gz') or filename.endswith('.egg'):
                filenames.append(os.path.join(eggs_path, filename))
        copy_files_to(filenames, os.path.join(docs_path, eggs_dir))
    names = []
    for filename in os.listdir(os.path.join(docs_path, eggs_dir)):
        if filename.endswith('.tar.gz'):
            names.append(filename)
    if os.path.exists(os.path.join(docs_path, eggs_dir, 'index.html')):
        page = DreamweaverTemplateInstance(
            filename=os.path.join(docs_path, eggs_dir, 'index.html')
        )
    else:
        page = DreamweaverTemplateInstance(
            filename=template_path
        )
    page['doctitle'] = '<title>%s</title>'%'Eggs'
    page['heading'] = 'Eggs'
    page['content'] = '<ul>'
    names.sort()
    for i, name in enumerate(names):
        page['content'] += '<li>'
        page['content'] +=  '<a href="%s">%s</a>'%(name, name)
    page['content'] += '</ul>'
    page.save_as_page(
        filename=os.path.join(docs_path, eggs_dir, 'index.html')
    )
Esempio n. 2
0
def main_index_page(docs_path, template_path, exclude=None):
    from dreamweavertemplate import DreamweaverTemplateInstance
    if exclude is None:
        exclude=[]
    # We don't treat the eggs dir as a package
    exclude.append('eggs')
    versions = []
    for filename in os.listdir(docs_path):
        if filename not in exclude and \
           os.path.isdir(os.path.join(docs_path, filename)):
            versions.append(filename)
    if os.path.exists(os.path.join(docs_path, 'index.html')):
        page = DreamweaverTemplateInstance(
            filename=os.path.join(docs_path, 'index.html')
        )
    else:
        page = DreamweaverTemplateInstance(
            filename=template_path
        )
    name = 'Code'
    page['doctitle'] = '<title>%s</title>'%name
    page['heading'] = name
    data = page['content']
    top = data[:data.find('<ul>')]
    last = data[data.find('</ul>')+5:]
    page['content'] = top+'<ul>'
    versions.sort()
    for i, version in enumerate(versions):
        page['content'] += '<li><a href="%s/index.html">%s</a> %s</li>'%(
            version, 
            version, 
            '',
        )
    page['content'] += '</ul>'+last
    page.save_as_page(
        filename=os.path.join(docs_path, 'index.html')
    )
Esempio n. 3
0
def package_index_page(eggs_path, package_docs_path, template_path, pkg_info):
    """\
    docs_path
        the directory containing the docs for all the modules
    dir
        The destination directory for the partcilular package's docs
    pkg_info
        Package Info
    """
    from dreamweavertemplate import DreamweaverTemplateInstance
    name = pkg_info['Name'][0]
    doc_versions = []
    for filename in os.listdir(package_docs_path):
        if os.path.isdir(os.path.join(package_docs_path, filename)):
            doc_versions.append(filename)
    file_versions = {}
    for filename in os.listdir(eggs_path):
        if filename.startswith(name) and filename.endswith('.tar.gz'):
            version = filename[:-len('.tar.gz')].split('-')[1]
            file_versions[version] = (filename, 'tar.gz')
    # Get a template or page
    if os.path.exists(os.path.join(package_docs_path, 'index.html')):
        page = DreamweaverTemplateInstance(
            filename=os.path.join(package_docs_path, 'index.html')
        )
    else:
        page = DreamweaverTemplateInstance(
            filename=template_path,
        )
    # Generate the index page
    page['doctitle'] = '<title>%s</title>'%name
    page['heading'] = name
    summary = pkg_info['Summary'][0]
    if not summary.endswith('.'):
        summary += '.'
    page['content'] = '<p>'+summary+'</p>'
    page['content'] += (
        '<p>Development status :%s, License: %s, Author: %s</p>'
    )%(
        pkg_info['Status'][0],
        pkg_info['License'][0],
        pkg_info['Author'][0]
    )
    page['content'] += '<ul>'
    doc_versions.sort()
    doc_versions.reverse()
    # Add the list of versions for the package
    for i, version in enumerate(doc_versions):
        page['content'] += '<li>'
        if i==0:
            page['content'] += '<b>Latest - '
        else:
            page['content'] += 'Archive - '
        page['content'] += 'Documentation: <a href="%s/index.html">%s</a> '%(
            version, 
            version,
        )
        if file_versions.has_key(version):
            page['content'] += 'Download: '
            filename, type = file_versions[version]
            page['content'] += '<a href="../eggs/%s">%s</a>, '%(
                filename, 
                type
            )
        page['content'] = page['content'][:-2]
        if i==0:
            page['content'] += '</b>'
        page['content'] += '</li>'
    page['content'] += '</ul>'
    # Save the page
    page.save_as_page(
        filename=os.path.join(package_docs_path, 'index.html'),
    )