Beispiel #1
0
def gen(basepath, destpath, changelogpath, tixurl, confrepl=None, confpath=None, changelogtmpl=None):
    """Generate sphinx docs with all bells and whistles.

    basepath: The base sphinx source path.
    destpath: The final path of html files
    changelogpath: The path to the changelog file to insert in changelog.rst.
    tixurl: The URL (with one formattable argument for the tix number) to the ticket system.
    confrepl: Dictionary containing replacements that have to be made in conf.py. {name: replacement}
    """
    if confrepl is None:
        confrepl = {}
    if confpath is None:
        confpath = op.join(basepath, 'conf.tmpl')
    if changelogtmpl is None:
        changelogtmpl = op.join(basepath, 'changelog.tmpl')
    changelog = read_changelog_file(changelogpath)
    tix = tixgen(tixurl)
    rendered_logs = []
    for log in changelog:
        description = tix(log['description'])
        # The format of the changelog descriptions is in markdown, but since we only use bulled list
        # and links, it's not worth depending on the markdown package. A simple regexp suffice.
        description = re.sub(r'\[(.*?)\]\((.*?)\)', '`\\1 <\\2>`__', description)
        rendered = CHANGELOG_FORMAT.format(version=log['version'], date=log['date_str'],
            description=description)
        rendered_logs.append(rendered)
    confrepl['version'] = changelog[0]['version']
    changelog_out = op.join(basepath, 'changelog.rst')
    filereplace(changelogtmpl, changelog_out, changelog='\n'.join(rendered_logs))
    conf_out = op.join(basepath, 'conf.py')
    filereplace(confpath, conf_out, **confrepl)
    cmd = 'sphinx-build "{}" "{}"'.format(basepath, destpath)
    print_and_do(cmd)
Beispiel #2
0
 def __init__(self, data):
     self.name = data['name']
     self.short_name = data.get('shortname', self.name)
     self.logo_name = data['logo']
     self.weburl = data['weburl']
     dls = data['downloads']
     self.changelog_path = data['changelog']
     if not op.isabs(self.changelog_path):
         self.changelog_path = op.join(HSGIT_ROOT, self.changelog_path)
     if self.changelog_path.endswith('yaml'):
         changelogs = yaml.load(open(self.changelog_path))
     else:
         changelogs = read_changelog_file(self.changelog_path)
     self.changelogs = [AppChangelog(self, log) for log in changelogs]
     self.downloads = []
     for p, dlitem in dls.items():
         if isinstance(dlitem, dict):
             fp = dlitem['href']
             reqs = dlitem.get('requirements', '')
             reqs = reqs.replace('{old}', '<a href="#oldversions">older</a>')
         else:
             fp = dlitem
             reqs = None
         if fp.startswith('http'):
             download = AppUrl(fp, p)
         else:
             download = AppDownload(self, p, fp)
         download.requirements = reqs
         self.downloads.append(download)
     DL_ORDER = ['osx', 'deb32', 'deb64', 'deball', 'arch', 'win64', 'win']
     sort_key = lambda dl: DL_ORDER.index(dl.platform)
     self.downloads.sort(key=sort_key)
     self.tixurl = data['tixurl']
     self.tixfunc = tixgen(self.tixurl)