當前位置: 首頁>>代碼示例>>Python>>正文


Python rstcloth.RstCloth類代碼示例

本文整理匯總了Python中rstcloth.rstcloth.RstCloth的典型用法代碼示例。如果您正苦於以下問題:Python RstCloth類的具體用法?Python RstCloth怎麽用?Python RstCloth使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了RstCloth類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: generate_hash_file

def generate_hash_file(fn, conf):
    r = RstCloth()

    if os.path.exists(fn):
        with open(fn, 'r') as f:
            existing = f.read()
    else:
        existing = []

    commit = conf.git.commit
    r.directive('|commit| replace', '``{0}``'.format(commit))

    try:
        if r.data == existing[:-1]:
            logger.debug('no new commit(s), not updating {0} ({1})'.format(fn, commit[:10]))
            return True
    except TypeError:
        logger.warning('problem generating {0}, continuing'.format(fn))
        if os.path.exists(fn):
            os.utime(fn, None)
        else:
            with open(fn, 'a'):
                os.utime(fn, None)
    else:
        r.write(fn)
        logger.debug('regenerated {0} with new commit hash: {1}'.format(fn, commit[:10]))
開發者ID:i80and,項目名稱:docs-tools,代碼行數:26,代碼來源:hash.py

示例2: render_apiarg_table

def render_apiarg_table(r, apiargs):
    table = TableData()

    header = [apiargs.field_type()]

    if apiargs.has_type() is True:
        header.append('Type')

    header.append('Description')

    num_columns = len(header)
    table.add_header(header)

    if num_columns == 2:
        widths = [20, 80]
        for entry in apiargs.ordered_content():
            table.add_row([RstCloth.pre(entry.name),
                           fill(string=entry.description, first=0, hanging=3, wrap=False)])
    elif num_columns == 3:
        widths = [20, 20, 80]
        for entry in apiargs.ordered_content():
            table.add_row([RstCloth.pre(entry.name),
                           entry.type_for_table_output(),
                           fill(string=entry.description, first=0, hanging=3, wrap=False)])

    r.content(TableBuilder(ListTable(table, widths=widths)).output, indent=3)
開發者ID:i80and,項目名稱:docs-tools,代碼行數:26,代碼來源:views.py

示例3: generate_release_copy

def generate_release_copy(builder, release):
    r = RstCloth()

    r.directive('code-block', 'sh', block='header')
    r.newline(block='header')

    r.content('mkdir -p mongodb', 3, wrap=False, block='cmd')
    r.content('cp -R -n mongodb-{0}-{1}/ mongodb'.format(builder, release), 3, wrap=False, block='cmd')

    return r
開發者ID:Yingminzhou,項目名稱:docs-tools,代碼行數:10,代碼來源:release.py

示例4: __init__

    def __init__(self, option):
        if not isinstance(option, Option):
            raise TypeError
        else:
            self.option = option

        self.rst = RstCloth()
開發者ID:Yingminzhou,項目名稱:docs-tools,代碼行數:7,代碼來源:options.py

示例5: setup_replacements

def setup_replacements(content):
    if content.interface == "command": 
        role_type = "dbcommand"
    elif content.interface == "method": 
        role_type = "method"
    elif content.interface == "phpmethod":
        role_type = "phpmethod"
    else: 
        role_type = "samp"

    if "role" not in content.replacement:
        content.replacement["role"] = RstCloth.role(role_type, content.operation)

    if "type" not in content.replacement: 
        if isinstance(content.type, list):
            if len(content.type) == 1: 
                content.replacement["type"] = content.type[0]
            elif len(content.type) == 2: 
                content.replacement["type"] = "or".join(content.type)
            else: 
                types = copy.copy(content.type)
                types[-1] = "and " + types[-1]
                content.replacement["type"] = ",".join(types)
        else: 
            content.replacement["type"] = content.type

    if "argname" not in content.replacement:
        content.replacement["argname"] = content.name
開發者ID:fviolette,項目名稱:docs-tools,代碼行數:28,代碼來源:views.py

示例6: setup_replacements

def setup_replacements(content):
    if content.interface == 'command':
        role_type = 'dbcommand'
    elif content.interface == 'method':
        role_type = 'method'
    elif content.interface == 'phpmethod':
        role_type = 'phpmethod'
    else:
        role_type = 'samp'

    if 'role' not in content.replacement:
        content.replacement['role'] = RstCloth.role(role_type, content.operation)

    if 'type' not in content.replacement:
        if isinstance(content.type, list):
            if len(content.type) == 1:
                content.replacement['type'] = content.type[0]
            elif len(content.type) == 2:
                content.replacement['type'] = 'or'.join(content.type)
            else:
                types = copy.copy(content.type)
                types[-1] = 'and ' + types[-1]
                content.replacement['type'] = ','.join(types)
        else:
            content.replacement['type'] = content.type

    if 'argname' not in content.replacement:
        content.replacement['argname'] = content.name
