getInputFiles() (#16)
This commit is contained in:
Родитель
376578ca25
Коммит
f3c26a3b0c
21
package.json
21
package.json
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@azure/openapi-markdown",
|
||||
"version": "0.7.7",
|
||||
"version": "0.7.8",
|
||||
"description": "Azure OpenAPI MarkDown",
|
||||
"scripts": {
|
||||
"tsc": "tsc",
|
||||
|
@ -34,17 +34,17 @@
|
|||
"devDependencies": {
|
||||
"@types/chai": "^4.1.7",
|
||||
"@types/chai-as-promised": "^7.1.0",
|
||||
"@types/commonmark": "^0.27.1",
|
||||
"@types/js-yaml": "^3.11.4",
|
||||
"@types/mocha": "^5.2.5",
|
||||
"@types/commonmark": "^0.27.3",
|
||||
"@types/js-yaml": "^3.12.0",
|
||||
"@types/mocha": "^5.2.6",
|
||||
"@types/node": "^10.12.18",
|
||||
"chai": "^4.2.0",
|
||||
"chai-as-promised": "^7.1.1",
|
||||
"mocha": "^5.2.0",
|
||||
"mocha": "^6.0.2",
|
||||
"mocha-junit-reporter": "^1.18.0",
|
||||
"mocha-multi-reporters": "^1.1.7",
|
||||
"nyc": "^13.1.0",
|
||||
"typescript": "^3.2.2"
|
||||
"nyc": "^13.3.0",
|
||||
"typescript": "^3.3.3333"
|
||||
},
|
||||
"nyc": {
|
||||
"reporter": [
|
||||
|
@ -54,11 +54,12 @@
|
|||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"@ts-common/commonmark-to-markdown": "^1.1.3",
|
||||
"@ts-common/commonmark-to-markdown": "^1.1.10",
|
||||
"@ts-common/virtual-fs": "^0.1.2",
|
||||
"@ts-common/string-map": "^0.2.3",
|
||||
"@ts-common/string-map": "^0.2.5",
|
||||
"@ts-common/iterator": "^0.1.4",
|
||||
"commonmark": "^0.28.1",
|
||||
"js-yaml": "^3.12.0",
|
||||
"js-yaml": "^3.12.2",
|
||||
"tslib": "^1.9.3"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,8 @@ export {
|
|||
hasSuppressionBlock,
|
||||
getCodeBlocksAndHeadings,
|
||||
getYamlFromNode,
|
||||
getTagsToSettingsMapping
|
||||
getTagsToSettingsMapping,
|
||||
getInputFiles
|
||||
} from "./readMeManipulator"
|
||||
export { Logger } from "./logger"
|
||||
export { ReadMeBuilder } from "./readMeBuilder"
|
||||
|
|
|
@ -133,8 +133,7 @@ const isTagSettings = (obj: unknown): obj is TagSettings =>
|
|||
export const getTagsToSettingsMapping = (
|
||||
startNode: commonmark.Node
|
||||
): { readonly [keg: string]: TagSettings|undefined } =>
|
||||
it.fold(
|
||||
getAllCodeBlockNodes(startNode),
|
||||
getAllCodeBlockNodes(startNode).fold(
|
||||
(accumulator, node) => {
|
||||
if (node && node.literal && node.info) {
|
||||
let settings: unknown
|
||||
|
@ -158,6 +157,9 @@ export const getTagsToSettingsMapping = (
|
|||
{}
|
||||
);
|
||||
|
||||
export const getInputFiles = (startNode: commonmark.Node) : it.IterableEx<string> =>
|
||||
sm.values(getTagsToSettingsMapping(startNode)).flatMap(v => v["input-file"])
|
||||
|
||||
export const addSuppression = (
|
||||
startNode: commonmark.Node,
|
||||
item: SuppressionItem
|
||||
|
@ -212,8 +214,7 @@ export interface CodeBlocksAndHeadings {
|
|||
export const getCodeBlocksAndHeadings = (
|
||||
startNode: commonmark.Node
|
||||
): CodeBlocksAndHeadings =>
|
||||
it.fold(
|
||||
getAllCodeBlockNodes(startNode),
|
||||
getAllCodeBlockNodes(startNode).fold(
|
||||
(acc, curr) => {
|
||||
const headingNode = nodeHeading(curr)
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import * as chai from "chai"
|
|||
import * as cm2md from "@ts-common/commonmark-to-markdown"
|
||||
|
||||
import { ReadMeBuilder } from "../readMeBuilder"
|
||||
import { ReadMeManipulator, getCodeBlocksAndHeadings, addSuppression } from "../readMeManipulator"
|
||||
import { ReadMeManipulator, getCodeBlocksAndHeadings, addSuppression, getTagsToSettingsMapping, getInputFiles } from "../readMeManipulator"
|
||||
import { Logger } from '../logger';
|
||||
|
||||
// const reader = new commonmark.Parser();
|
||||
|
@ -62,6 +62,34 @@ describe("@fast ReadmeManipulator.getAllTags", () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe("@fast getTagsToSettingsMapping", () => {
|
||||
it("should return a list of tags", () => {
|
||||
const tagsForSettings = getTagsToSettingsMapping(parsed.markDown)
|
||||
chai.expect(tagsForSettings).to.deep.equal({
|
||||
"package-2017-04": {
|
||||
"input-file": [
|
||||
"Microsoft.Cdn/stable/2017-04-02/cdn.json"
|
||||
]
|
||||
},
|
||||
"package-2017-10": {
|
||||
"input-file": [
|
||||
"Microsoft.Cdn/stable/2017-10-12/cdn.json"
|
||||
]
|
||||
}
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
describe("@fast getInputFiles", () => {
|
||||
it("should return a list of files", () => {
|
||||
const files = getInputFiles(parsed.markDown)
|
||||
chai.expect(files.toArray()).to.deep.equal([
|
||||
"Microsoft.Cdn/stable/2017-10-12/cdn.json",
|
||||
"Microsoft.Cdn/stable/2017-04-02/cdn.json"
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
describe("@fast ReadmeManipulator.getTagsForFilesChanged", () => {
|
||||
it("should identify tags that are related to given spec", async () => {
|
||||
const rm = new ReadMeManipulator(logger, readmeBuilder);
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
/* Basic Options */
|
||||
"target": "es2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
|
||||
"target": "es2017", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */
|
||||
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
|
||||
"lib": ["es2015", "es2017.object"], /* Specify library files to be included in the compilation. */
|
||||
// "lib": [], /* Specify library files to be included in the compilation. */
|
||||
// "allowJs": true, /* Allow javascript files to be compiled. */
|
||||
// "checkJs": true, /* Report errors in .js files. */
|
||||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
|
||||
"declaration": true, /* Generates corresponding '.d.ts' file. */
|
||||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||
"declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
|
||||
"sourceMap": true, /* Generates corresponding '.map' file. */
|
||||
// "outFile": "./", /* Concatenate and emit output to single file. */
|
||||
"outDir": "./dist", /* Redirect output structure to the directory. */
|
||||
|
|
Загрузка…
Ссылка в новой задаче