Exemplo n.º 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)
Exemplo n.º 2
0
def build_mg_help():
    for lang in ['en', 'fr', 'de', 'it', 'cs', 'ru']:
        mg_basepath = op.join(HSGIT_ROOT, 'moneyguru')
        help_basepath = op.join(mg_basepath, 'help', lang)
        help_destpath = op.join(HTML_PATH, 'moneyguru', 'help', lang)
        changelog_path = op.join(mg_basepath, 'help', 'changelog')
        confpath = op.join(mg_basepath, 'help', 'conf.tmpl')
        credits_path = op.join(mg_basepath, 'help', 'credits.rst')
        credits_tmpl = op.join(help_basepath, 'credits.tmpl')
        credits_out = op.join(help_basepath, 'credits.rst')
        filereplace(credits_tmpl, credits_out, credits=open(credits_path, 'rt', encoding='utf-8').read())
        image_src = op.join(mg_basepath, 'help', 'image_osx')
        image_dst = op.join(help_basepath, 'image')
        if not op.exists(image_dst):
            os.symlink(image_src, image_dst)
        tixurl = "https://github.com/hsoft/moneyguru/issues/{}"
        confrepl = {'platform': 'osx'}
        sphinxgen.gen(help_basepath, help_destpath, changelog_path, tixurl, confrepl, confpath)