Beispiel #1
0
def image_tasks(conf, app):
    paths = conf.paths

    meta_file = get_images_metadata_file(conf)

    if 'images' not in conf.system.files.data:
        logger.info('no images to generate')
        return

    if isinstance(conf.system.files.data.images, list):
        images = conf.system.files.data.images
    else:
        images = [conf.system.files.data.images]

    for image in images:
        image['dir'] = paths.images
        source_base = os.path.join(paths.projectroot, image['dir'],
                                   image['name'])
        source_file = dot_concat(source_base, 'svg')
        rst_file = dot_concat(source_base, 'rst')
        image['conf'] = conf

        t = app.add('task')
        t.conf = conf
        t.job = generate_image_pages
        t.args = image
        t.description = "generating rst include file {0} for {1}".format(
            rst_file, source_file)
        t.target = rst_file
        t.dependency = meta_file
        logger.debug('adding task for image rst file: {0}'.format(rst_file))

        for output in image['output']:
            if 'tag' in output:
                tag = '-' + output['tag']
            else:
                tag = ''

            target_img = source_base + tag + '.png'

            inkscape_cmd = '{cmd} -z -d {dpi} -w {width} -y 0.0 -e >/dev/null {target} {source}'

            t = app.add('task')
            t.conf = conf
            t.job = _generate_images
            t.args = [
                inkscape_cmd, output['dpi'], output['width'], target_img,
                source_file
            ]
            t.target = target_img
            t.dependency = [meta_file, source_file]
            t.description = 'generating image file {0} from {1}'.format(
                target_img, source_file)
            logger.debug(
                'adding image creation job for {0}'.format(target_img))
Beispiel #2
0
def json_output_tasks(conf, app):
    regexes = [
        (re.compile(r'<a class=\"headerlink\"'), '<a'),
        (re.compile(r'<[^>]*>'), ''),
        (re.compile(r'&#8220;'), '"'),
        (re.compile(r'&#8221;'), '"'),
        (re.compile(r'&#8216;'), "'"),
        (re.compile(r'&#8217;'), "'"),
        (re.compile(r'&#\d{4};'), ''),
        (re.compile(r'&nbsp;'), ''),
        (re.compile(r'&gt;'), '>'),
        (re.compile(r'&lt;'), '<')
    ]

    outputs = []
    for fn in expand_tree('source', 'txt'):
        # path = build/<branch>/json/<filename>

        if 'edition' in conf.project and conf.project.edition != conf.project.name:
            path = os.path.join(conf.paths.branch_output,
                                'json-' + conf.project.edition,
                                os.path.splitext(fn.split(os.path.sep, 1)[1])[0])

        else:
            path = os.path.join(conf.paths.branch_output,
                                'json', os.path.splitext(fn.split(os.path.sep, 1)[1])[0])



        fjson = dot_concat(path, 'fjson')
        json = dot_concat(path, 'json')

        task = app.add('task')
        task.target = json
        task.dependency = fjson
        task.job = process_json_file
        task.description = "processing json file".format(json)
        task.args = [fjson, json, regexes, conf]

        outputs.append(json)

    list_file = os.path.join(conf.paths.branch_output, 'json-file-list')

    list_task = app.add('task')
    list_task.target = list_file
    list_task.job = generate_list_file
    list_task.args = [outputs, list_file, conf]

    output = app.add('app')
    out_task = output.add('task')
    out_task.job = json_output
    out_task.args = [conf]
    out_task.description = 'transfer json output to public directory'
Beispiel #3
0
def json_output_tasks(conf, app):
    regexes = [
        (re.compile(r'<a class=\"headerlink\"'), '<a'),
        (re.compile(r'<[^>]*>'), ''),
        (re.compile(r'&#8220;'), '"'),
        (re.compile(r'&#8221;'), '"'),
        (re.compile(r'&#8216;'), "'"),
        (re.compile(r'&#8217;'), "'"),
        (re.compile(r'&#\d{4};'), ''),
        (re.compile(r'&nbsp;'), ''),
        (re.compile(r'&gt;'), '>'),
        (re.compile(r'&lt;'), '<')
    ]

    outputs = []
    for fn in expand_tree('source', 'txt'):
        # path = build/<branch>/json/<filename>

        if 'edition' in conf.project and conf.project.edition != conf.project.name:
            path = os.path.join(conf.paths.branch_output,
                                'json-' + conf.project.edition, 
                                os.path.splitext(fn.split(os.path.sep, 1)[1])[0])
            
        else:
            path = os.path.join(conf.paths.branch_output,
                                'json', os.path.splitext(fn.split(os.path.sep, 1)[1])[0])



        fjson = dot_concat(path, 'fjson')
        json = dot_concat(path, 'json')

        task = app.add('task')
        task.target = json
        task.dependency = fjson
        task.job = process_json_file
        task.description = "processing json file".format(json)
        task.args = [fjson, json, regexes, conf]

        outputs.append(json)

    list_file = os.path.join(conf.paths.branch_output, 'json-file-list')

    list_task = app.add('task')
    list_task.target = list_file
    list_task.job = generate_list_file
    list_task.args = [outputs, list_file, conf]

    output = app.add('app')
    out_task = output.add('task')
    out_task.job = json_output
    out_task.args = [conf]
    out_task.description = 'transfer json output to public directory'
Beispiel #4
0
def image_tasks(conf, app):
    paths = conf.paths

    meta_file = get_images_metadata_file(conf)

    if 'images' not in conf.system.files.data:
        logger.info('no images to generate')
        return

    if isinstance(conf.system.files.data.images, list):
        images = conf.system.files.data.images
    else:
        images = [ conf.system.files.data.images ]

    for image in images:
        image['dir'] = paths.images
        source_base = os.path.join(paths.projectroot, image['dir'], image['name'])
        source_file = dot_concat(source_base, 'svg')
        rst_file = dot_concat(source_base, 'rst')
        image['conf'] = conf

        t = app.add('task')
        t.conf = conf
        t.job = generate_image_pages
        t.args = image
        t.description = "generating rst include file {0} for {1}".format(rst_file, source_file)
        t.target = rst_file
        t.dependency = meta_file
        logger.debug('adding task for image rst file: {0}'.format(rst_file))

        for output in image['output']:
            if 'tag' in output:
                tag = '-' + output['tag']
            else:
                tag = ''

            target_img = source_base + tag + '.png'

            inkscape_cmd = '{cmd} -z -d {dpi} -w {width} -y 0.0 -e >/dev/null {target} {source}'

            t = app.add('task')
            t.conf = conf
            t.job = _generate_images
            t.args = [ inkscape_cmd, output['dpi'], output['width'], target_img, source_file ]
            t.target = target_img
            t.dependency = [ meta_file, source_file ]
            t.description = 'generating image file {0} from {1}'.format(target_img, source_file)
            logger.debug('adding image creation job for {0}'.format(target_img))
Beispiel #5
0
def image_clean(conf, app):
    if 'images' not in conf.system.files.data:
        logger.info('no images to clean')
        return

    for image in conf.system.files.data.images:
        source_base = os.path.join(conf.paths.projectroot, conf.paths.images, image['name'])

        rm_rst = app.add('task')
        rm_rst.job = verbose_remove
        rm_rst.args = dot_concat(source_base, 'rst')

        for output in image['output']:
            rm_tag_image = app.add('task')
            rm_tag_image.job = verbose_remove
            if 'tag' in output:
                rm_tag_image.args = dot_concat(hyph_concat(source_base, output['tag']), 'png')
            else:
                rm_tag_image.args = dot_concat(source_base, 'png')
Beispiel #6
0
def image_clean(conf, app):
    if 'images' not in conf.system.files.data:
        logger.info('no images to clean')
        return

    for image in conf.system.files.data.images:
        source_base = os.path.join(conf.paths.projectroot, image['dir'], image['name'])

        rm_rst = app.add('task')
        rm_rst.job = verbose_remove
        rm_rst.args = dot_concat(source_base, 'rst')

        for output in image['output']:
            rm_tag_image = app.add('task')
            rm_tag_image.job = verbose_remove
            if 'tag' in otuput:
                rm_tag_image.args = dot_concat(hyph_concat(source_base, tag), 'png')
            else:
                rm_tag_image.args = dot_concat(source_base, 'png')
Beispiel #7
0
def api_target(source):
    return dot_concat(os.path.splitext(source)[0], 'rst')
Beispiel #8
0
def _get_list_table_output_name(fn):
    base, leaf = os.path.split(os.path.splitext(fn)[0])

    return dot_concat(
        hyph_concat(os.path.join(base, 'table', leaf[6:]), 'list'), 'rst')
Beispiel #9
0
def image_tasks(conf, app):
    meta_file = get_images_metadata_file(conf)

    if 'images' not in conf.system.files.data:
        logger.info('no images to generate')
        return

    if isinstance(conf.system.files.data.images, list):
        images = conf.system.files.data.images
    else:
        images = [ conf.system.files.data.images ]

    image_dir = conf.paths.branch_images

    for image in images:
        image['dir'] = image_dir
        image['conf'] = conf

        source_base = os.path.join(conf.paths.projectroot, image['dir'], image['name'])
        source_file = dot_concat(source_base, 'svg')
        source_core = os.path.join(conf.paths.projectroot, conf.paths.branch_images, image['name'] + '.svg' )
        rst_file = dot_concat(source_base, 'rst')

        if not os.path.isfile(source_core):
            logger.error('"{0}" does not exist'.format(source_core))
            continue

        t = app.add('task')
        t.conf = conf
        t.job = generate_image_pages
        t.args = image # as kwargs
        t.description = "generating rst include file {0} for {1}".format(rst_file, source_core)
        t.target = rst_file
        t.dependency = [meta_file, os.path.abspath(__file__) ]
        logger.debug('adding task for image rst file: {0}'.format(rst_file))

        if conf.runstate.fast is True:
            continue

        for output in image['output']:
            if output['type'] == 'offset':
                build_type = 'eps'
            else:
                build_type = 'png'

            if 'tag' in output:
                tag = '-' + output['tag']
            else:
                tag = ''

            target_img = ''.join([source_base, tag, '.', build_type])

            if build_type == 'png':
                inkscape_cmd = '{cmd} -z -d {dpi} -w {width} -y 0.0 -e >/dev/null {target} {source}'
            elif build_type == 'eps':
                inkscape_cmd = '{cmd} -z -d {dpi} -w {width} -y 1.0 -E >/dev/null {target} {source}'

            t = app.add('task')
            t.conf = conf
            t.job = _generate_images
            t.args = [ inkscape_cmd, output['dpi'], output['width'], target_img, source_file ]
            t.target = target_img
            t.dependency = [ source_core ]
            t.description = 'generating image file {0} from {1}'.format(target_img, source_core)
            logger.debug('adding image creation job for {0}'.format(target_img))
Beispiel #10
0
def _get_list_table_output_name(fn):
    base, leaf = os.path.split(os.path.splitext(fn)[0])

    return dot_concat(hyph_concat(os.path.join(base, 'table', leaf[6:]), 'list'), 'rst')
Beispiel #11
0
def api_target(source):
    return dot_concat(os.path.splitext(source)[0], 'rst')
Beispiel #12
0
html_copy_source = False
html_use_smartypants = True
html_domain_indices = True
html_use_index = True
html_split_index = False
html_show_sourcelink = False
html_show_sphinx = True
html_show_copyright = True

manual_edition_path = '{0}/{1}/{2}'.format(conf.project.url,
                                           conf.git.branches.current,
                                           sconf.theme.book_path_base)

html_theme_options = {
    'branch': conf.git.branches.current,
    'pdfpath': dot_concat(manual_edition_path, 'pdf'),
    'epubpath': dot_concat(manual_edition_path, 'epub'),
    'manual_path': get_manual_path(conf),
    'translations': languages,
    'language': language,
    'repo_name': sconf.theme.repo,
    'jira_project': sconf.theme.jira,
    'google_analytics': sconf.theme.google_analytics,
    'project': sconf.theme.project,
    'version': version,
    'version_selector': get_versions(conf),
    'stable': conf.version.stable,
    'sitename': sconf.theme.sitename,
    'nav_excluded': sconf.theme.nav_excluded,
}
Beispiel #13
0
html_copy_source = False
html_use_smartypants = True
html_domain_indices = True
html_use_index = True
html_split_index = False
html_show_sourcelink = False
html_show_sphinx = True
html_show_copyright = True

manual_edition_path = '{0}/{1}/{2}'.format(conf.project.url,
                                           conf.git.branches.current,
                                           sconf.theme.book_path_base)

html_theme_options = {
    'branch': conf.git.branches.current,
    'pdfpath': dot_concat(manual_edition_path, 'pdf'),
    'epubpath': dot_concat(manual_edition_path, 'epub'),
    'manual_path': get_manual_path(conf),
    'translations': languages,
    'language': language,
    'repo_name': sconf.theme.repo,
    'jira_project': sconf.theme.jira,
    'google_analytics': sconf.theme.google_analytics,
    'project': sconf.theme.project,
    'version': version,
    'version_selector': get_versions(conf),
    'stable': conf.version.stable,
    'sitename': sconf.theme.sitename,
    'nav_excluded': sconf.theme.nav_excluded,
}