https://github.com/richytong/cronist
Transform comment documentation into ES modules
https://github.com/richytong/cronist
comment documentation json markdown parser
Last synced: 10 months ago
JSON representation
Transform comment documentation into ES modules
- Host: GitHub
- URL: https://github.com/richytong/cronist
- Owner: richytong
- License: mit
- Created: 2020-09-17T19:30:09.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2023-06-12T05:47:12.000Z (about 3 years ago)
- Last Synced: 2025-02-26T10:54:55.207Z (over 1 year ago)
- Topics: comment, documentation, json, markdown, parser
- Language: JavaScript
- Homepage:
- Size: 27.3 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cronist

Transform comment documentation into [JSON](https://www.json.org/json-en.html) or [ES modules](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules).
# Usage
Write comment documentation following a basic `@key #valid-markdown` schema.
```javascript
/**
* @name tap
*
* @synopsis
* ```coffeescript [specscript]
* var args ...any,
* tapper ...args=>Promise|any
*
* tap(tapper)(...args) -> Promise|args[0]
* ```
*
* @description
* Call a function with a value, returning the value. Promises created by the tapper are resolved before returning the value.
*
* ```javascript [playground]
* pipe([
* tap(console.log),
* value => value + 'bar',
* tap(console.log),
* ])('foo') // 'foo'
* // 'foobar'
* ```
*/
const tap = ...
```
Use cronist to parse the file containing the above comment documentation into ES modules.
```sh
$ cronist file-that-had-the-above-tap.js
export default [
{
name: 'tap',
synopsis: '```coffeescript [specscript]\n' +
'var args ...any,\n' +
' tapper ...args=>Promise|any\n' +
'\n' +
'tap(tapper)(...args) -> Promise|args[0]\n' +
'```',
description: 'Call a function with a value, returning the value. Promises created by the tapper are resolved before returning the value.\n' +
'\n' +
'```javascript [playground]\n' +
'pipe([\n' +
' tap(console.log),\n' +
" value => value + 'bar',\n" +
' tap(console.log),\n' +
"])('foo') // 'foo'\n" +
" // 'foobar'\n" +
'```',
mdast: {
name: {/* ... */},
synopsis: {/* ... */},
description: {/* ... */}
}
},
...
]
```
# Installation
with `npm`
```sh
npm i cronist
```