開發者ID:i80and,項目名稱:docs-tools,代碼行數:28,代碼來源:views.py

示例7: render_toctree

def render_toctree(toc_items, is_ref=False):
    r = RstCloth()

    r.directive('toctree', fields=[('titlesonly', ''), ('hidden', '')])
    r.newline()

    for entry in toc_items:
        if is_ref is False and 'name' in entry:
            r.content('{0} <{1}>'.format(entry.name, entry.file), indent=3, wrap=False)
        else:
            r.content(entry.file, indent=3, wrap=False)

    return r
開發者ID:jdestefano-mongo,項目名稱:docs-tools,代碼行數:13,代碼來源:views.py

示例8: get_include_statement

def get_include_statement(include_file):
    r = RstCloth()
    r.newline()

    r.directive('include', include_file)
    r.newline()

    return '\n'.join(r.data)
開發者ID:fviolette,項目名稱:docs-tools,代碼行數:8,代碼來源:views.py

示例9: __init__

    def __init__(self, steps, conf):
        if not isinstance(steps, Steps):
            raise TypeError
        else:
            self.steps = steps

        self.conf = conf
        self.current_step = 1
        self.rst = RstCloth()
        self.hook()
開發者ID:Yingminzhou,項目名稱:docs-tools,代碼行數:10,代碼來源:steps.py

示例10: generate_release_untar

def generate_release_untar(builder, release):
    r = RstCloth()

    r.directive('code-block', 'sh', block='header')
    r.newline(block='header')

    r.content('tar -zxvf mongodb-{0}-{1}.tgz'.format(builder, release), 3, wrap=False, block='cmd')

    return r
開發者ID:Yingminzhou,項目名稱:docs-tools,代碼行數:9,代碼來源:release.py

示例11: get_replacements

def get_replacements(conf):
    if "replacement" in conf.system.files.data:
        mapping = conf.system.files.data.replacement
    else:
        return []

    r = RstCloth()

    try:
        if conf.version.release != "Upcoming":
            mapping['release-string'] = "-- {0} Release".format(conf.version.release)
        else:
            mapping['release-string'] = "\ "
    except:
        pass

    for k, v in mapping.items():
        r.replacement(k, v)

    return r.data
開發者ID:fviolette,項目名稱:docs-tools,代碼行數:20,代碼來源:replacements.py

示例12: render_extracts

def render_extracts(extract):
    r = RstCloth()
    extract.render()

    indent = 0
    if 'only' in extract:
        r.directive('only', extract.only, indent=indent)
        r.newline()
        indent += 3

    if 'style' in extract:
        r.directive('rst-class', extract.style, indent=indent)
        r.newline()

    render_action(extract, indent=indent, level=extract.level, r=r)

    return r
開發者ID:fviolette,項目名稱:docs-tools,代碼行數:17,代碼來源:views.py

示例13: render_glossary

def render_glossary(terms):
    r = RstCloth()

    r.directive(name="glossary", fields=[("sorted", "")])
    r.newline()

    for term in terms.ordered_content():
        r.definition(term.term, term.definition, wrap=False, indent=3)

    return r
開發者ID:fviolette,項目名稱:docs-tools,代碼行數:10,代碼來源:views.py

示例14: render_toc_table

def render_toc_table(toc_items):
    table = TableData()

    table.add_header(['Name', 'Description'])
    for entry in toc_items:
        entry.render()
        if 'name' in entry:
            table.add_row([entry.name, entry.description])
        else:
            table.add_row([RstCloth.role('doc', entry.file), entry.description])

    return TableBuilder(RstTable(table))
開發者ID:jdestefano-mongo,項目名稱:docs-tools,代碼行數:12,代碼來源:views.py

示例15: build_contents

 def build_contents(self):
     self.contents = RstCloth()
     self.contents.directive('class', 'hidden')
     self.contents.newline()
     self.contents.directive('toctree', fields=[('titlesonly', '')], indent=3)
     self.contents.newline()
開發者ID:Yingminzhou,項目名稱:docs-tools,代碼行數:6,代碼來源:toc.py


注:本文中的rstcloth.rstcloth.RstCloth類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。