tnpm install schema2md --save
-
Input
:
{
"title": "foo.config.js",
"description": "My Config File",
"properties": {
"type": {
"description": "TYPE's description",
"type": "string",
"enum": [
"foo",
"bar"
]
},
"env": {
"description": "ENV's description",
"type": "string"
}
}
}
-
Output
:
# foo.config.js
My Config File
## type
- Type: `"foo" | "bar"`
- Description: TYPE's description
## env
- Type: `string`
- Description: ENV's description"
const { transform } = require('schema2md')
transform({
schemaPath: 'fixtures/simple.json',
outputPath: 'docs/config/README.md',
})
- Type:
(options: ITransformOptions) => Promise<string>
- Description:
Get markdown output by JSON Schema.
Type of ITransformOptions
is as follows:
interface ITransformOptions {
/**
* Current working directory, used to calcaulate absolute path for "schemaPath"
* and "outputPath" with relative path, defaults to `process.cwd()`.
*/
cwd?: string;
/**
* A relative path or an absolute path to a JSON Schema file.
*/
schemaPath: string;
/**
* A relative path or an absolute path to a output markdown file.
*/
outputPath: string;
/**
* Whether to write output content to "outputPath".
*/
write: boolean;
/**
* Current locale.
*/
locale: string;
/**
* Specify a markdown file to be merged into the generated markdown.
*/
schemaMarkdown: string;
/**
* Frontmatter content.
*/
frontmatter: string;
/**
* Content at the below of h1.
*/
heading: string;
}
- Type:
(options: IBatchTransformOptions) => Promise<string[]>
- Description:
Get markdown output by JSON Schema.
Type of IBatchTransformOptions
is as follows:
interface IBatchTransformOptions {
/**
* Global "cwd".
*/
cwd: string;
/**
* Global "cwd".
*/
locale: string;
/**
* Global "write".
*/
write: string;
/**
* Meta transform config.
*/
configs: ITransformOptions[];
}
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
schema2md © ULIVZ, Released under the MIT License.
github.com/ulivz · GitHub @ULIVZ · Twitter @_ulivz