@adobe/jsonschema2md 6.1.4 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{.eslintrc.js → .eslintrc.cjs} +3 -17
- package/{.releaserc.js → .releaserc.cjs} +0 -0
- package/CHANGELOG.md +41 -0
- package/README.md +1 -1
- package/cli.js +1 -1
- package/lib/formatInfo.js +17 -19
- package/lib/formattingTools.js +6 -8
- package/lib/index.js +176 -81
- package/lib/keywords.js +2 -4
- package/lib/locales/nl-NL.json +182 -0
- package/lib/locales/update.js +2 -2
- package/lib/markdownBuilder.js +62 -44
- package/lib/readmeBuilder.js +15 -15
- package/lib/schemaProxy.js +32 -26
- package/lib/symbols.js +14 -2
- package/lib/traverseSchema.js +5 -5
- package/lib/writeMarkdown.js +87 -41
- package/lib/writeSchema.js +46 -21
- package/package.json +41 -30
- package/types/api.d.ts +72 -0
- package/types/formatInfo.d.ts +19 -0
- package/types/formattingTools.d.ts +2 -0
- package/types/index.d.ts +75 -0
- package/types/keywords.d.ts +2 -0
- package/types/markdownBuilder.d.ts +8 -0
- package/types/readmeBuilder.d.ts +5 -0
- package/types/schemaProxy.d.ts +1 -0
- package/types/symbols.d.ts +11 -0
- package/types/traverseSchema.d.ts +6 -0
- package/types/writeMarkdown.d.ts +56 -0
- package/types/writeSchema.d.ts +19 -0
- package/.circleci/config.yml +0 -83
- package/.github/ISSUE_TEMPLATE/bug_report.md +0 -23
- package/.github/workflows/semantic-release.yaml +0 -55
- package/.github/workflows/semver-check.yaml +0 -16
- package/.renovaterc.json +0 -3
- package/.tidelift.yml +0 -32
- package/crowdin.yml +0 -4
- package/examples/abstract.md +0 -3
- package/examples/docs/README.md +0 -121
- package/examples/docs/abstract-definitions-first-properties-foo.md +0 -15
- package/examples/docs/abstract-definitions-first-properties-nonfoo.md +0 -23
- package/examples/docs/abstract-definitions-first.md +0 -66
- package/examples/docs/abstract-definitions-second-properties-bar.md +0 -15
- package/examples/docs/abstract-definitions-second.md +0 -39
- package/examples/docs/abstract-definitions.md +0 -15
- package/examples/docs/abstract.md +0 -104
- package/examples/docs/arrays-properties-boollist-items.md +0 -15
- package/examples/docs/arrays-properties-boollist.md +0 -19
- package/examples/docs/arrays-properties-coordinatelist-items-items.md +0 -21
- package/examples/docs/arrays-properties-coordinatelist-items.md +0 -21
- package/examples/docs/arrays-properties-coordinatelist.md +0 -19
- package/examples/docs/arrays-properties-intlist-items.md +0 -15
- package/examples/docs/arrays-properties-intlist.md +0 -21
- package/examples/docs/arrays-properties-jointypelist-items-oneof-0-properties-foo.md +0 -21
- package/examples/docs/arrays-properties-jointypelist-items-oneof-0.md +0 -45
- package/examples/docs/arrays-properties-jointypelist-items-oneof-1-properties-bar.md +0 -21
- package/examples/docs/arrays-properties-jointypelist-items-oneof-1.md +0 -45
- package/examples/docs/arrays-properties-jointypelist-items.md +0 -21
- package/examples/docs/arrays-properties-jointypelist.md +0 -15
- package/examples/docs/arrays-properties-list-items.md +0 -15
- package/examples/docs/arrays-properties-list.md +0 -15
- package/examples/docs/arrays-properties-listlist-items.md +0 -15
- package/examples/docs/arrays-properties-listlist.md +0 -15
- package/examples/docs/arrays-properties-numlist-items.md +0 -19
- package/examples/docs/arrays-properties-numlist.md +0 -19
- package/examples/docs/arrays-properties-objectlist-items-properties-a.md +0 -15
- package/examples/docs/arrays-properties-objectlist-items-properties-b.md +0 -15
- package/examples/docs/arrays-properties-objectlist-items.md +0 -58
- package/examples/docs/arrays-properties-objectlist.md +0 -15
- package/examples/docs/arrays-properties-stringlistlist-items-items.md +0 -15
- package/examples/docs/arrays-properties-stringlistlist-items.md +0 -15
- package/examples/docs/arrays-properties-stringlistlist.md +0 -15
- package/examples/docs/arrays-properties-tuple-items-negative-integer.md +0 -19
- package/examples/docs/arrays-properties-tuple-items-positive-integer.md +0 -19
- package/examples/docs/arrays-properties-tuple-zero.md +0 -23
- package/examples/docs/arrays-properties-tuple.md +0 -21
- package/examples/docs/arrays.md +0 -240
- package/examples/docs/complex-additionalproperties.md +0 -15
- package/examples/docs/complex-patternproperties-int.md +0 -15
- package/examples/docs/complex-patternproperties-str.md +0 -15
- package/examples/docs/complex-patternproperties.md +0 -15
- package/examples/docs/complex-properties-and-allof-0.md +0 -19
- package/examples/docs/complex-properties-and-allof-1.md +0 -19
- package/examples/docs/complex-properties-and.md +0 -21
- package/examples/docs/complex-properties-or-anyof-0.md +0 -15
- package/examples/docs/complex-properties-or-anyof-1.md +0 -19
- package/examples/docs/complex-properties-or.md +0 -21
- package/examples/docs/complex-properties-reflocalfiledef.md +0 -39
- package/examples/docs/complex-properties-refnestedobj-properties-refobj.md +0 -39
- package/examples/docs/complex-properties-refnestedobj.md +0 -39
- package/examples/docs/complex-properties-refobj.md +0 -39
- package/examples/docs/complex-properties-xor-oneof-0.md +0 -19
- package/examples/docs/complex-properties-xor-oneof-1.md +0 -19
- package/examples/docs/complex-properties-xor.md +0 -21
- package/examples/docs/complex.md +0 -285
- package/examples/docs/constants-properties-hello.md +0 -23
- package/examples/docs/constants.md +0 -47
- package/examples/docs/custom-allof-0.md +0 -15
- package/examples/docs/custom-allof-1.md +0 -39
- package/examples/docs/custom-allof-2.md +0 -39
- package/examples/docs/custom-definitions-first-properties-foo.md +0 -15
- package/examples/docs/custom-definitions-first-properties.md +0 -15
- package/examples/docs/custom-definitions-first.md +0 -39
- package/examples/docs/custom-definitions-second-properties-bar.md +0 -15
- package/examples/docs/custom-definitions-second-properties.md +0 -15
- package/examples/docs/custom-definitions-second.md +0 -39
- package/examples/docs/custom-definitions.md +0 -15
- package/examples/docs/custom.md +0 -85
- package/examples/docs/deepextending-allof-0.md +0 -49
- package/examples/docs/deepextending-allof-1.md +0 -89
- package/examples/docs/deepextending-allof-3.md +0 -39
- package/examples/docs/deepextending-definitions-fourth-properties-hey.md +0 -15
- package/examples/docs/deepextending-definitions-fourth-properties.md +0 -15
- package/examples/docs/deepextending-definitions-fourth.md +0 -39
- package/examples/docs/deepextending-definitions.md +0 -15
- package/examples/docs/deepextending.md +0 -57
- package/examples/docs/definitions-definitions-myid-properties-id-1.md +0 -19
- package/examples/docs/definitions-definitions-myid-properties-id.md +0 -19
- package/examples/docs/definitions-definitions-myid-properties-metaid.md +0 -19
- package/examples/docs/definitions-definitions-myid-properties.md +0 -15
- package/examples/docs/definitions-definitions-myid.md +0 -89
- package/examples/docs/definitions-definitions.md +0 -15
- package/examples/docs/definitions.md +0 -117
- package/examples/docs/enums-properties-enumerated-nested-properties-test.md +0 -25
- package/examples/docs/enums-properties-enumerated-nested.md +0 -49
- package/examples/docs/enums-properties-hello.md +0 -24
- package/examples/docs/enums.md +0 -67
- package/examples/docs/example-properties-bar.md +0 -25
- package/examples/docs/example-properties-foo.md +0 -21
- package/examples/docs/example.md +0 -83
- package/examples/docs/examples-properties-bar.md +0 -25
- package/examples/docs/examples-properties-foo.md +0 -21
- package/examples/docs/examples.md +0 -90
- package/examples/docs/extending-definitions-third-properties-baaaz.md +0 -21
- package/examples/docs/extending-definitions-third.md +0 -45
- package/examples/docs/extending-definitions.md +0 -15
- package/examples/docs/extending.md +0 -61
- package/examples/docs/extensible-definitions-first-properties-foo.md +0 -21
- package/examples/docs/extensible-definitions-first-properties.md +0 -15
- package/examples/docs/extensible-definitions-first.md +0 -45
- package/examples/docs/extensible-definitions-second-properties-bar.md +0 -25
- package/examples/docs/extensible-definitions-second-properties.md +0 -15
- package/examples/docs/extensible-definitions-second.md +0 -49
- package/examples/docs/extensible-definitions.md +0 -15
- package/examples/docs/extensible.md +0 -93
- package/examples/docs/identifiable-properties-id.md +0 -19
- package/examples/docs/identifiable.md +0 -43
- package/examples/docs/join-oneof-0-not-oneof-0-properties-foo.md +0 -21
- package/examples/docs/join-oneof-0-not-oneof-0.md +0 -45
- package/examples/docs/join-oneof-0-not-oneof-1-properties-bar.md +0 -21
- package/examples/docs/join-oneof-0-not-oneof-1.md +0 -45
- package/examples/docs/join-oneof-0-not.md +0 -21
- package/examples/docs/join-oneof-0.md +0 -23
- package/examples/docs/join-oneof-1-allof-0-properties-foo.md +0 -21
- package/examples/docs/join-oneof-1-allof-0.md +0 -45
- package/examples/docs/join-oneof-1.md +0 -19
- package/examples/docs/join-oneof-2-anyof-0-properties-bar.md +0 -21
- package/examples/docs/join-oneof-2-anyof-0.md +0 -45
- package/examples/docs/join-oneof-2.md +0 -19
- package/examples/docs/join.md +0 -33
- package/examples/docs/nestedobj-properties-settings-properties-collaborators-patternproperties-.md +0 -15
- package/examples/docs/nestedobj-properties-settings-properties-collaborators-patternproperties.md +0 -15
- package/examples/docs/nestedobj-properties-settings-properties-collaborators-properties-id.md +0 -15
- package/examples/docs/nestedobj-properties-settings-properties-collaborators.md +0 -58
- package/examples/docs/nestedobj-properties-settings.md +0 -39
- package/examples/docs/nestedobj.md +0 -39
- package/examples/docs/pattern-patternproperties-0-9.md +0 -21
- package/examples/docs/pattern-patternproperties.md +0 -15
- package/examples/docs/pattern.md +0 -45
- package/examples/docs/simple-properties-id.md +0 -19
- package/examples/docs/simple.md +0 -43
- package/examples/docs/simpletypes-properties-integer_threes.md +0 -23
- package/examples/docs/simpletypes-properties-interger_constrained.md +0 -19
- package/examples/docs/simpletypes-properties-interger_unconstrained.md +0 -15
- package/examples/docs/simpletypes-properties-number_constrained.md +0 -19
- package/examples/docs/simpletypes-properties-number_unconstrained.md +0 -15
- package/examples/docs/simpletypes-properties-string_date.md +0 -19
- package/examples/docs/simpletypes-properties-string_email.md +0 -19
- package/examples/docs/simpletypes-properties-string_hostname.md +0 -19
- package/examples/docs/simpletypes-properties-string_ipv4.md +0 -19
- package/examples/docs/simpletypes-properties-string_ipv6.md +0 -19
- package/examples/docs/simpletypes-properties-string_length.md +0 -31
- package/examples/docs/simpletypes-properties-string_pattern-metaenum.md +0 -15
- package/examples/docs/simpletypes-properties-string_pattern.md +0 -39
- package/examples/docs/simpletypes-properties-string_pattern_noexample.md +0 -25
- package/examples/docs/simpletypes-properties-string_pattern_singleexample.md +0 -31
- package/examples/docs/simpletypes-properties-string_unconstrained.md +0 -21
- package/examples/docs/simpletypes-properties-string_uri.md +0 -19
- package/examples/docs/simpletypes-properties-yesno.md +0 -15
- package/examples/docs/simpletypes.md +0 -455
- package/examples/docs/stabilizing-properties-id.md +0 -19
- package/examples/docs/stabilizing.md +0 -43
- package/examples/docs/subdir-allof-0.md +0 -43
- package/examples/docs/subdir-definitions-content-properties-id.md +0 -19
- package/examples/docs/subdir-definitions-content-properties.md +0 -15
- package/examples/docs/subdir-definitions-content.md +0 -43
- package/examples/docs/subdir-definitions.md +0 -15
- package/examples/docs/subdir.md +0 -55
- package/examples/docs/typearrays-properties-null.md +0 -15
- package/examples/docs/typearrays-properties-string-or-null.md +0 -15
- package/examples/docs/typearrays-properties-string-or-number-null.md +0 -15
- package/examples/docs/typearrays-properties-string-or-number.md +0 -15
- package/examples/docs/typearrays.md +0 -96
- package/examples/docsWithoutHeader/arrays.schema.md +0 -254
- package/examples/generated-schemas/abstract.schema.json +0 -1
- package/examples/generated-schemas/arrays.schema.json +0 -1
- package/examples/generated-schemas/complex.schema.json +0 -1
- package/examples/generated-schemas/constants.schema.json +0 -1
- package/examples/generated-schemas/custom.schema.json +0 -1
- package/examples/generated-schemas/deepextending.schema.json +0 -1
- package/examples/generated-schemas/definitions.schema.json +0 -1
- package/examples/generated-schemas/enums.schema.json +0 -1
- package/examples/generated-schemas/example.schema.json +0 -1
- package/examples/generated-schemas/examples.schema.json +0 -1
- package/examples/generated-schemas/extending.schema.json +0 -1
- package/examples/generated-schemas/extensible.schema.json +0 -1
- package/examples/generated-schemas/identifiable.schema.json +0 -1
- package/examples/generated-schemas/join.schema.json +0 -1
- package/examples/generated-schemas/nestedobj.schema.json +0 -1
- package/examples/generated-schemas/pattern.schema.json +0 -1
- package/examples/generated-schemas/simple.schema.json +0 -1
- package/examples/generated-schemas/simpletypes.schema.json +0 -1
- package/examples/generated-schemas/stabilizing.schema.json +0 -1
- package/examples/generated-schemas/subdir/subdir.schema.json +0 -1
- package/examples/generated-schemas/typearrays.schema.json +0 -1
- package/examples/schemas/abstract.schema.json +0 -44
- package/examples/schemas/arrays.schema.json +0 -185
- package/examples/schemas/complex.schema.json +0 -123
- package/examples/schemas/constants.schema.json +0 -25
- package/examples/schemas/custom.schema.json +0 -41
- package/examples/schemas/deepextending.schema.json +0 -37
- package/examples/schemas/definitions.description.md +0 -17
- package/examples/schemas/definitions.schema.json +0 -46
- package/examples/schemas/enums.schema.json +0 -42
- package/examples/schemas/example.example.1.json +0 -4
- package/examples/schemas/example.schema.json +0 -29
- package/examples/schemas/examples.example.1.json +0 -4
- package/examples/schemas/examples.example.2.json +0 -4
- package/examples/schemas/examples.schema.json +0 -32
- package/examples/schemas/extending.schema.json +0 -38
- package/examples/schemas/extensible.schema.json +0 -38
- package/examples/schemas/identifiable.schema.json +0 -22
- package/examples/schemas/join.schema.json +0 -88
- package/examples/schemas/nestedobj.schema.json +0 -35
- package/examples/schemas/pattern.schema.json +0 -21
- package/examples/schemas/simple.schema.json +0 -22
- package/examples/schemas/simpletypes.schema.json +0 -151
- package/examples/schemas/stabilizing.schema.json +0 -23
- package/examples/schemas/subdir/subdir.schema.json +0 -29
- package/examples/schemas/typearrays.schema.json +0 -39
- package/examples/status.md +0 -3
- package/test/api.test.js +0 -55
- package/test/cyclicSchemaIntegration.test.js +0 -87
- package/test/fixtures/additionalprops/additionalprops.schema.json +0 -6
- package/test/fixtures/additionalprops/arrays.schema.json +0 -9
- package/test/fixtures/arrays/arrays.schema.json +0 -201
- package/test/fixtures/arrays/tuple.schema.json +0 -35
- package/test/fixtures/content/html.schema.json +0 -5
- package/test/fixtures/content/jwt.schema.json +0 -26
- package/test/fixtures/content/png.schema.json +0 -6
- package/test/fixtures/cyclic/one.description.md +0 -1
- package/test/fixtures/cyclic/one.example.1.json +0 -1
- package/test/fixtures/cyclic/one.schema.json +0 -17
- package/test/fixtures/cyclic/three.schema.json +0 -17
- package/test/fixtures/cyclic/two.schema.json +0 -17
- package/test/fixtures/deadref/deadref.schema.json +0 -6
- package/test/fixtures/enums/arrayenums.schema.json +0 -29
- package/test/fixtures/enums/enums.schema.json +0 -29
- package/test/fixtures/example/example.schema.json +0 -52
- package/test/fixtures/format/format.schema.json +0 -25
- package/test/fixtures/identifiable/identifiable.schema.json +0 -22
- package/test/fixtures/not/not.schema.json +0 -7
- package/test/fixtures/null/null.schema.json +0 -14
- package/test/fixtures/nullable/array.schema.json +0 -17
- package/test/fixtures/readme-1/abstract.schema.json +0 -50
- package/test/fixtures/readme-1/complex.schema.json +0 -118
- package/test/fixtures/readme-1/simple.schema.json +0 -30
- package/test/fixtures/skipproperties/complete.schema.json +0 -29
- package/test/fixtures/stringformats/simpletypes.schema.json +0 -211
- package/test/fixtures/title/meta.schema.json +0 -53
- package/test/fixtures/type/button.schema.json +0 -28
- package/test/fixtures/type/type.schema.json +0 -20
- package/test/fixtures/types/merged.schema.json +0 -10
- package/test/fixtures/types/object.schema.json +0 -3
- package/test/fixtures/types/objectorarray.schema.json +0 -3
- package/test/fixtures/types/undefined.schema.json +0 -3
- package/test/fixtures/types/wrong.schema.json +0 -6
- package/test/formatting.test.js +0 -59
- package/test/markdownBuilder.test.js +0 -441
- package/test/readmeBuilder.test.js +0 -106
- package/test/schemaProxy.test.js +0 -187
- package/test/testUtils.js +0 -88
- package/test/testintegration.test.js +0 -65
- package/test/traverseSchema.test.js +0 -111
- package/test/zSchemaCoverage.test.js +0 -186
package/lib/writeMarkdown.js
CHANGED
|
@@ -9,77 +9,123 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
import { each, pairs } from 'ferrum';
|
|
13
|
+
import stringify from 'remark-stringify';
|
|
14
|
+
import { unified } from 'unified';
|
|
15
|
+
import gfm from 'remark-gfm';
|
|
16
|
+
import path from 'path';
|
|
17
|
+
import fs from 'fs-extra';
|
|
18
|
+
import yaml from 'js-yaml';
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {import("../types/api").MarkdownAst} MarkdownAst
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* @typedef {import("../types/api").MarkdownContent} MarkdownContent
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* @typedef {import("../types/api").ReadmeContent} ReadmeContent
|
|
28
|
+
*/
|
|
29
|
+
/**
|
|
30
|
+
* @typedef {{ [name: string]: MarkdownAst }} MarkdownAstFiles
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Write the Markdown to filesystem or an object
|
|
35
|
+
* @param {Object} options
|
|
36
|
+
* @param {string} [options.out] - (optional) Directory where the files will be saved
|
|
37
|
+
* @param {Function} [options.error] - (optional) Error logger
|
|
38
|
+
* @param {Function} [options.info] - (optional) Info logger
|
|
39
|
+
* @param {Function} [options.debug] - (optional) Debug logger
|
|
40
|
+
* @param {{ [key: string]: string }} [options.meta] - (optional) Metadata to be added to Markdown
|
|
41
|
+
* @returns {(astFiles: MarkdownAstFiles) => MarkdownContent[]}
|
|
42
|
+
*/
|
|
43
|
+
export function writemarkdown({
|
|
21
44
|
out, error, meta,
|
|
22
45
|
}) {
|
|
23
46
|
const processor = unified()
|
|
24
47
|
.use(gfm)
|
|
25
48
|
.use(stringify);
|
|
26
49
|
|
|
27
|
-
fs.mkdirpSync(out);
|
|
28
|
-
|
|
29
50
|
return (schemas) => {
|
|
30
|
-
|
|
31
|
-
|
|
51
|
+
/** @type {MarkdownContent[]} */
|
|
52
|
+
const output = [];
|
|
53
|
+
each(pairs(schemas), (tuple) => {
|
|
54
|
+
/** @type {[ string, MarkdownAst ]} */
|
|
55
|
+
const [name, markdownAst] = tuple;
|
|
32
56
|
|
|
33
57
|
// add YAML frontmatter
|
|
34
|
-
const
|
|
58
|
+
const content = (!meta ? '' : '---\n')
|
|
35
59
|
+ (!meta ? '' : yaml.dump(meta))
|
|
36
60
|
+ (!meta ? '' : '---\n\n')
|
|
37
61
|
|
|
38
|
-
+ processor.stringify(
|
|
62
|
+
+ processor.stringify(markdownAst);
|
|
39
63
|
|
|
40
|
-
|
|
41
|
-
|
|
64
|
+
const fileName = `${name}.md`;
|
|
65
|
+
let fullPath;
|
|
66
|
+
if (out) {
|
|
67
|
+
fullPath = path.resolve(out, fileName);
|
|
68
|
+
try {
|
|
69
|
+
fs.outputFileSync(fullPath, content);
|
|
70
|
+
} catch (err) {
|
|
42
71
|
error(err);
|
|
43
72
|
}
|
|
44
73
|
// info(`${fileName} created`);
|
|
74
|
+
}
|
|
75
|
+
output.push({
|
|
76
|
+
fileName,
|
|
77
|
+
fullPath,
|
|
78
|
+
markdownAst,
|
|
79
|
+
content,
|
|
45
80
|
});
|
|
46
81
|
});
|
|
47
82
|
|
|
48
|
-
return
|
|
83
|
+
return output;
|
|
49
84
|
};
|
|
50
85
|
}
|
|
51
86
|
|
|
52
|
-
|
|
53
|
-
|
|
87
|
+
/**
|
|
88
|
+
* Write the Readme Markdown to filesystem or an object
|
|
89
|
+
* @param {Object} options
|
|
90
|
+
* @param {string} [options.out] - (optional) Directory where the files will be saved
|
|
91
|
+
* @param {Function} [options.error] - (optional) Error logger
|
|
92
|
+
* @param {Function} [options.info] - (optional) Info logger
|
|
93
|
+
* @param {Function} [options.debug] - (optional) Debug logger
|
|
94
|
+
* @param {{ [key: string]: string }} [options.meta] - (optional) Metadata to be added to Markdown
|
|
95
|
+
* @returns {(markdownAst: MarkdownAst) => ReadmeContent}
|
|
96
|
+
*/
|
|
97
|
+
export function writereadme({
|
|
98
|
+
out, error, info, meta,
|
|
54
99
|
}) {
|
|
55
100
|
const processor = unified()
|
|
56
101
|
.use(gfm)
|
|
57
102
|
.use(stringify);
|
|
58
103
|
|
|
59
|
-
|
|
60
|
-
|
|
104
|
+
return (markdownAst) => {
|
|
105
|
+
// add YAML frontmatter
|
|
106
|
+
const content = (!meta ? '' : '---\n')
|
|
107
|
+
+ (!meta ? '' : yaml.dump(meta))
|
|
108
|
+
+ (!meta ? '' : '---\n\n')
|
|
61
109
|
|
|
62
|
-
|
|
63
|
-
const fileName = path.resolve(out, 'README.md');
|
|
64
|
-
// add YAML frontmatter
|
|
65
|
-
const output = (!meta ? '' : '---\n')
|
|
66
|
-
+ (!meta ? '' : yaml.dump(meta))
|
|
67
|
-
+ (!meta ? '' : '---\n\n')
|
|
110
|
+
+ processor.stringify(markdownAst);
|
|
68
111
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
112
|
+
const fileName = 'README.md';
|
|
113
|
+
let fullPath;
|
|
114
|
+
if (out) {
|
|
115
|
+
fullPath = path.resolve(out, fileName);
|
|
116
|
+
try {
|
|
117
|
+
fs.outputFileSync(fullPath, content);
|
|
118
|
+
} catch (err) {
|
|
119
|
+
error(err);
|
|
120
|
+
}
|
|
121
|
+
info(`${fileName} created`);
|
|
122
|
+
}
|
|
77
123
|
|
|
78
|
-
|
|
124
|
+
return {
|
|
125
|
+
fileName,
|
|
126
|
+
fullPath,
|
|
127
|
+
markdownAst,
|
|
128
|
+
content,
|
|
79
129
|
};
|
|
80
|
-
}
|
|
81
|
-
return (args) => args;
|
|
82
|
-
}
|
|
130
|
+
};
|
|
83
131
|
}
|
|
84
|
-
|
|
85
|
-
module.exports = { writemarkdown, writereadme };
|
package/lib/writeSchema.js
CHANGED
|
@@ -9,35 +9,60 @@
|
|
|
9
9
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
import fs from 'fs-extra';
|
|
13
|
+
import path from 'path';
|
|
14
|
+
import s from './symbols.js';
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
/**
|
|
17
|
+
* @typedef {import("../types/api").ExtendedJsonSchema} ExtendedJsonSchema
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* @typedef {import("../types/api").SchemaContent} SchemaContent
|
|
21
|
+
*/
|
|
18
22
|
|
|
23
|
+
/**
|
|
24
|
+
* Write the JSON Schemas to filesystem or an object
|
|
25
|
+
* @param {Object} options
|
|
26
|
+
* @param {string} [options.schemadir] - (optional) Directory where the files will be saved
|
|
27
|
+
* @param {string} [options.origindir] - (optional) Directory where the files were loaded from
|
|
28
|
+
* @returns {(schemas: ExtendedJsonSchema[]) => SchemaContent[]}
|
|
29
|
+
*/
|
|
30
|
+
export default function writeSchema({ schemadir, origindir }) {
|
|
19
31
|
return (schemas) => {
|
|
20
|
-
|
|
32
|
+
// eslint-disable-next-line no-console
|
|
33
|
+
console.log('preparing schemas');
|
|
21
34
|
|
|
22
35
|
const realschemas = Object.values(schemas).filter((schema) => !schema[s.parent]);
|
|
23
|
-
realschemas.
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
36
|
+
return realschemas.map((schema) => {
|
|
37
|
+
const fileName = schema[s.filename];
|
|
38
|
+
const inputPath = schema[s.fullpath] || (origindir && path.join(origindir, fileName));
|
|
39
|
+
let content = schema;
|
|
27
40
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
41
|
+
if (inputPath) {
|
|
42
|
+
content = fs.readJsonSync(inputPath);
|
|
43
|
+
if (schema[s.meta] && schema[s.meta].description) {
|
|
44
|
+
// copy description from external file
|
|
45
|
+
content.description = schema[s.meta].description;
|
|
46
|
+
}
|
|
47
|
+
if (schema.examples && Array.isArray(schema.examples) && schema.examples.length > 0) {
|
|
48
|
+
// copy examples from external files
|
|
49
|
+
content.examples = [...schema.examples];
|
|
50
|
+
}
|
|
32
51
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
52
|
+
|
|
53
|
+
let fullPath;
|
|
54
|
+
if (schemadir) {
|
|
55
|
+
// eslint-disable-next-line no-console
|
|
56
|
+
console.log('writing schemas to', schemadir);
|
|
57
|
+
fullPath = path.resolve(schemadir, fileName);
|
|
58
|
+
fs.outputJsonSync(fullPath, content);
|
|
36
59
|
}
|
|
37
|
-
|
|
38
|
-
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
fileName,
|
|
63
|
+
fullPath,
|
|
64
|
+
content,
|
|
65
|
+
};
|
|
39
66
|
});
|
|
40
67
|
};
|
|
41
68
|
}
|
|
42
|
-
|
|
43
|
-
module.exports = { writeSchema };
|
package/package.json
CHANGED
|
@@ -1,62 +1,73 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/jsonschema2md",
|
|
3
3
|
"description": "Validate and document complex JSON Schemas the easy way.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "7.1.0",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
|
+
"typings": "types",
|
|
6
7
|
"bin": {
|
|
7
8
|
"jsonschema2md": "./cli.js"
|
|
8
9
|
},
|
|
10
|
+
"type": "module",
|
|
9
11
|
"scripts": {
|
|
10
|
-
"semantic-release": "semantic-release",
|
|
12
|
+
"semantic-release": "npm run emit-types && npx semantic-release",
|
|
11
13
|
"commit": "git-cz",
|
|
12
14
|
"lint": "eslint .",
|
|
13
15
|
"lint-fix": "eslint . --fix",
|
|
14
16
|
"start": "node cli.js",
|
|
15
17
|
"examples": "node cli.js -d examples/schemas/ -o examples/docs/ -x examples/generated-schemas/",
|
|
16
|
-
"test": "
|
|
17
|
-
"test-ci": "
|
|
18
|
+
"test": " c8 --reporter=text --reporter=lcov --check-coverage --branches 80 --statements 95 --lines 95 mocha && node lib/locales/update.js",
|
|
19
|
+
"test-ci": "c8 --reporter=text --reporter=lcov --check-coverage --branches 80 --statements 95 --lines 95 mocha --reporter xunit --reporter-options output=./junit/test-results.xml; codecov",
|
|
20
|
+
"emit-types": "npx -p typescript tsc",
|
|
21
|
+
"prepare": "husky install"
|
|
18
22
|
},
|
|
19
23
|
"dependencies": {
|
|
20
|
-
"@adobe/helix-log": "
|
|
24
|
+
"@adobe/helix-log": "6.0.0",
|
|
25
|
+
"@types/json-schema": "^7.0.8",
|
|
26
|
+
"@types/mdast": "^3.0.4",
|
|
21
27
|
"es2015-i18n-tag": "1.6.1",
|
|
22
|
-
"ferrum": "1.9.
|
|
23
|
-
"fs-extra": "10.
|
|
28
|
+
"ferrum": "1.9.4",
|
|
29
|
+
"fs-extra": "10.1.0",
|
|
24
30
|
"github-slugger": "1.4.0",
|
|
25
31
|
"js-yaml": "4.1.0",
|
|
32
|
+
"json-schema": "^0.4.0",
|
|
26
33
|
"mdast-builder": "1.1.1",
|
|
27
|
-
"mdast-util-to-string": "
|
|
34
|
+
"mdast-util-to-string": "3.1.0",
|
|
28
35
|
"readdirp": "3.6.0",
|
|
29
|
-
"remark-gfm": "^
|
|
30
|
-
"remark-parse": "
|
|
31
|
-
"remark-stringify": "
|
|
32
|
-
"unified": "
|
|
33
|
-
"unist-util-inspect": "
|
|
34
|
-
"yargs": "17.
|
|
36
|
+
"remark-gfm": "^3.0.0",
|
|
37
|
+
"remark-parse": "10.0.1",
|
|
38
|
+
"remark-stringify": "10.0.2",
|
|
39
|
+
"unified": "10.1.2",
|
|
40
|
+
"unist-util-inspect": "7.0.0",
|
|
41
|
+
"yargs": "17.5.0"
|
|
35
42
|
},
|
|
36
43
|
"devDependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"@semantic-release/
|
|
39
|
-
"@semantic-release/
|
|
44
|
+
"@adobe/eslint-config-helix": "1.3.2",
|
|
45
|
+
"@semantic-release/changelog": "6.0.1",
|
|
46
|
+
"@semantic-release/git": "10.0.1",
|
|
47
|
+
"@semantic-release/github": "8.0.4",
|
|
48
|
+
"@types/fs-extra": "9.0.13",
|
|
49
|
+
"@types/github-slugger": "1.3.0",
|
|
50
|
+
"@types/js-yaml": "4.0.5",
|
|
51
|
+
"@types/node": "16.11.35",
|
|
52
|
+
"@types/yargs": "17.0.10",
|
|
53
|
+
"c8": "7.11.2",
|
|
40
54
|
"codecov": "3.8.3",
|
|
41
55
|
"commitizen": "4.2.4",
|
|
42
56
|
"cz-conventional-changelog": "3.3.0",
|
|
43
|
-
"eslint": "
|
|
44
|
-
"eslint-config-airbnb": "18.2.1",
|
|
57
|
+
"eslint": "8.15.0",
|
|
45
58
|
"eslint-plugin-header": "3.1.1",
|
|
46
|
-
"eslint-plugin-import": "2.
|
|
47
|
-
"
|
|
48
|
-
"eslint-plugin-react": "7.25.3",
|
|
49
|
-
"ghooks": "2.0.4",
|
|
59
|
+
"eslint-plugin-import": "2.26.0",
|
|
60
|
+
"husky": "8.0.1",
|
|
50
61
|
"i18n-tag-schema": "2.5.0",
|
|
51
|
-
"json-logic-js": "
|
|
52
|
-
"lint-staged": "
|
|
53
|
-
"mocha": "
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"unist-util-select": "
|
|
62
|
+
"json-logic-js": "axa-ch/cyclic-schemas-test",
|
|
63
|
+
"lint-staged": "12.4.1",
|
|
64
|
+
"mocha": "10.0.0",
|
|
65
|
+
"semantic-release": "19.0.2",
|
|
66
|
+
"typescript": "4.6.4",
|
|
67
|
+
"unist-util-select": "4.0.1"
|
|
57
68
|
},
|
|
58
69
|
"engines": {
|
|
59
|
-
"node": ">=
|
|
70
|
+
"node": ">= 14.0.0"
|
|
60
71
|
},
|
|
61
72
|
"repository": {
|
|
62
73
|
"type": "git",
|
package/types/api.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2021 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { JSONSchema4, JSONSchema6, JSONSchema7 } from "json-schema";
|
|
14
|
+
import { Root } from "mdast";
|
|
15
|
+
import { filename, fullpath } from "../lib/symbols.js";
|
|
16
|
+
|
|
17
|
+
export type UniqueSymbols = {
|
|
18
|
+
readonly pointer: unique symbol;
|
|
19
|
+
readonly filename: unique symbol;
|
|
20
|
+
readonly fullpath: unique symbol;
|
|
21
|
+
readonly id: unique symbol;
|
|
22
|
+
readonly titles: unique symbol;
|
|
23
|
+
readonly resolve: unique symbol;
|
|
24
|
+
readonly slug: unique symbol;
|
|
25
|
+
readonly meta: unique symbol;
|
|
26
|
+
readonly parent: unique symbol;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type JsonSchema = JSONSchema4 | JSONSchema6 | JSONSchema7;
|
|
30
|
+
export type SchemaList = {
|
|
31
|
+
fileName: string;
|
|
32
|
+
fullPath: string;
|
|
33
|
+
};
|
|
34
|
+
export type SchemaContent = {
|
|
35
|
+
fileName: string;
|
|
36
|
+
fullPath?: string;
|
|
37
|
+
content: JsonSchema;
|
|
38
|
+
};
|
|
39
|
+
export type SchemaFiles = (SchemaList | SchemaContent)[];
|
|
40
|
+
export type ExtendedJsonSchema = JsonSchema & {
|
|
41
|
+
[filename]: string;
|
|
42
|
+
[fullpath]?: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type MarkdownAst = Root;
|
|
46
|
+
export type MarkdownContent = {
|
|
47
|
+
fileName: string;
|
|
48
|
+
fullPath: string;
|
|
49
|
+
markdownAst?: MarkdownAst;
|
|
50
|
+
content?: string;
|
|
51
|
+
};
|
|
52
|
+
export type ReadmeContent = MarkdownContent & {
|
|
53
|
+
fileName: "README.md";
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* GeneratedOutput
|
|
58
|
+
*/
|
|
59
|
+
export type GeneratedOutput = {
|
|
60
|
+
/**
|
|
61
|
+
* Input JSON schemas
|
|
62
|
+
*/
|
|
63
|
+
schema: SchemaContent[];
|
|
64
|
+
/**
|
|
65
|
+
* Ouput Readme file
|
|
66
|
+
*/
|
|
67
|
+
readme?: ReadmeContent;
|
|
68
|
+
/**
|
|
69
|
+
* Output markdown data
|
|
70
|
+
*/
|
|
71
|
+
markdown: MarkdownContent[];
|
|
72
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export default function formatmeta(schema: any): {
|
|
2
|
+
longcomment: import("mdast").Root;
|
|
3
|
+
shortcomment: any;
|
|
4
|
+
comment: string;
|
|
5
|
+
longdescription: import("mdast").Root;
|
|
6
|
+
shortdescription: any;
|
|
7
|
+
description: any;
|
|
8
|
+
abstract: boolean;
|
|
9
|
+
extensible: boolean;
|
|
10
|
+
status: any;
|
|
11
|
+
identifiable: string;
|
|
12
|
+
custom: boolean;
|
|
13
|
+
additional: boolean;
|
|
14
|
+
definedin: {
|
|
15
|
+
text: any;
|
|
16
|
+
link: any;
|
|
17
|
+
};
|
|
18
|
+
restrictions: string;
|
|
19
|
+
};
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("../types/api").JsonSchema} JsonSchema
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {import("../types/api").SchemaList} SchemaList
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {import("../types/api").SchemaContent} SchemaContent
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {import("../types/api").SchemaFiles} SchemaFiles
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* @typedef {import("../types/api").GeneratedOutput} GeneratedOutput
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Public API for jsonschema2md that can be used to turn JSON Schema files
|
|
18
|
+
* into readable Markdown documentation.
|
|
19
|
+
* @param {JsonSchema | SchemaFiles} schema JSON Schema input to get data from
|
|
20
|
+
* @param {Object} options Additional options for generation
|
|
21
|
+
* @param {string} [options.schemaPath] - (optional) Path to directory containing all JSON Schemas
|
|
22
|
+
* or a single JSON Schema file. This will be considered as the baseURL.
|
|
23
|
+
* @param {string} [options.outDir] - (optional) Path to output directory. Generating files will
|
|
24
|
+
* be skipped if directory is not specified.
|
|
25
|
+
* @param {{ [key:string]: string }} [options.metadata] - (optional) Add metadata elements to
|
|
26
|
+
* .md files.
|
|
27
|
+
* @param {string} [options.schemaOut] - (optional) Output JSON Schema files including
|
|
28
|
+
* description and validated examples in the specified folder.
|
|
29
|
+
* @param {boolean} [options.includeReadme=true] - (optional) Generate a README.md file in the
|
|
30
|
+
* output directory.
|
|
31
|
+
* @param {{ [key:string]: string }[]} [options.links] - (optional) Add this file as a link
|
|
32
|
+
* explaining the specified attribute.
|
|
33
|
+
* @param {string} [options.i18n="locales/"] - (optional) Path to a locales folder with
|
|
34
|
+
* JSON files used for internationalization.
|
|
35
|
+
* @param {"en_US" | "de"} [options.language="en_US"] - (optional) Selected language.
|
|
36
|
+
* @param {"json" | "yaml"} [options.exampleFormat="json"] - (optional) How to format examples.
|
|
37
|
+
* @param {string[]} [options.includeProperties=[]] - (optional) Name of custom properties
|
|
38
|
+
* which should be also in the description of an element.
|
|
39
|
+
* @param {boolean} [options.header=true] - (optional) Whether or not to include the header
|
|
40
|
+
* in markdown.
|
|
41
|
+
* @param {string[]} [options.skipProperties=[]] - (optional) Name of a default property to
|
|
42
|
+
* skip in markdown.
|
|
43
|
+
* @returns {GeneratedOutput} List of raw markdown that were generated from input schema.
|
|
44
|
+
*/
|
|
45
|
+
export function jsonschema2md(schema: JsonSchema | import("../types/api").SchemaFiles, options: {
|
|
46
|
+
schemaPath?: string;
|
|
47
|
+
outDir?: string;
|
|
48
|
+
metadata?: {
|
|
49
|
+
[key: string]: string;
|
|
50
|
+
};
|
|
51
|
+
schemaOut?: string;
|
|
52
|
+
includeReadme?: boolean;
|
|
53
|
+
links?: {
|
|
54
|
+
[key: string]: string;
|
|
55
|
+
}[];
|
|
56
|
+
i18n?: string;
|
|
57
|
+
language?: "en_US" | "de";
|
|
58
|
+
exampleFormat?: "json" | "yaml";
|
|
59
|
+
includeProperties?: string[];
|
|
60
|
+
header?: boolean;
|
|
61
|
+
skipProperties?: string[];
|
|
62
|
+
}): GeneratedOutput;
|
|
63
|
+
/**
|
|
64
|
+
* Main function used in the CLI.
|
|
65
|
+
* @param {{ [key:string]: unknown }} args CLI arguments from user input
|
|
66
|
+
* @returns The generated Markdown files to the specified output directory
|
|
67
|
+
*/
|
|
68
|
+
export function main(args: {
|
|
69
|
+
[key: string]: unknown;
|
|
70
|
+
}): Promise<number>;
|
|
71
|
+
export type JsonSchema = import("../types/api").JsonSchema;
|
|
72
|
+
export type SchemaList = import("../types/api").SchemaList;
|
|
73
|
+
export type SchemaContent = import("../types/api").SchemaContent;
|
|
74
|
+
export type SchemaFiles = import("../types/api").SchemaFiles;
|
|
75
|
+
export type GeneratedOutput = import("../types/api").GeneratedOutput;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export default function build({ header, links, includeProperties, rewritelinks, exampleFormat, skipProperties, }?: {
|
|
2
|
+
header: any;
|
|
3
|
+
links?: {};
|
|
4
|
+
includeProperties?: any[];
|
|
5
|
+
rewritelinks?: (x: any) => any;
|
|
6
|
+
exampleFormat?: string;
|
|
7
|
+
skipProperties?: any[];
|
|
8
|
+
}): (schemas: any) => any;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function loader(): (name: string, schema: any) => any;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("../types/api").UniqueSymbols} UniqueSymbols
|
|
3
|
+
*/
|
|
4
|
+
export const filename: unique symbol;
|
|
5
|
+
export const fullpath: unique symbol;
|
|
6
|
+
export default symbols;
|
|
7
|
+
export type UniqueSymbols = import("../types/api").UniqueSymbols;
|
|
8
|
+
/**
|
|
9
|
+
* @type {UniqueSymbols}
|
|
10
|
+
* */
|
|
11
|
+
declare const symbols: UniqueSymbols;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("../types/api").MarkdownAst} MarkdownAst
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {import("../types/api").MarkdownContent} MarkdownContent
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {import("../types/api").ReadmeContent} ReadmeContent
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {{ [name: string]: MarkdownAst }} MarkdownAstFiles
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Write the Markdown to filesystem or an object
|
|
15
|
+
* @param {Object} options
|
|
16
|
+
* @param {string} [options.out] - (optional) Directory where the files will be saved
|
|
17
|
+
* @param {Function} [options.error] - (optional) Error logger
|
|
18
|
+
* @param {Function} [options.info] - (optional) Info logger
|
|
19
|
+
* @param {Function} [options.debug] - (optional) Debug logger
|
|
20
|
+
* @param {{ [key: string]: string }} [options.meta] - (optional) Metadata to be added to Markdown
|
|
21
|
+
* @returns {(astFiles: MarkdownAstFiles) => MarkdownContent[]}
|
|
22
|
+
*/
|
|
23
|
+
export function writemarkdown({ out, error, meta, }: {
|
|
24
|
+
out?: string;
|
|
25
|
+
error?: Function;
|
|
26
|
+
info?: Function;
|
|
27
|
+
debug?: Function;
|
|
28
|
+
meta?: {
|
|
29
|
+
[key: string]: string;
|
|
30
|
+
};
|
|
31
|
+
}): (astFiles: MarkdownAstFiles) => MarkdownContent[];
|
|
32
|
+
/**
|
|
33
|
+
* Write the Readme Markdown to filesystem or an object
|
|
34
|
+
* @param {Object} options
|
|
35
|
+
* @param {string} [options.out] - (optional) Directory where the files will be saved
|
|
36
|
+
* @param {Function} [options.error] - (optional) Error logger
|
|
37
|
+
* @param {Function} [options.info] - (optional) Info logger
|
|
38
|
+
* @param {Function} [options.debug] - (optional) Debug logger
|
|
39
|
+
* @param {{ [key: string]: string }} [options.meta] - (optional) Metadata to be added to Markdown
|
|
40
|
+
* @returns {(markdownAst: MarkdownAst) => ReadmeContent}
|
|
41
|
+
*/
|
|
42
|
+
export function writereadme({ out, error, info, meta, }: {
|
|
43
|
+
out?: string;
|
|
44
|
+
error?: Function;
|
|
45
|
+
info?: Function;
|
|
46
|
+
debug?: Function;
|
|
47
|
+
meta?: {
|
|
48
|
+
[key: string]: string;
|
|
49
|
+
};
|
|
50
|
+
}): (markdownAst: MarkdownAst) => ReadmeContent;
|
|
51
|
+
export type MarkdownAst = import("../types/api").MarkdownAst;
|
|
52
|
+
export type MarkdownContent = import("../types/api").MarkdownContent;
|
|
53
|
+
export type ReadmeContent = import("../types/api").ReadmeContent;
|
|
54
|
+
export type MarkdownAstFiles = {
|
|
55
|
+
[name: string]: import("mdast").Root;
|
|
56
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("../types/api").ExtendedJsonSchema} ExtendedJsonSchema
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {import("../types/api").SchemaContent} SchemaContent
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Write the JSON Schemas to filesystem or an object
|
|
9
|
+
* @param {Object} options
|
|
10
|
+
* @param {string} [options.schemadir] - (optional) Directory where the files will be saved
|
|
11
|
+
* @param {string} [options.origindir] - (optional) Directory where the files were loaded from
|
|
12
|
+
* @returns {(schemas: ExtendedJsonSchema[]) => SchemaContent[]}
|
|
13
|
+
*/
|
|
14
|
+
export default function writeSchema({ schemadir, origindir }: {
|
|
15
|
+
schemadir?: string;
|
|
16
|
+
origindir?: string;
|
|
17
|
+
}): (schemas: ExtendedJsonSchema[]) => SchemaContent[];
|
|
18
|
+
export type ExtendedJsonSchema = import("../types/api").ExtendedJsonSchema;
|
|
19
|
+
export type SchemaContent = import("../types/api").SchemaContent;
|