当前位置: 首页>>代码示例>>Python>>正文


Python Markdown.set_output_format方法代码示例

本文整理汇总了Python中markdown.Markdown.set_output_format方法的典型用法代码示例。如果您正苦于以下问题:Python Markdown.set_output_format方法的具体用法?Python Markdown.set_output_format怎么用?Python Markdown.set_output_format使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在markdown.Markdown的用法示例。


在下文中一共展示了Markdown.set_output_format方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from markdown import Markdown [as 别名]
# 或者: from markdown.Markdown import set_output_format [as 别名]
def main():
    m = Markdown(extensions=["plueprint"])
    m.set_output_format("apiblueprint")
    tests_dir = os.path.join(os.path.dirname(__file__), "api-blueprint",
                             "examples")
    skip_number = 0
    index = 0
    for doc in sorted(os.listdir(tests_dir)):
        if os.path.splitext(doc)[1] != ".md" or doc == "README.md":
            continue
        index += 1
        if index <= skip_number:
            continue
        with codecs.open(os.path.join(tests_dir, doc), "r", "utf-8") as fin:
            txt = fin.read()
        api = m.convert(txt)
        print("-- %s --" % doc)
        print(api)
        try:
            api[">"].print_resources()
        except KeyError:
            pass
        print("Actions:")
        for action in api["/"]:
            print(action)
开发者ID:eduardozamin,项目名称:plueprint,代码行数:27,代码来源:test.py

示例2: __init__

# 需要导入模块: from markdown import Markdown [as 别名]
# 或者: from markdown.Markdown import set_output_format [as 别名]
 def __init__(self, templatefile, *apifiles, **kwargs):
     if len(apifiles) == 0:
         raise ValueError("There must be at least one APIBlueprint file "
                          "specified")
     include_comments = kwargs.pop("include_comments", True)
     base_class = kwargs.pop("base_class", None)
     if base_class is None:
         base_class = "rest_framework.test.APITestCase"
     self._use_html2text = kwargs.pop("html2text", False)
     m = Markdown(extensions=["plueprint"])
     m.set_output_format("apiblueprint")
     with codecs.open(apifiles[0], "r", "utf-8") as fin:
         self._api = m.convert(fin.read())
     for f in apifiles[1:]:
         with codecs.open(f, "r", "utf-8") as fin:
             self._api.merge(m.convert(fin.read()))
     env = Environment(loader=FileSystemLoader(templatefile),
                       autoescape=False, trim_blocks=True,
                       lstrip_blocks=True,
                       extensions=("jinja2.ext.loopcontrols",))
     env.filters["symbolize"] = self._symbolize
     env.filters["html2text"] = self._html2text
     self._template = env.get_template("")
     self._include_comments = include_comments
     self._base_class = base_class[base_class.rfind('.') + 1:]
     self._base_module = base_class[:-len(self._base_class) - 1]
     self._counter = 1
开发者ID:vmarkovtsev,项目名称:django-apiblueprint-tests,代码行数:29,代码来源:generator.py

示例3: main

# 需要导入模块: from markdown import Markdown [as 别名]
# 或者: from markdown.Markdown import set_output_format [as 别名]
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-o", "--output", help="Output pickle file path",
                        default=None)
    parser.add_argument("input", help="Input API Blueprint file")
    args = parser.parse_args()
    with codecs.open(args.input, "r", "utf-8") as fin:
        txt = fin.read()
    m = Markdown(extensions=["plueprint"])
    m.set_output_format("apiblueprint")
    api = m.convert(txt)
    if args.output is not None:
        with open(args.output, "wb") as fout:
            pickle.dump(api, fout, protocol=-1)
    else:
        print(api)
        print("Resource groups:")
        for g in api:
            print("  %s" % g)
            print("  Resources:")
            for r in g:
                print("    %s" % r)
                print("    Actions:")
                for a in r:
                    print("      %s" % a)
开发者ID:eduardozamin,项目名称:plueprint,代码行数:27,代码来源:__main__.py

示例4: __init__

# 需要导入模块: from markdown import Markdown [as 别名]
# 或者: from markdown.Markdown import set_output_format [as 别名]
  def __init__(self, api, apib):
    self.api = api

    markdown_parser = Markdown(extensions=['plueprint'])
    markdown_parser.set_output_format('apiblueprint')
    with open(apib, 'r') as f:
      self.api_spec = markdown_parser.convert(f.read())
    self.parser = Parser(self.api_spec)
    self.routes = {
      resource.uri_template.uri: resource
      for resource in self.api_spec.resources
    }
开发者ID:csboling,项目名称:apy_blueprint,代码行数:14,代码来源:apib.py


注:本文中的markdown.Markdown.set_output_format方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。