honkit 6.0.4 → 6.1.5
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/lib/__tests__/__fixtures__/honkit/book.d.ts +7 -0
- package/lib/__tests__/__fixtures__/honkit/book.d.ts.map +1 -0
- package/lib/__tests__/__fixtures__/honkit/book.js +9 -0
- package/lib/__tests__/e2e.test.d.ts +2 -0
- package/lib/__tests__/e2e.test.d.ts.map +1 -0
- package/lib/__tests__/e2e.test.js +81 -0
- package/lib/__tests__/init.d.ts +2 -0
- package/lib/__tests__/init.d.ts.map +1 -0
- package/lib/__tests__/init.js +19 -0
- package/lib/__tests__/satisfies.d.ts +2 -0
- package/lib/__tests__/satisfies.d.ts.map +1 -0
- package/lib/__tests__/satisfies.js +11 -0
- package/lib/__tests__/snapshot-asciidoc.d.ts +2 -0
- package/lib/__tests__/snapshot-asciidoc.d.ts.map +1 -0
- package/lib/__tests__/snapshot-asciidoc.js +48 -0
- package/lib/__tests__/snapshot-honkit.d.ts +2 -0
- package/lib/__tests__/snapshot-honkit.d.ts.map +1 -0
- package/lib/__tests__/snapshot-honkit.js +48 -0
- package/lib/cli/__tests__/watch.test.d.ts +2 -0
- package/lib/cli/__tests__/watch.test.d.ts.map +1 -0
- package/lib/cli/__tests__/watch.test.js +194 -0
- package/lib/cli/serve.d.ts.map +1 -1
- package/lib/cli/serve.js +49 -43
- package/lib/cli/watch.d.ts +22 -6
- package/lib/cli/watch.d.ts.map +1 -1
- package/lib/cli/watch.js +24 -10
- package/lib/constants/__tests__/configSchema.d.ts +2 -0
- package/lib/constants/__tests__/configSchema.d.ts.map +1 -0
- package/lib/constants/__tests__/configSchema.js +41 -0
- package/lib/fs/__tests__/mock.d.ts +2 -0
- package/lib/fs/__tests__/mock.d.ts.map +1 -0
- package/lib/fs/__tests__/mock.js +68 -0
- package/lib/models/__tests__/config.d.ts +2 -0
- package/lib/models/__tests__/config.d.ts.map +1 -0
- package/lib/models/__tests__/config.js +164 -0
- package/lib/models/__tests__/glossary.d.ts +2 -0
- package/lib/models/__tests__/glossary.d.ts.map +1 -0
- package/lib/models/__tests__/glossary.js +38 -0
- package/lib/models/__tests__/glossaryEntry.d.ts +2 -0
- package/lib/models/__tests__/glossaryEntry.d.ts.map +1 -0
- package/lib/models/__tests__/glossaryEntry.js +16 -0
- package/lib/models/__tests__/page.d.ts +2 -0
- package/lib/models/__tests__/page.d.ts.map +1 -0
- package/lib/models/__tests__/page.js +26 -0
- package/lib/models/__tests__/plugin.d.ts +2 -0
- package/lib/models/__tests__/plugin.d.ts.map +1 -0
- package/lib/models/__tests__/plugin.js +50 -0
- package/lib/models/__tests__/pluginDependency.d.ts +2 -0
- package/lib/models/__tests__/pluginDependency.d.ts.map +1 -0
- package/lib/models/__tests__/pluginDependency.js +71 -0
- package/lib/models/__tests__/summary.d.ts +2 -0
- package/lib/models/__tests__/summary.d.ts.map +1 -0
- package/lib/models/__tests__/summary.js +115 -0
- package/lib/models/__tests__/summaryArticle.d.ts +2 -0
- package/lib/models/__tests__/summaryArticle.d.ts.map +1 -0
- package/lib/models/__tests__/summaryArticle.js +117 -0
- package/lib/models/__tests__/summaryPart.d.ts +2 -0
- package/lib/models/__tests__/summaryPart.d.ts.map +1 -0
- package/lib/models/__tests__/summaryPart.js +24 -0
- package/lib/models/__tests__/templateBlock.d.ts +2 -0
- package/lib/models/__tests__/templateBlock.d.ts.map +1 -0
- package/lib/models/__tests__/templateBlock.js +172 -0
- package/lib/models/__tests__/templateEngine.d.ts +2 -0
- package/lib/models/__tests__/templateEngine.d.ts.map +1 -0
- package/lib/models/__tests__/templateEngine.js +49 -0
- package/lib/modifiers/config/__tests__/addPlugin.d.ts +2 -0
- package/lib/modifiers/config/__tests__/addPlugin.d.ts.map +1 -0
- package/lib/modifiers/config/__tests__/addPlugin.js +30 -0
- package/lib/modifiers/config/__tests__/removePlugin.d.ts +2 -0
- package/lib/modifiers/config/__tests__/removePlugin.d.ts.map +1 -0
- package/lib/modifiers/config/__tests__/removePlugin.js +29 -0
- package/lib/modifiers/config/__tests__/togglePlugin.d.ts +2 -0
- package/lib/modifiers/config/__tests__/togglePlugin.d.ts.map +1 -0
- package/lib/modifiers/config/__tests__/togglePlugin.js +28 -0
- package/lib/modifiers/summary/__tests__/editPartTitle.d.ts +2 -0
- package/lib/modifiers/summary/__tests__/editPartTitle.d.ts.map +1 -0
- package/lib/modifiers/summary/__tests__/editPartTitle.js +41 -0
- package/lib/modifiers/summary/__tests__/insertArticle.d.ts +2 -0
- package/lib/modifiers/summary/__tests__/insertArticle.d.ts.map +1 -0
- package/lib/modifiers/summary/__tests__/insertArticle.js +72 -0
- package/lib/modifiers/summary/__tests__/insertPart.d.ts +2 -0
- package/lib/modifiers/summary/__tests__/insertPart.d.ts.map +1 -0
- package/lib/modifiers/summary/__tests__/insertPart.js +56 -0
- package/lib/modifiers/summary/__tests__/mergeAtLevel.d.ts +2 -0
- package/lib/modifiers/summary/__tests__/mergeAtLevel.d.ts.map +1 -0
- package/lib/modifiers/summary/__tests__/mergeAtLevel.js +45 -0
- package/lib/modifiers/summary/__tests__/moveArticle.d.ts +2 -0
- package/lib/modifiers/summary/__tests__/moveArticle.d.ts.map +1 -0
- package/lib/modifiers/summary/__tests__/moveArticle.js +66 -0
- package/lib/modifiers/summary/__tests__/moveArticleAfter.d.ts +2 -0
- package/lib/modifiers/summary/__tests__/moveArticleAfter.d.ts.map +1 -0
- package/lib/modifiers/summary/__tests__/moveArticleAfter.js +75 -0
- package/lib/modifiers/summary/__tests__/removeArticle.d.ts +2 -0
- package/lib/modifiers/summary/__tests__/removeArticle.d.ts.map +1 -0
- package/lib/modifiers/summary/__tests__/removeArticle.js +54 -0
- package/lib/output/__tests__/ebook.d.ts +2 -0
- package/lib/output/__tests__/ebook.d.ts.map +1 -0
- package/lib/output/__tests__/ebook.js +17 -0
- package/lib/output/__tests__/json.d.ts +2 -0
- package/lib/output/__tests__/json.d.ts.map +1 -0
- package/lib/output/__tests__/json.js +43 -0
- package/lib/output/__tests__/plugin-hooks.d.ts +2 -0
- package/lib/output/__tests__/plugin-hooks.d.ts.map +1 -0
- package/lib/output/__tests__/plugin-hooks.js +57 -0
- package/lib/output/__tests__/website.d.ts +2 -0
- package/lib/output/__tests__/website.d.ts.map +1 -0
- package/lib/output/__tests__/website.js +121 -0
- package/lib/output/modifiers/__tests__/addHeadingId.d.ts +2 -0
- package/lib/output/modifiers/__tests__/addHeadingId.d.ts.map +1 -0
- package/lib/output/modifiers/__tests__/addHeadingId.js +23 -0
- package/lib/output/modifiers/__tests__/annotateText.d.ts +2 -0
- package/lib/output/modifiers/__tests__/annotateText.d.ts.map +1 -0
- package/lib/output/modifiers/__tests__/annotateText.js +71 -0
- package/lib/output/modifiers/__tests__/fetchRemoteImages.d.ts +2 -0
- package/lib/output/modifiers/__tests__/fetchRemoteImages.d.ts.map +1 -0
- package/lib/output/modifiers/__tests__/fetchRemoteImages.js +69 -0
- package/lib/output/modifiers/__tests__/highlightCode.d.ts +2 -0
- package/lib/output/modifiers/__tests__/highlightCode.d.ts.map +1 -0
- package/lib/output/modifiers/__tests__/highlightCode.js +48 -0
- package/lib/output/modifiers/__tests__/inlinePng.d.ts +2 -0
- package/lib/output/modifiers/__tests__/inlinePng.d.ts.map +1 -0
- package/lib/output/modifiers/__tests__/inlinePng.js +22 -0
- package/lib/output/modifiers/__tests__/inlineSvg.d.ts +2 -0
- package/lib/output/modifiers/__tests__/inlineSvg.d.ts.map +1 -0
- package/lib/output/modifiers/__tests__/inlineSvg.js +42 -0
- package/lib/output/modifiers/__tests__/resolveImages.d.ts +2 -0
- package/lib/output/modifiers/__tests__/resolveImages.d.ts.map +1 -0
- package/lib/output/modifiers/__tests__/resolveImages.js +39 -0
- package/lib/output/modifiers/__tests__/resolveLinks.d.ts +2 -0
- package/lib/output/modifiers/__tests__/resolveLinks.d.ts.map +1 -0
- package/lib/output/modifiers/__tests__/resolveLinks.js +81 -0
- package/lib/output/modifiers/__tests__/svgToImg.d.ts +2 -0
- package/lib/output/modifiers/__tests__/svgToImg.d.ts.map +1 -0
- package/lib/output/modifiers/__tests__/svgToImg.js +29 -0
- package/lib/output/website/__tests__/i18n.d.ts +2 -0
- package/lib/output/website/__tests__/i18n.d.ts.map +1 -0
- package/lib/output/website/__tests__/i18n.js +40 -0
- package/lib/parse/__tests__/listAssets.d.ts +2 -0
- package/lib/parse/__tests__/listAssets.d.ts.map +1 -0
- package/lib/parse/__tests__/listAssets.js +63 -0
- package/lib/parse/__tests__/parseBook.d.ts +2 -0
- package/lib/parse/__tests__/parseBook.d.ts.map +1 -0
- package/lib/parse/__tests__/parseBook.js +77 -0
- package/lib/parse/__tests__/parseGlossary.d.ts +2 -0
- package/lib/parse/__tests__/parseGlossary.d.ts.map +1 -0
- package/lib/parse/__tests__/parseGlossary.js +32 -0
- package/lib/parse/__tests__/parseIgnore.d.ts +2 -0
- package/lib/parse/__tests__/parseIgnore.d.ts.map +1 -0
- package/lib/parse/__tests__/parseIgnore.js +37 -0
- package/lib/parse/__tests__/parsePageFromString.d.ts +2 -0
- package/lib/parse/__tests__/parsePageFromString.d.ts.map +1 -0
- package/lib/parse/__tests__/parsePageFromString.js +34 -0
- package/lib/parse/__tests__/parseReadme.d.ts +2 -0
- package/lib/parse/__tests__/parseReadme.d.ts.map +1 -0
- package/lib/parse/__tests__/parseReadme.js +33 -0
- package/lib/parse/__tests__/parseSummary.d.ts +2 -0
- package/lib/parse/__tests__/parseSummary.d.ts.map +1 -0
- package/lib/parse/__tests__/parseSummary.js +30 -0
- package/lib/plugins/__tests__/listDependencies.d.ts +2 -0
- package/lib/plugins/__tests__/listDependencies.d.ts.map +1 -0
- package/lib/plugins/__tests__/listDependencies.js +28 -0
- package/lib/plugins/__tests__/sortDependencies.d.ts +2 -0
- package/lib/plugins/__tests__/sortDependencies.d.ts.map +1 -0
- package/lib/plugins/__tests__/sortDependencies.js +28 -0
- package/lib/plugins/__tests__/validatePlugin.d.ts +2 -0
- package/lib/plugins/__tests__/validatePlugin.d.ts.map +1 -0
- package/lib/plugins/__tests__/validatePlugin.js +99 -0
- package/lib/templating/__tests__/conrefsLoader.d.ts +2 -0
- package/lib/templating/__tests__/conrefsLoader.d.ts.map +1 -0
- package/lib/templating/__tests__/conrefsLoader.js +90 -0
- package/lib/templating/__tests__/postRender.d.ts +2 -0
- package/lib/templating/__tests__/postRender.d.ts.map +1 -0
- package/lib/templating/__tests__/postRender.js +52 -0
- package/lib/templating/__tests__/replaceShortcuts.d.ts +2 -0
- package/lib/templating/__tests__/replaceShortcuts.d.ts.map +1 -0
- package/lib/templating/__tests__/replaceShortcuts.js +27 -0
- package/lib/utils/__tests__/git.d.ts +2 -0
- package/lib/utils/__tests__/git.d.ts.map +1 -0
- package/lib/utils/__tests__/git.js +46 -0
- package/lib/utils/__tests__/location.d.ts +2 -0
- package/lib/utils/__tests__/location.d.ts.map +1 -0
- package/lib/utils/__tests__/location.js +81 -0
- package/lib/utils/__tests__/path.d.ts +2 -0
- package/lib/utils/__tests__/path.d.ts.map +1 -0
- package/lib/utils/__tests__/path.js +19 -0
- package/package.json +17 -19
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const summary_1 = __importDefault(require("../../../models/summary"));
|
|
7
|
+
const file_1 = __importDefault(require("../../../models/file"));
|
|
8
|
+
const editPartTitle_1 = __importDefault(require("../editPartTitle"));
|
|
9
|
+
describe("editPartTitle", () => {
|
|
10
|
+
const summary = summary_1.default.createFromParts(new file_1.default(), [
|
|
11
|
+
{
|
|
12
|
+
articles: [
|
|
13
|
+
{
|
|
14
|
+
title: "My First Article",
|
|
15
|
+
path: "README.md",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
title: "My Second Article",
|
|
19
|
+
path: "article.md",
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
title: "Test",
|
|
25
|
+
},
|
|
26
|
+
]);
|
|
27
|
+
test("should correctly set title of first part", () => {
|
|
28
|
+
const newSummary = (0, editPartTitle_1.default)(summary, 0, "Hello World");
|
|
29
|
+
const part = newSummary.getPart(0);
|
|
30
|
+
expect(part.getTitle()).toBe("Hello World");
|
|
31
|
+
});
|
|
32
|
+
test("should correctly set title of second part", () => {
|
|
33
|
+
const newSummary = (0, editPartTitle_1.default)(summary, 1, "Hello");
|
|
34
|
+
const part = newSummary.getPart(1);
|
|
35
|
+
expect(part.getTitle()).toBe("Hello");
|
|
36
|
+
});
|
|
37
|
+
test("should not fail if part doesn't exist", () => {
|
|
38
|
+
const newSummary = (0, editPartTitle_1.default)(summary, 3, "Hello");
|
|
39
|
+
expect(newSummary.getParts().size).toBe(2);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insertArticle.d.ts","sourceRoot":"","sources":["../../../../src/modifiers/summary/__tests__/insertArticle.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const summary_1 = __importDefault(require("../../../models/summary"));
|
|
7
|
+
const summaryArticle_1 = __importDefault(require("../../../models/summaryArticle"));
|
|
8
|
+
const file_1 = __importDefault(require("../../../models/file"));
|
|
9
|
+
const insertArticle_1 = __importDefault(require("../insertArticle"));
|
|
10
|
+
describe("insertArticle", () => {
|
|
11
|
+
const summary = summary_1.default.createFromParts(new file_1.default(), [
|
|
12
|
+
{
|
|
13
|
+
articles: [
|
|
14
|
+
{
|
|
15
|
+
title: "1.1",
|
|
16
|
+
path: "1.1",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
title: "1.2",
|
|
20
|
+
path: "1.2",
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
title: "Part I",
|
|
26
|
+
articles: [
|
|
27
|
+
{
|
|
28
|
+
title: "2.1",
|
|
29
|
+
path: "2.1",
|
|
30
|
+
articles: [
|
|
31
|
+
{
|
|
32
|
+
title: "2.1.1",
|
|
33
|
+
path: "2.1.1",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
title: "2.1.2",
|
|
37
|
+
path: "2.1.2",
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
title: "2.2",
|
|
43
|
+
path: "2.2",
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
]);
|
|
48
|
+
test("should insert an article at a given level", () => {
|
|
49
|
+
const article = summaryArticle_1.default.create({
|
|
50
|
+
title: "Inserted",
|
|
51
|
+
}, "fake.level");
|
|
52
|
+
const newSummary = (0, insertArticle_1.default)(summary, article, "2.1.1");
|
|
53
|
+
const inserted = newSummary.getByLevel("2.1.1");
|
|
54
|
+
const nextOne = newSummary.getByLevel("2.1.2");
|
|
55
|
+
expect(inserted.getTitle()).toBe("Inserted");
|
|
56
|
+
expect(inserted.getLevel()).toBe("2.1.1");
|
|
57
|
+
expect(nextOne.getTitle()).toBe("2.1.1");
|
|
58
|
+
expect(nextOne.getLevel()).toBe("2.1.2");
|
|
59
|
+
});
|
|
60
|
+
test("should insert an article in last position", () => {
|
|
61
|
+
const article = summaryArticle_1.default.create({
|
|
62
|
+
title: "Inserted",
|
|
63
|
+
}, "fake.level");
|
|
64
|
+
const newSummary = (0, insertArticle_1.default)(summary, article, "2.2");
|
|
65
|
+
const inserted = newSummary.getByLevel("2.2");
|
|
66
|
+
const previousOne = newSummary.getByLevel("2.1");
|
|
67
|
+
expect(inserted.getTitle()).toBe("Inserted");
|
|
68
|
+
expect(inserted.getLevel()).toBe("2.2");
|
|
69
|
+
expect(previousOne.getTitle()).toBe("2.1"); // Unchanged
|
|
70
|
+
expect(previousOne.getLevel()).toBe("2.1");
|
|
71
|
+
});
|
|
72
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insertPart.d.ts","sourceRoot":"","sources":["../../../../src/modifiers/summary/__tests__/insertPart.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const summary_1 = __importDefault(require("../../../models/summary"));
|
|
7
|
+
const summaryPart_1 = __importDefault(require("../../../models/summaryPart"));
|
|
8
|
+
const file_1 = __importDefault(require("../../../models/file"));
|
|
9
|
+
const insertPart_1 = __importDefault(require("../insertPart"));
|
|
10
|
+
describe("insertPart", () => {
|
|
11
|
+
const summary = summary_1.default.createFromParts(new file_1.default(), [
|
|
12
|
+
{
|
|
13
|
+
articles: [
|
|
14
|
+
{
|
|
15
|
+
title: "1.1",
|
|
16
|
+
path: "1.1",
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
title: "Part I",
|
|
22
|
+
articles: [
|
|
23
|
+
{
|
|
24
|
+
title: "2.1",
|
|
25
|
+
path: "2.1",
|
|
26
|
+
articles: [],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
title: "2.2",
|
|
30
|
+
path: "2.2",
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
]);
|
|
35
|
+
test("should insert an part at a given level", () => {
|
|
36
|
+
const part = summaryPart_1.default.create({
|
|
37
|
+
title: "Inserted",
|
|
38
|
+
}, "meaningless.level");
|
|
39
|
+
const newSummary = (0, insertPart_1.default)(summary, part, 1);
|
|
40
|
+
const inserted = newSummary.getPart(1);
|
|
41
|
+
expect(inserted.getTitle()).toBe("Inserted");
|
|
42
|
+
expect(newSummary.getParts().count()).toBe(3);
|
|
43
|
+
const otherArticle = newSummary.getByLevel("3.1");
|
|
44
|
+
expect(otherArticle.getTitle()).toBe("2.1");
|
|
45
|
+
expect(otherArticle.getLevel()).toBe("3.1");
|
|
46
|
+
});
|
|
47
|
+
test("should insert an part in last position", () => {
|
|
48
|
+
const part = summaryPart_1.default.create({
|
|
49
|
+
title: "Inserted",
|
|
50
|
+
}, "meaningless.level");
|
|
51
|
+
const newSummary = (0, insertPart_1.default)(summary, part, 2);
|
|
52
|
+
const inserted = newSummary.getPart(2);
|
|
53
|
+
expect(inserted.getTitle()).toBe("Inserted");
|
|
54
|
+
expect(newSummary.getParts().count()).toBe(3);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeAtLevel.d.ts","sourceRoot":"","sources":["../../../../src/modifiers/summary/__tests__/mergeAtLevel.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const immutable_1 = __importDefault(require("immutable"));
|
|
7
|
+
const summary_1 = __importDefault(require("../../../models/summary"));
|
|
8
|
+
const file_1 = __importDefault(require("../../../models/file"));
|
|
9
|
+
const mergeAtLevel_1 = __importDefault(require("../mergeAtLevel"));
|
|
10
|
+
describe("mergeAtLevel", () => {
|
|
11
|
+
const summary = summary_1.default.createFromParts(new file_1.default(), [
|
|
12
|
+
{
|
|
13
|
+
articles: [
|
|
14
|
+
{
|
|
15
|
+
title: "1.1",
|
|
16
|
+
path: "1.1",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
title: "1.2",
|
|
20
|
+
path: "1.2",
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
title: "Part I",
|
|
26
|
+
articles: [],
|
|
27
|
+
},
|
|
28
|
+
]);
|
|
29
|
+
test("should edit a part", () => {
|
|
30
|
+
const beforeChildren = summary.getByLevel("1").getArticles();
|
|
31
|
+
const newSummary = (0, mergeAtLevel_1.default)(summary, "1", { title: "Part O" });
|
|
32
|
+
const edited = newSummary.getByLevel("1");
|
|
33
|
+
expect(edited.getTitle()).toBe("Part O");
|
|
34
|
+
// Same children
|
|
35
|
+
expect(immutable_1.default.is(beforeChildren, edited.getArticles())).toBe(true);
|
|
36
|
+
});
|
|
37
|
+
test("should edit a part", () => {
|
|
38
|
+
const beforePath = summary.getByLevel("1.2").getPath();
|
|
39
|
+
const newSummary = (0, mergeAtLevel_1.default)(summary, "1.2", { title: "Renamed article" });
|
|
40
|
+
const edited = newSummary.getByLevel("1.2");
|
|
41
|
+
expect(edited.getTitle()).toBe("Renamed article");
|
|
42
|
+
// Same children
|
|
43
|
+
expect(immutable_1.default.is(beforePath, edited.getPath())).toBe(true);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moveArticle.d.ts","sourceRoot":"","sources":["../../../../src/modifiers/summary/__tests__/moveArticle.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const immutable_1 = __importDefault(require("immutable"));
|
|
7
|
+
const summary_1 = __importDefault(require("../../../models/summary"));
|
|
8
|
+
const file_1 = __importDefault(require("../../../models/file"));
|
|
9
|
+
const moveArticle_1 = __importDefault(require("../moveArticle"));
|
|
10
|
+
describe("moveArticle", () => {
|
|
11
|
+
const summary = summary_1.default.createFromParts(new file_1.default(), [
|
|
12
|
+
{
|
|
13
|
+
articles: [
|
|
14
|
+
{
|
|
15
|
+
title: "1.1",
|
|
16
|
+
path: "1.1",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
title: "1.2",
|
|
20
|
+
path: "1.2",
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
title: "Part I",
|
|
26
|
+
articles: [
|
|
27
|
+
{
|
|
28
|
+
title: "2.1",
|
|
29
|
+
path: "2.1",
|
|
30
|
+
articles: [
|
|
31
|
+
{
|
|
32
|
+
title: "2.1.1",
|
|
33
|
+
path: "2.1.1",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
title: "2.1.2",
|
|
37
|
+
path: "2.1.2",
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
title: "2.2",
|
|
43
|
+
path: "2.2",
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
]);
|
|
48
|
+
test("should move an article to the same place", () => {
|
|
49
|
+
const newSummary = (0, moveArticle_1.default)(summary, "2.1", "2.1");
|
|
50
|
+
expect(immutable_1.default.is(summary, newSummary)).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
test("should move an article to an previous level", () => {
|
|
53
|
+
const newSummary = (0, moveArticle_1.default)(summary, "2.2", "2.1");
|
|
54
|
+
const moved = newSummary.getByLevel("2.1");
|
|
55
|
+
const other = newSummary.getByLevel("2.2");
|
|
56
|
+
expect(moved.getTitle()).toBe("2.2");
|
|
57
|
+
expect(other.getTitle()).toBe("2.1");
|
|
58
|
+
});
|
|
59
|
+
test("should move an article to a next level", () => {
|
|
60
|
+
const newSummary = (0, moveArticle_1.default)(summary, "2.1", "2.2");
|
|
61
|
+
const moved = newSummary.getByLevel("2.1");
|
|
62
|
+
const other = newSummary.getByLevel("2.2");
|
|
63
|
+
expect(moved.getTitle()).toBe("2.2");
|
|
64
|
+
expect(other.getTitle()).toBe("2.1");
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"moveArticleAfter.d.ts","sourceRoot":"","sources":["../../../../src/modifiers/summary/__tests__/moveArticleAfter.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const immutable_1 = __importDefault(require("immutable"));
|
|
7
|
+
const summary_1 = __importDefault(require("../../../models/summary"));
|
|
8
|
+
const file_1 = __importDefault(require("../../../models/file"));
|
|
9
|
+
const moveArticleAfter_1 = __importDefault(require("../moveArticleAfter"));
|
|
10
|
+
describe("moveArticleAfter", () => {
|
|
11
|
+
const summary = summary_1.default.createFromParts(new file_1.default(), [
|
|
12
|
+
{
|
|
13
|
+
articles: [
|
|
14
|
+
{
|
|
15
|
+
title: "1.1",
|
|
16
|
+
path: "1.1",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
title: "1.2",
|
|
20
|
+
path: "1.2",
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
title: "Part I",
|
|
26
|
+
articles: [
|
|
27
|
+
{
|
|
28
|
+
title: "2.1",
|
|
29
|
+
path: "2.1",
|
|
30
|
+
articles: [
|
|
31
|
+
{
|
|
32
|
+
title: "2.1.1",
|
|
33
|
+
path: "2.1.1",
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
title: "2.1.2",
|
|
37
|
+
path: "2.1.2",
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
title: "2.2",
|
|
43
|
+
path: "2.2",
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
]);
|
|
48
|
+
test("moving right after itself should be invariant", () => {
|
|
49
|
+
const newSummary = (0, moveArticleAfter_1.default)(summary, "2.1", "2.1");
|
|
50
|
+
expect(immutable_1.default.is(summary, newSummary)).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
test("moving after previous one should be invariant too", () => {
|
|
53
|
+
const newSummary = (0, moveArticleAfter_1.default)(summary, "2.1", "2.0");
|
|
54
|
+
expect(immutable_1.default.is(summary, newSummary)).toBe(true);
|
|
55
|
+
});
|
|
56
|
+
test("should move an article after a previous level", () => {
|
|
57
|
+
const newSummary = (0, moveArticleAfter_1.default)(summary, "2.2", "2.0");
|
|
58
|
+
const moved = newSummary.getByLevel("2.1");
|
|
59
|
+
expect(moved.getTitle()).toBe("2.2");
|
|
60
|
+
expect(newSummary.getByLevel("2.2").getTitle()).toBe("2.1");
|
|
61
|
+
});
|
|
62
|
+
test("should move an article after a previous and less deep level", () => {
|
|
63
|
+
const newSummary = (0, moveArticleAfter_1.default)(summary, "2.1.1", "2.0");
|
|
64
|
+
const moved = newSummary.getByLevel("2.1");
|
|
65
|
+
expect(moved.getTitle()).toBe("2.1.1");
|
|
66
|
+
expect(newSummary.getByLevel("2.2.1").getTitle()).toBe("2.1.2");
|
|
67
|
+
expect(newSummary.getByLevel("2.2").getTitle()).toBe("2.1");
|
|
68
|
+
});
|
|
69
|
+
test("should move an article after a next level", () => {
|
|
70
|
+
const newSummary = (0, moveArticleAfter_1.default)(summary, "2.1", "2.2");
|
|
71
|
+
const moved = newSummary.getByLevel("2.2");
|
|
72
|
+
expect(moved.getTitle()).toBe("2.1");
|
|
73
|
+
expect(newSummary.getByLevel("2.1").getTitle()).toBe("2.2");
|
|
74
|
+
});
|
|
75
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"removeArticle.d.ts","sourceRoot":"","sources":["../../../../src/modifiers/summary/__tests__/removeArticle.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const summary_1 = __importDefault(require("../../../models/summary"));
|
|
7
|
+
const file_1 = __importDefault(require("../../../models/file"));
|
|
8
|
+
const removeArticle_1 = __importDefault(require("../removeArticle"));
|
|
9
|
+
describe("removeArticle", () => {
|
|
10
|
+
const summary = summary_1.default.createFromParts(new file_1.default(), [
|
|
11
|
+
{
|
|
12
|
+
articles: [
|
|
13
|
+
{
|
|
14
|
+
title: "1.1",
|
|
15
|
+
path: "1.1",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
title: "1.2",
|
|
19
|
+
path: "1.2",
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
title: "Part I",
|
|
25
|
+
articles: [
|
|
26
|
+
{
|
|
27
|
+
title: "2.1",
|
|
28
|
+
path: "2.1",
|
|
29
|
+
articles: [
|
|
30
|
+
{
|
|
31
|
+
title: "2.1.1",
|
|
32
|
+
path: "2.1.1",
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
title: "2.1.2",
|
|
36
|
+
path: "2.1.2",
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
title: "2.2",
|
|
42
|
+
path: "2.2",
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
]);
|
|
47
|
+
test("should remove an article at a given level", () => {
|
|
48
|
+
const newSummary = (0, removeArticle_1.default)(summary, "2.1.1");
|
|
49
|
+
const removed = newSummary.getByLevel("2.1.1");
|
|
50
|
+
const nextOne = newSummary.getByLevel("2.1.2");
|
|
51
|
+
expect(removed.getTitle()).toBe("2.1.2");
|
|
52
|
+
expect(nextOne).toBe(null);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ebook.d.ts","sourceRoot":"","sources":["../../../src/output/__tests__/ebook.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const generateMock_1 = __importDefault(require("../testing/generateMock"));
|
|
7
|
+
const ebook_1 = __importDefault(require("../ebook"));
|
|
8
|
+
describe("EbookGenerator", () => {
|
|
9
|
+
test("should generate a SUMMARY.html", () => {
|
|
10
|
+
return (0, generateMock_1.default)(ebook_1.default, {
|
|
11
|
+
"README.md": "Hello World"
|
|
12
|
+
}).then((folder) => {
|
|
13
|
+
expect(folder).toHaveFile("SUMMARY.html");
|
|
14
|
+
expect(folder).toHaveFile("index.html");
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../src/output/__tests__/json.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const generateMock_1 = __importDefault(require("../testing/generateMock"));
|
|
7
|
+
const json_1 = __importDefault(require("../json"));
|
|
8
|
+
describe("JSONGenerator", () => {
|
|
9
|
+
test("should generate a README.json", () => {
|
|
10
|
+
return (0, generateMock_1.default)(json_1.default, {
|
|
11
|
+
"README.md": "Hello World"
|
|
12
|
+
}).then((folder) => {
|
|
13
|
+
expect(folder).toHaveFile("README.json");
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
test("should generate a json file for each articles", () => {
|
|
17
|
+
return (0, generateMock_1.default)(json_1.default, {
|
|
18
|
+
"README.md": "Hello World",
|
|
19
|
+
"SUMMARY.md": "# Summary\n\n* [Page](test/page.md)",
|
|
20
|
+
test: {
|
|
21
|
+
"page.md": "Hello 2"
|
|
22
|
+
}
|
|
23
|
+
}).then((folder) => {
|
|
24
|
+
expect(folder).toHaveFile("README.json");
|
|
25
|
+
expect(folder).toHaveFile("test/page.json");
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
test("should generate a multilingual book", () => {
|
|
29
|
+
return (0, generateMock_1.default)(json_1.default, {
|
|
30
|
+
"LANGS.md": "# Languages\n\n* [en](en)\n* [fr](fr)",
|
|
31
|
+
en: {
|
|
32
|
+
"README.md": "Hello"
|
|
33
|
+
},
|
|
34
|
+
fr: {
|
|
35
|
+
"README.md": "Bonjour"
|
|
36
|
+
}
|
|
37
|
+
}).then((folder) => {
|
|
38
|
+
expect(folder).toHaveFile("en/README.json");
|
|
39
|
+
expect(folder).toHaveFile("fr/README.json");
|
|
40
|
+
expect(folder).toHaveFile("README.json");
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-hooks.d.ts","sourceRoot":"","sources":["../../../src/output/__tests__/plugin-hooks.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const assert_1 = __importDefault(require("assert"));
|
|
7
|
+
const generateMock_1 = require("../testing/generateMock");
|
|
8
|
+
const immutable_1 = __importDefault(require("immutable"));
|
|
9
|
+
const generatePages_1 = __importDefault(require("../generatePages"));
|
|
10
|
+
const plugin_1 = __importDefault(require("../../models/plugin"));
|
|
11
|
+
const json_1 = __importDefault(require("../json"));
|
|
12
|
+
const createOutputWithPlugin = async ({ Generator, plugin, files }) => {
|
|
13
|
+
const { output } = await (0, generateMock_1.generateMockBook)(Generator, files);
|
|
14
|
+
// add plugin
|
|
15
|
+
return output.merge({
|
|
16
|
+
plugins: [plugin],
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
describe("plugin-hooks", function () {
|
|
20
|
+
it(`should be called "page" and "page:before" when generate each pages`, async () => {
|
|
21
|
+
let onPageBeforeCount = 0;
|
|
22
|
+
let onPageCount = 0;
|
|
23
|
+
const plugin = new plugin_1.default({
|
|
24
|
+
name: "testplugin",
|
|
25
|
+
version: "*",
|
|
26
|
+
path: "test.js",
|
|
27
|
+
package: immutable_1.default.fromJS({
|
|
28
|
+
name: "testplugin",
|
|
29
|
+
}),
|
|
30
|
+
content: immutable_1.default.fromJS({
|
|
31
|
+
hooks: {
|
|
32
|
+
"page:before": function (page) {
|
|
33
|
+
onPageBeforeCount++;
|
|
34
|
+
return page;
|
|
35
|
+
},
|
|
36
|
+
page: function (page) {
|
|
37
|
+
onPageCount++;
|
|
38
|
+
return page;
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
});
|
|
43
|
+
const output = await createOutputWithPlugin({
|
|
44
|
+
Generator: json_1.default,
|
|
45
|
+
plugin,
|
|
46
|
+
files: {
|
|
47
|
+
"README.md": "Hello World",
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
// call twice
|
|
51
|
+
await (0, generatePages_1.default)(json_1.default, output);
|
|
52
|
+
await (0, generatePages_1.default)(json_1.default, output);
|
|
53
|
+
// assert
|
|
54
|
+
assert_1.default.strictEqual(onPageBeforeCount, 2);
|
|
55
|
+
assert_1.default.strictEqual(onPageCount, 2);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"website.d.ts","sourceRoot":"","sources":["../../../src/output/__tests__/website.ts"],"names":[],"mappings":""}
|