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,40 @@
|
|
|
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 createTemplateEngine_1 = __importDefault(require("../createTemplateEngine"));
|
|
7
|
+
const createMock_1 = __importDefault(require("../../testing/createMock"));
|
|
8
|
+
const prepareI18n_1 = __importDefault(require("../prepareI18n"));
|
|
9
|
+
const __1 = __importDefault(require("../"));
|
|
10
|
+
describe("i18n", () => {
|
|
11
|
+
test("should correctly use english as default language", () => {
|
|
12
|
+
// @ts-expect-error
|
|
13
|
+
return (0, createMock_1.default)(__1.default, {
|
|
14
|
+
"README.md": "Hello World"
|
|
15
|
+
})
|
|
16
|
+
.then((output) => {
|
|
17
|
+
return (0, prepareI18n_1.default)(output);
|
|
18
|
+
})
|
|
19
|
+
.then((output) => {
|
|
20
|
+
const engine = (0, createTemplateEngine_1.default)(output, "README.md");
|
|
21
|
+
const t = engine.getFilters().get("t");
|
|
22
|
+
expect(t("SUMMARY_INTRODUCTION")).toEqual("Introduction");
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
test("should correctly use language from book.json", () => {
|
|
26
|
+
// @ts-expect-error
|
|
27
|
+
return (0, createMock_1.default)(__1.default, {
|
|
28
|
+
"README.md": "Hello World",
|
|
29
|
+
"book.json": JSON.stringify({ language: "fr" })
|
|
30
|
+
})
|
|
31
|
+
.then((output) => {
|
|
32
|
+
return (0, prepareI18n_1.default)(output);
|
|
33
|
+
})
|
|
34
|
+
.then((output) => {
|
|
35
|
+
const engine = (0, createTemplateEngine_1.default)(output, "README.md");
|
|
36
|
+
const t = engine.getFilters().get("t");
|
|
37
|
+
expect(t("GITBOOK_LINK")).toEqual("Publié avec HonKit");
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listAssets.d.ts","sourceRoot":"","sources":["../../../src/parse/__tests__/listAssets.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,63 @@
|
|
|
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 mock_1 = __importDefault(require("../../fs/mock"));
|
|
8
|
+
const book_1 = __importDefault(require("../../models/book"));
|
|
9
|
+
const listAssets_1 = __importDefault(require("../listAssets"));
|
|
10
|
+
const parseGlossary_1 = __importDefault(require("../parseGlossary"));
|
|
11
|
+
const parseBook_1 = __importDefault(require("../parseBook"));
|
|
12
|
+
describe("listAssets", () => {
|
|
13
|
+
test("should not list glossary as asset", () => {
|
|
14
|
+
const fs = (0, mock_1.default)({
|
|
15
|
+
"GLOSSARY.md": "# Glossary\n\n## Hello\nDescription for hello",
|
|
16
|
+
"assetFile.js": "",
|
|
17
|
+
assets: {
|
|
18
|
+
"file.js": "",
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
const book = book_1.default.createForFS(fs);
|
|
22
|
+
return (0, parseGlossary_1.default)(book)
|
|
23
|
+
.then((resultBook) => {
|
|
24
|
+
return (0, listAssets_1.default)(resultBook, immutable_1.default.Map());
|
|
25
|
+
})
|
|
26
|
+
.then((assets) => {
|
|
27
|
+
expect(assets.size).toBe(2);
|
|
28
|
+
expect(assets.includes("assetFile.js"));
|
|
29
|
+
expect(assets.includes("assets/file.js"));
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
test("should not list README.md of pages as asset", () => {
|
|
33
|
+
const fs = (0, mock_1.default)({
|
|
34
|
+
"book.json": JSON.stringify({
|
|
35
|
+
root: "./test",
|
|
36
|
+
}),
|
|
37
|
+
test: {
|
|
38
|
+
"SUMMARY.md": `# Summary
|
|
39
|
+
|
|
40
|
+
* [top](README.md)
|
|
41
|
+
* [sub](sub/README-sub.md)
|
|
42
|
+
* [subsub](sub/sub/README-subsub.md)
|
|
43
|
+
|
|
44
|
+
`,
|
|
45
|
+
"README.md": "top",
|
|
46
|
+
"sub/README-sub.md": "in sub",
|
|
47
|
+
"sub/sub/README-subsub.md": "in sub/sub",
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
const pages = new Map()
|
|
51
|
+
.set("README.md", "top")
|
|
52
|
+
.set("sub/README-sub.md", "sub")
|
|
53
|
+
.set("sub/sub/README-subsub.md", "sub/sub");
|
|
54
|
+
const book = book_1.default.createForFS(fs);
|
|
55
|
+
return (0, parseBook_1.default)(book)
|
|
56
|
+
.then((resultBook) => {
|
|
57
|
+
return (0, listAssets_1.default)(resultBook, pages);
|
|
58
|
+
})
|
|
59
|
+
.then((assets) => {
|
|
60
|
+
expect(assets.size).toBe(0);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseBook.d.ts","sourceRoot":"","sources":["../../../src/parse/__tests__/parseBook.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,77 @@
|
|
|
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 book_1 = __importDefault(require("../../models/book"));
|
|
7
|
+
const mock_1 = __importDefault(require("../../fs/mock"));
|
|
8
|
+
const parseBook_1 = __importDefault(require("../parseBook"));
|
|
9
|
+
describe("parseBook", () => {
|
|
10
|
+
test("should parse multilingual book", () => {
|
|
11
|
+
const fs = (0, mock_1.default)({
|
|
12
|
+
"LANGS.md": "# Languages\n\n* [en](en)\n* [fr](fr)",
|
|
13
|
+
en: {
|
|
14
|
+
"README.md": "Hello",
|
|
15
|
+
},
|
|
16
|
+
fr: {
|
|
17
|
+
"README.md": "Bonjour",
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
const book = book_1.default.createForFS(fs);
|
|
21
|
+
return (0, parseBook_1.default)(book).then((resultBook) => {
|
|
22
|
+
const languages = resultBook.getLanguages();
|
|
23
|
+
const books = resultBook.getBooks();
|
|
24
|
+
expect(resultBook.isMultilingual()).toBe(true);
|
|
25
|
+
expect(languages.getList().size).toBe(2);
|
|
26
|
+
expect(books.size).toBe(2);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
test("should extend configuration for multilingual book", () => {
|
|
30
|
+
const fs = (0, mock_1.default)({
|
|
31
|
+
"LANGS.md": "# Languages\n\n* [en](en)\n* [fr](fr)",
|
|
32
|
+
"book.json": '{ "title": "Test", "author": "HonKit" }',
|
|
33
|
+
en: {
|
|
34
|
+
"README.md": "Hello",
|
|
35
|
+
"book.json": '{ "title": "Test EN" }',
|
|
36
|
+
},
|
|
37
|
+
fr: {
|
|
38
|
+
"README.md": "Bonjour",
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
const book = book_1.default.createForFS(fs);
|
|
42
|
+
return (0, parseBook_1.default)(book).then((resultBook) => {
|
|
43
|
+
const books = resultBook.getBooks();
|
|
44
|
+
expect(resultBook.isMultilingual()).toBe(true);
|
|
45
|
+
expect(books.size).toBe(2);
|
|
46
|
+
const en = books.get("en");
|
|
47
|
+
const fr = books.get("fr");
|
|
48
|
+
const enConfig = en.getConfig();
|
|
49
|
+
const frConfig = fr.getConfig();
|
|
50
|
+
expect(enConfig.getValue("title")).toBe("Test EN");
|
|
51
|
+
expect(enConfig.getValue("author")).toBe("HonKit");
|
|
52
|
+
expect(frConfig.getValue("title")).toBe("Test");
|
|
53
|
+
expect(frConfig.getValue("author")).toBe("HonKit");
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
test("should parse book in a directory", () => {
|
|
57
|
+
const fs = (0, mock_1.default)({
|
|
58
|
+
"book.json": JSON.stringify({
|
|
59
|
+
root: "./test",
|
|
60
|
+
}),
|
|
61
|
+
test: {
|
|
62
|
+
"README.md": "Hello World",
|
|
63
|
+
"SUMMARY.md": "# Summary\n\n* [Page](page.md)\n",
|
|
64
|
+
"page.md": "Page",
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
const book = book_1.default.createForFS(fs);
|
|
68
|
+
return (0, parseBook_1.default)(book).then((resultBook) => {
|
|
69
|
+
const readme = resultBook.getReadme();
|
|
70
|
+
const summary = resultBook.getSummary();
|
|
71
|
+
const articles = summary.getArticlesAsList();
|
|
72
|
+
expect(summary.getFile().exists()).toBe(true);
|
|
73
|
+
expect(readme.getFile().exists()).toBe(true);
|
|
74
|
+
expect(articles.size).toBe(2);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseGlossary.d.ts","sourceRoot":"","sources":["../../../src/parse/__tests__/parseGlossary.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
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 book_1 = __importDefault(require("../../models/book"));
|
|
7
|
+
const mock_1 = __importDefault(require("../../fs/mock"));
|
|
8
|
+
const parseGlossary_1 = __importDefault(require("../parseGlossary"));
|
|
9
|
+
describe("parseGlossary", () => {
|
|
10
|
+
test("should parse glossary if exists", () => {
|
|
11
|
+
const fs = (0, mock_1.default)({
|
|
12
|
+
"GLOSSARY.md": "# Glossary\n\n## Hello\nDescription for hello",
|
|
13
|
+
});
|
|
14
|
+
const book = book_1.default.createForFS(fs);
|
|
15
|
+
return (0, parseGlossary_1.default)(book).then((resultBook) => {
|
|
16
|
+
const glossary = resultBook.getGlossary();
|
|
17
|
+
const file = glossary.getFile();
|
|
18
|
+
const entries = glossary.getEntries();
|
|
19
|
+
expect(file.exists()).toBeTruthy();
|
|
20
|
+
expect(entries.size).toBe(1);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
test("should not fail if doesn't exist", () => {
|
|
24
|
+
const fs = (0, mock_1.default)({});
|
|
25
|
+
const book = book_1.default.createForFS(fs);
|
|
26
|
+
return (0, parseGlossary_1.default)(book).then((resultBook) => {
|
|
27
|
+
const glossary = resultBook.getGlossary();
|
|
28
|
+
const file = glossary.getFile();
|
|
29
|
+
expect(file.exists()).toBeFalsy();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseIgnore.d.ts","sourceRoot":"","sources":["../../../src/parse/__tests__/parseIgnore.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,37 @@
|
|
|
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 book_1 = __importDefault(require("../../models/book"));
|
|
7
|
+
const mock_1 = __importDefault(require("../../fs/mock"));
|
|
8
|
+
const parseIgnore_1 = __importDefault(require("../parseIgnore"));
|
|
9
|
+
describe("parseIgnore", () => {
|
|
10
|
+
const fs = (0, mock_1.default)({
|
|
11
|
+
".ignore": "test-1.js",
|
|
12
|
+
".gitignore": "test-2.js\ntest-3.js",
|
|
13
|
+
".bookignore": "!test-3.js",
|
|
14
|
+
"test-1.js": "1",
|
|
15
|
+
"test-2.js": "2",
|
|
16
|
+
"test-3.js": "3",
|
|
17
|
+
});
|
|
18
|
+
function getBook() {
|
|
19
|
+
const book = book_1.default.createForFS(fs);
|
|
20
|
+
return (0, parseIgnore_1.default)(book);
|
|
21
|
+
}
|
|
22
|
+
test("should load rules from .ignore", () => {
|
|
23
|
+
return getBook().then((book) => {
|
|
24
|
+
expect(book.isFileIgnored("test-1.js")).toBeTruthy();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
test("should load rules from .gitignore", () => {
|
|
28
|
+
return getBook().then((book) => {
|
|
29
|
+
expect(book.isFileIgnored("test-2.js")).toBeTruthy();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
test("should load rules from .bookignore", () => {
|
|
33
|
+
return getBook().then((book) => {
|
|
34
|
+
expect(book.isFileIgnored("test-3.js")).toBeFalsy();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parsePageFromString.d.ts","sourceRoot":"","sources":["../../../src/parse/__tests__/parsePageFromString.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,34 @@
|
|
|
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 parsePageFromString_1 = __importDefault(require("../parsePageFromString"));
|
|
7
|
+
const page_1 = __importDefault(require("../../models/page"));
|
|
8
|
+
describe("parsePageFromString", () => {
|
|
9
|
+
const page = new page_1.default();
|
|
10
|
+
test("should parse YAML frontmatter", () => {
|
|
11
|
+
const CONTENT = "---\nhello: true\nworld: \"cool\"\n---\n# Hello World\n";
|
|
12
|
+
const newPage = (0, parsePageFromString_1.default)(page, CONTENT);
|
|
13
|
+
expect(newPage.getDir()).toBe("ltr");
|
|
14
|
+
expect(newPage.getContent()).toBe("# Hello World\n");
|
|
15
|
+
const attrs = newPage.getAttributes();
|
|
16
|
+
expect(attrs.size).toBe(2);
|
|
17
|
+
expect(attrs.get("hello")).toBe(true);
|
|
18
|
+
expect(attrs.get("world")).toBe("cool");
|
|
19
|
+
});
|
|
20
|
+
test("should parse text direction (english)", () => {
|
|
21
|
+
const CONTENT = "Hello World";
|
|
22
|
+
const newPage = (0, parsePageFromString_1.default)(page, CONTENT);
|
|
23
|
+
expect(newPage.getDir()).toBe("ltr");
|
|
24
|
+
expect(newPage.getContent()).toBe("Hello World");
|
|
25
|
+
expect(newPage.getAttributes().size).toBe(0);
|
|
26
|
+
});
|
|
27
|
+
test("should parse text direction (arab)", () => {
|
|
28
|
+
const CONTENT = "مرحبا بالعالم";
|
|
29
|
+
const newPage = (0, parsePageFromString_1.default)(page, CONTENT);
|
|
30
|
+
expect(newPage.getDir()).toBe("rtl");
|
|
31
|
+
expect(newPage.getContent()).toBe("مرحبا بالعالم");
|
|
32
|
+
expect(newPage.getAttributes().size).toBe(0);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseReadme.d.ts","sourceRoot":"","sources":["../../../src/parse/__tests__/parseReadme.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
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 promise_1 = __importDefault(require("../../utils/promise"));
|
|
7
|
+
const mock_1 = __importDefault(require("../../fs/mock"));
|
|
8
|
+
const book_1 = __importDefault(require("../../models/book"));
|
|
9
|
+
const parseReadme_1 = __importDefault(require("../parseReadme"));
|
|
10
|
+
describe("parseReadme", () => {
|
|
11
|
+
test("should parse summary if exists", () => {
|
|
12
|
+
const fs = (0, mock_1.default)({
|
|
13
|
+
"README.md": "# Hello\n\nAnd here is the description.",
|
|
14
|
+
});
|
|
15
|
+
const book = book_1.default.createForFS(fs);
|
|
16
|
+
return (0, parseReadme_1.default)(book).then((resultBook) => {
|
|
17
|
+
const readme = resultBook.getReadme();
|
|
18
|
+
const file = readme.getFile();
|
|
19
|
+
expect(file.exists()).toBeTruthy();
|
|
20
|
+
expect(readme.getTitle()).toBe("Hello");
|
|
21
|
+
expect(readme.getDescription()).toBe("And here is the description.");
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
test("should fail if doesn't exist", () => {
|
|
25
|
+
const fs = (0, mock_1.default)({});
|
|
26
|
+
const book = book_1.default.createForFS(fs);
|
|
27
|
+
return (0, parseReadme_1.default)(book).then((resultBook) => {
|
|
28
|
+
throw new Error("It should have fail");
|
|
29
|
+
}, () => {
|
|
30
|
+
return (0, promise_1.default)();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parseSummary.d.ts","sourceRoot":"","sources":["../../../src/parse/__tests__/parseSummary.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,30 @@
|
|
|
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 book_1 = __importDefault(require("../../models/book"));
|
|
7
|
+
const mock_1 = __importDefault(require("../../fs/mock"));
|
|
8
|
+
const parseSummary_1 = __importDefault(require("../parseSummary"));
|
|
9
|
+
describe("parseSummary", () => {
|
|
10
|
+
test("should parse summary if exists", () => {
|
|
11
|
+
const fs = (0, mock_1.default)({
|
|
12
|
+
"SUMMARY.md": "# Summary\n\n* [Hello](hello.md)",
|
|
13
|
+
});
|
|
14
|
+
const book = book_1.default.createForFS(fs);
|
|
15
|
+
return (0, parseSummary_1.default)(book).then((resultBook) => {
|
|
16
|
+
const summary = resultBook.getSummary();
|
|
17
|
+
const file = summary.getFile();
|
|
18
|
+
expect(file.exists()).toBeTruthy();
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
test("should not fail if doesn't exist", () => {
|
|
22
|
+
const fs = (0, mock_1.default)({});
|
|
23
|
+
const book = book_1.default.createForFS(fs);
|
|
24
|
+
return (0, parseSummary_1.default)(book).then((resultBook) => {
|
|
25
|
+
const summary = resultBook.getSummary();
|
|
26
|
+
const file = summary.getFile();
|
|
27
|
+
expect(file.exists()).toBeFalsy();
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listDependencies.d.ts","sourceRoot":"","sources":["../../../src/plugins/__tests__/listDependencies.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
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 pluginDependency_1 = __importDefault(require("../../models/pluginDependency"));
|
|
7
|
+
const listDependencies_1 = __importDefault(require("../listDependencies"));
|
|
8
|
+
const toNames_1 = __importDefault(require("../toNames"));
|
|
9
|
+
describe("listDependencies", () => {
|
|
10
|
+
test("must list default", () => {
|
|
11
|
+
const deps = pluginDependency_1.default.listFromString("ga,great");
|
|
12
|
+
const plugins = (0, listDependencies_1.default)(deps);
|
|
13
|
+
const names = (0, toNames_1.default)(plugins);
|
|
14
|
+
expect(names).toEqual(["ga", "great", "highlight", "search", "lunr", "fontsettings", "theme-default"]);
|
|
15
|
+
});
|
|
16
|
+
test("must list from array with -", () => {
|
|
17
|
+
const deps = pluginDependency_1.default.listFromString("ga,-great");
|
|
18
|
+
const plugins = (0, listDependencies_1.default)(deps);
|
|
19
|
+
const names = (0, toNames_1.default)(plugins);
|
|
20
|
+
expect(names).toEqual(["ga", "highlight", "search", "lunr", "fontsettings", "theme-default"]);
|
|
21
|
+
});
|
|
22
|
+
test("must remove default plugins using -", () => {
|
|
23
|
+
const deps = pluginDependency_1.default.listFromString("ga,-search");
|
|
24
|
+
const plugins = (0, listDependencies_1.default)(deps);
|
|
25
|
+
const names = (0, toNames_1.default)(plugins);
|
|
26
|
+
expect(names).toEqual(["ga", "highlight", "lunr", "fontsettings", "theme-default"]);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortDependencies.d.ts","sourceRoot":"","sources":["../../../src/plugins/__tests__/sortDependencies.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
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 pluginDependency_1 = __importDefault(require("../../models/pluginDependency"));
|
|
7
|
+
const sortDependencies_1 = __importDefault(require("../sortDependencies"));
|
|
8
|
+
const toNames_1 = __importDefault(require("../toNames"));
|
|
9
|
+
describe("sortDependencies", () => {
|
|
10
|
+
test("must load themes after plugins", () => {
|
|
11
|
+
const allPlugins = pluginDependency_1.default.listFromArray(["hello", "theme-test", "world"]);
|
|
12
|
+
const sorted = (0, sortDependencies_1.default)(allPlugins);
|
|
13
|
+
const names = (0, toNames_1.default)(sorted);
|
|
14
|
+
expect(names).toEqual(["hello", "world", "theme-test"]);
|
|
15
|
+
});
|
|
16
|
+
test("must keep order of themes", () => {
|
|
17
|
+
const allPlugins = pluginDependency_1.default.listFromArray([
|
|
18
|
+
"theme-test",
|
|
19
|
+
"theme-test1",
|
|
20
|
+
"hello",
|
|
21
|
+
"theme-test2",
|
|
22
|
+
"world",
|
|
23
|
+
]);
|
|
24
|
+
const sorted = (0, sortDependencies_1.default)(allPlugins);
|
|
25
|
+
const names = (0, toNames_1.default)(sorted);
|
|
26
|
+
expect(names).toEqual(["hello", "world", "theme-test", "theme-test1", "theme-test2"]);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validatePlugin.d.ts","sourceRoot":"","sources":["../../../src/plugins/__tests__/validatePlugin.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,99 @@
|
|
|
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 promise_1 = __importDefault(require("../../utils/promise"));
|
|
8
|
+
const plugin_1 = __importDefault(require("../../models/plugin"));
|
|
9
|
+
const validatePlugin_1 = __importDefault(require("../validatePlugin"));
|
|
10
|
+
describe("validatePlugin", () => {
|
|
11
|
+
test("must not validate a not loaded plugin", () => {
|
|
12
|
+
const plugin = plugin_1.default.createFromString("test");
|
|
13
|
+
return (0, validatePlugin_1.default)(plugin).then(() => {
|
|
14
|
+
throw new Error("Should not be validate");
|
|
15
|
+
}, (err) => {
|
|
16
|
+
return (0, promise_1.default)();
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
test("alpha plugin can loaded plugin", () => {
|
|
20
|
+
const testPkgRequireAlphaVersion = {
|
|
21
|
+
title: "Disqus",
|
|
22
|
+
name: "gitbook-plugin-disqus",
|
|
23
|
+
description: "Disqus comments thread in the footer of your pages",
|
|
24
|
+
icon: "./icon.png",
|
|
25
|
+
main: "index.js",
|
|
26
|
+
browser: "./_assets/plugin.js",
|
|
27
|
+
version: "1.0.1",
|
|
28
|
+
engines: {
|
|
29
|
+
gitbook: ">=4.0.0-alpha",
|
|
30
|
+
},
|
|
31
|
+
dependencies: {
|
|
32
|
+
react: "^15.3.2",
|
|
33
|
+
"react-disqus-thread": "^0.4.0",
|
|
34
|
+
},
|
|
35
|
+
devDependencies: {
|
|
36
|
+
"gitbook-plugin": "^4.0.0-alpha.0",
|
|
37
|
+
eslint: "3.7.1",
|
|
38
|
+
"eslint-config-gitbook": "1.4.0",
|
|
39
|
+
},
|
|
40
|
+
homepage: "https://github.com/GitbookIO/plugin-disqus",
|
|
41
|
+
repository: {
|
|
42
|
+
type: "git",
|
|
43
|
+
url: "https://github.com/GitbookIO/plugin-disqus.git",
|
|
44
|
+
},
|
|
45
|
+
license: "Apache-2.0",
|
|
46
|
+
bugs: {
|
|
47
|
+
url: "https://github.com/GitbookIO/plugin-disqus/issues",
|
|
48
|
+
},
|
|
49
|
+
keywords: ["gitbook:social"],
|
|
50
|
+
scripts: {
|
|
51
|
+
"build-js": "gitbook-plugin build ./src/index.js ./_assets/plugin.js",
|
|
52
|
+
prepublish: "npm run build-js",
|
|
53
|
+
},
|
|
54
|
+
gitbook: {
|
|
55
|
+
properties: {
|
|
56
|
+
shortName: {
|
|
57
|
+
type: "string",
|
|
58
|
+
title: "Website Shortname",
|
|
59
|
+
description: "Unique identifier for your website as registered on Disqus",
|
|
60
|
+
required: true,
|
|
61
|
+
},
|
|
62
|
+
useIdentifier: {
|
|
63
|
+
type: "boolean",
|
|
64
|
+
title: "Pass page identifier option to Disqus",
|
|
65
|
+
default: false,
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
page: {
|
|
69
|
+
title: "Disqus configuration for this page",
|
|
70
|
+
properties: {
|
|
71
|
+
disqus: {
|
|
72
|
+
type: "object",
|
|
73
|
+
properties: {
|
|
74
|
+
enabled: {
|
|
75
|
+
type: "boolean",
|
|
76
|
+
title: "Enable Disqus comments for this page.",
|
|
77
|
+
default: true,
|
|
78
|
+
},
|
|
79
|
+
identifier: {
|
|
80
|
+
type: "string",
|
|
81
|
+
title: "Identifier for this page.",
|
|
82
|
+
description: "Tells the Disqus service how to identify the current page",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
};
|
|
90
|
+
const plugin = new plugin_1.default({
|
|
91
|
+
name: "test",
|
|
92
|
+
version: "4.0.0",
|
|
93
|
+
path: "/",
|
|
94
|
+
package: immutable_1.default.fromJS(testPkgRequireAlphaVersion),
|
|
95
|
+
content: immutable_1.default.fromJS({}),
|
|
96
|
+
});
|
|
97
|
+
return (0, validatePlugin_1.default)(plugin);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conrefsLoader.d.ts","sourceRoot":"","sources":["../../../src/templating/__tests__/conrefsLoader.ts"],"names":[],"mappings":""}
|