コード例 #1
0
ファイル: includes.py プロジェクト: fviolette/docs-tools
def graph(args):
    c = fetch_config(args)

    if c.runstate.include_mask is None:
        render_for_console(include_files(conf=c))
    else:
        mask = c.runstate.include_mask
        if mask.startswith(c.paths.source):
            mask = mask[6:]
        elif mask.startswith('/' + c.paths.source):
            mask = mask[7:]

        render_for_console(includes_masked(mask=mask, conf=c))
コード例 #2
0
def graph(args):
    c = fetch_config(args)

    if c.runstate.include_mask is None:
        render_for_console(include_files(conf=c))
    else:
        mask = c.runstate.include_mask
        if mask.startswith(c.paths.source):
            mask = mask[6:]
        elif mask.startswith('/' + c.paths.source):
            mask = mask[7:]

        render_for_console(includes_masked(mask=mask, conf=c))
コード例 #3
0
ファイル: dependencies.py プロジェクト: i80and/docs-tools
def refresh_deps(conf):
    with Timer('resolve dependency graph'):
        # resolve a map of the source files to the files they depend on
        # (i.e. the ones that they include).
        graph = include_files(conf=conf)

        # load, if possible, a mappping of all source files with hashes from the
        # last build.
        if not os.path.exists(conf.system.dependency_cache):
            dep_map = None
        else:
            with open(conf.system.dependency_cache, 'r') as f:
                try:
                    dep_cache = json.load(f)
                    dep_map = dep_cache['files']
                except ValueError:
                    dep_map = None
                    m = 'no stored dependency information, will rebuild more things than necessary.'
                    logger.warning(m)

    with Timer('dependency updates'):
        _refresh_deps(graph, dep_map, conf)
コード例 #4
0
def refresh_deps(conf):
    with Timer('resolve dependency graph'):
        # resolve a map of the source files to the files they depend on
        # (i.e. the ones that they include).
        graph = include_files(conf=conf)

        # load, if possible, a mappping of all source files with hashes from the
        # last build.
        if not os.path.exists(conf.system.dependency_cache):
            dep_map = None
        else:
            with open(conf.system.dependency_cache, 'r') as f:
                try:
                    dep_cache = json.load(f)
                    dep_map = dep_cache['files']
                except ValueError:
                    dep_map = None
                    m = 'no stored dependency information, will rebuild more things than necessary.'
                    logger.warning(m)

    with Timer('dependency updates'):
        _refresh_deps(graph, dep_map, conf)
コード例 #5
0
ファイル: includes.py プロジェクト: fviolette/docs-tools
def list(args):
    c = fetch_config(args)

    render_for_console(include_files(conf=c).keys())
コード例 #6
0
ファイル: includes.py プロジェクト: banlyst/docs-tools
def list(args):
    c = fetch_config(args)

    render_for_console(include_files(conf=c).keys())
コード例 #7
0
ファイル: includes.py プロジェクト: MarkTseng/docs-tools
def include_file_data(conf):
    inc_path = os.path.join(conf.paths.includes)
    include_file_list = expand_tree(path=inc_path, input_extension=None)
    include_graph = include_files(conf=conf)

    recursive_use = included_recusively(conf, include_graph)
    generated = generated_includes(conf)

    omni = {}
    for idx, fn in enumerate(include_file_list):
        incf = fn[len(conf.paths.source):]

        if fn.endswith('~'):
            continue

        for prefix in suppressed_page_prefixes:
            if incf.startswith(prefix):
                break
        else:
            omni[incf] = {
                'id': idx,
                'name': os.path.splitext(incf)[0],
                'path': incf,
            }

            if incf in generated:
                omni[incf]['generated'] = True
            else:
                omni[incf]['generated'] = False

            if incf in recursive_use:
                omni[incf]['recursive'] = True
            else:
                omni[incf]['recursive'] = False

            if incf in include_graph:
                omni[incf]['num_clients'] = len(include_graph[incf])

                omni[incf]['clients'] = []
                for cl in include_graph[incf]:
                    cl, ext = os.path.splitext(cl)

                    if ext == 'yaml':
                        continue
                    if (cl.startswith('/includes/generated/overview') or
                        cl.startswith('/includes/manpage-')):
                        continue

                    omni[incf]['clients'].append(cl)

                if len(omni[incf]['clients']) == 0:
                    omni[incf]['yaml_only'] = True
                else:
                    omni[incf]['yaml_only'] = False
            else:
                omni[incf]['clients'] = dict()
                omni[incf]['num_clients'] = 0

            with open(fn, 'r') as f:
                omni[incf]['content'] = [ ln.rstrip() for ln in f.readlines() ]

    return omni
コード例 #8
0
def include_file_data(conf):
    inc_path = os.path.join(conf.paths.includes)
    include_file_list = expand_tree(path=inc_path, input_extension=None)
    include_graph = include_files(conf=conf)

    recursive_use = included_recusively(conf, include_graph)
    generated = generated_includes(conf)

    omni = {}
    for idx, fn in enumerate(include_file_list):
        incf = fn[len(conf.paths.source):]

        if fn.endswith('~'):
            continue

        for prefix in suppressed_page_prefixes:
            if incf.startswith(prefix):
                break
        else:
            omni[incf] = {
                'id': idx,
                'name': os.path.splitext(incf)[0],
                'path': incf,
            }

            if incf in generated:
                omni[incf]['generated'] = True
            else:
                omni[incf]['generated'] = False

            if incf in recursive_use:
                omni[incf]['recursive'] = True
            else:
                omni[incf]['recursive'] = False

            if incf in include_graph:
                omni[incf]['num_clients'] = len(include_graph[incf])

                omni[incf]['clients'] = []
                for cl in include_graph[incf]:
                    cl, ext = os.path.splitext(cl)

                    if ext == 'yaml':
                        continue
                    if (cl.startswith('/includes/generated/overview') or
                        cl.startswith('/includes/manpage-')):
                        continue

                    omni[incf]['clients'].append(cl)

                if len(omni[incf]['clients']) == 0:
                    omni[incf]['yaml_only'] = True
                else:
                    omni[incf]['yaml_only'] = False
            else:
                omni[incf]['clients'] = dict()
                omni[incf]['num_clients'] = 0

            with open(fn, 'r') as f:
                omni[incf]['content'] = [ ln.rstrip() for ln in f.readlines() ]

    return omni