• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript doctrine.parse函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中doctrine.parse函数的典型用法代码示例。如果您正苦于以下问题:TypeScript parse函数的具体用法?TypeScript parse怎么用?TypeScript parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了parse函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: parseJsdoc

export function parseJsdoc(docs:string):Annotation {
  docs = _removeLeadingAsterisks(docs);
  var d = doctrine.parse(docs, {
    unwrap: false,
    lineNumber: true,
    preserveWhitespace: true
  });
  return {
    description: d.description,
    tags: _tagsToHydroTags(d.tags)
  };
}
开发者ID:1hemant,项目名称:Test00,代码行数:12,代码来源:jsdoc.ts


示例2: parseJsdoc

export function parseJsdoc(docs: string): doctrine.Annotation {
  docs = removeLeadingAsterisks(docs);
  const d = doctrine.parse(docs, {
    unwrap: false,
    // lineNumbers: true,
    preserveWhitespace: true,
  });
  // Strip any leading and trailing newline characters in the
  // description of multiline comments for readibility.
  // TODO(rictic): figure out if we can trim() here or not. Something something
  //     markdown?
  const description = d.description && d.description.replace(/^\n+|\n+$/g, '');
  return {description, tags: parseCustomTags(d.tags)};
}
开发者ID:asdfg9822,项目名称:polymer-analyzer,代码行数:14,代码来源:jsdoc.ts


示例3: test

test('parse all options', (t: test.Test) => {
  let res = d.parse('/* this is a test\n * @param {number} bees the number of bees\n */', {
    unwrap: true,
    tags: null,
    recoverable: true,
    sloppy: true,
    lineNumbers: true
  });
  t.plan(10);
  t.equal(res.description, 'this is a test');
  t.equal(res.tags.length, 1);
  t.equal(res.tags[0].title, 'param');
  t.equal(res.tags[0].name, 'bees');
  t.equal(res.tags[0].description, 'the number of bees');
  t.equal(res.tags[0].type.type, d.Syntax.NameExpression);
  let resType = res.tags[0].type as d.NameExpression;
  t.equal(resType.name, 'number');
  t.equal(res.tags[0].lineNumber, 1);
  t.false(res.tags[0].errors);
  t.false(res.tags[0].caption);
  t.end();
});
开发者ID:kazimuth,项目名称:typed-doctrine,代码行数:22,代码来源:test.ts


示例4: yn

export const extractMetadata = (code: string) => {
  const match = code.match(JSDocCommentRegex)
  const metadata: ActionMetadata = {
    title: '',
    category: '',
    description: '',
    author: '',
    hidden: false,
    params: []
  }

  if (!match) {
    return metadata
  }

  const extracted = doctrine.parse(match[0], {
    recoverable: true,
    sloppy: true,
    unwrap: true,
    strict: false,
    preserveWhitespace: false
  })

  metadata.description = extracted.description

  const author = _.find(extracted.tags, { title: 'author' })
  if (author) {
    metadata.author = (author as any).description || ''
  }

  const category = _.find(extracted.tags, { title: 'category' })
  if (category) {
    metadata.category = (category as any).description || ''
  }

  const title = _.find(extracted.tags, { title: 'title' })
  if (title) {
    metadata.title = (title as any).description || ''
  }

  const hidden = _.find(extracted.tags, { title: 'hidden' })
  if (hidden) {
    metadata.hidden = yn((hidden as any).description)
  }

  metadata.params = _.filter(extracted.tags, { title: 'param' }).map(tag => {
    const type: string = _.get(tag, 'type.name', '')
    const required = _.get(tag, 'type.type') !== doctrine.type.Syntax.OptionalType
    const def = _.get(tag, 'default', '')
    const name = _.get(tag, 'name', '')

    return {
      description: (tag as any).description || '',
      type,
      default: def,
      required,
      name
    }
  })

  return metadata
}
开发者ID:alexsandrocruz,项目名称:botpress,代码行数:62,代码来源:metadata.ts


示例5:

import * as doctrine from 'doctrine';

let string: string = 'string';
let strings: string[];
let tags: doctrine.Tag[] = [];
let annotation: doctrine.Annotation;

annotation = doctrine.parse(string);
string = annotation.description;
tags = annotation.tags;

annotation = doctrine.parse(string, {});
annotation = doctrine.parse(string, {
  unwrap: true,
  tags: ['foo', 'bar', 'baz'],
  recoverable: false,
  sloppy: false,
  strict: true,
  preserveWhitespace: false,
  lineNumbers: true
});

tags.forEach((tag) => {
  string = doctrine.type.stringify({type: 'NullableLiteral'});
  string = tag.title;
  string = tag.description || '';
  string = tag.kind || '';
  string = tag.name || '';
  strings = tag.errors || [];
  if (tag.type && tag.type.type === 'NameExpression') {
    string = tag.type.name;
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:31,代码来源:doctrine-tests.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript doctrine.type类代码示例发布时间:2022-05-25
下一篇:
TypeScript dockerode.listContainers函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap