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

cloudflare/JSON.is: Open-source documentation for common JSON formats.

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

开源软件名称:

cloudflare/JSON.is

开源软件地址:

https://github.com/cloudflare/JSON.is

开源编程语言:

JavaScript 69.8%

开源软件介绍:

JSON.is

Open-source documentation for common JSON formats.

Currently included:

Contributing

We welcome contributors of both improvements and additional JSON formats.

Format

Format definition files are located in coffee/formats.

The definitions are CoffeeScript source files. Each file exports an object mapping regular expressions to HTML descriptions. The regular expressions are tested against the path to the object the user currently has his or her cursor over. The first complete match determines what documentation block is shown.

For example, to add a doc for {"engines": ...}, you would specify:

'engines': '''
  <h4>Engines</h4>
'''

Any character with special meaning in regular expressions (like [ and .) should be escaped with a backslash:

'engines\.node': '''
  <h4>Node Version</h4>
'''

There are two 'shortcuts' which are available, INDEX and PROPERTY.

  • INDEX (\d+) matches any index within an array
  • PROPERTY ([^\.]+) matches any key within an object

For example, to write a doc for any property within engines:

'engines\.PROPERTY': '''
  <h4>Engines</h4>
'''

You can use regular expression syntax to create a section which will match both the parent, and it's children:

'engines(\.PROPERTY)?': '''
  <h4>Engines</h4>
'''

When dealing with an array, you can do a similar thing with INDEX:

'keywords\.INDEX': '''
  <h4>Keyword</h4>
'''

You can use the pipe regular expression syntax to match multiple options:

'(dependencies|devDependencies)': '''
  <h4>Dependencies</h4>
'''

As each file is CoffeeScript, you can add arbitrary code:

'description': '''
  <h4>Description</h4>
''' + new Date

Each doc body can also be a function, which will be passed the item which was matched:

'(dependencies|devDependencies)': (item) ->
  "<h4>#{ item.path }</h4>"

HTML Conventions

  • Begin each doc with a title in an h4.
  • Wrap each paragraph in a p.
  • Docs can optionally begin with a subtitle wrapped like <p><em>Subtitle</em></p>
  • Inline code blocks should be wrapped with a code element
  • Block code blocks should be wrapped like <pre><code>my code</code></pre>



鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
grisha/json2avro: Fast JSON to Avro converter发布时间:2022-07-09
下一篇:
jsonresume/resume-cli: CLI tool to easily setup a new resume 发布时间:2022-07-09
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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