This commit is contained in:
2025-05-12 05:38:44 +09:00
parent dced21c3f8
commit 6d78bfa46e
8120 changed files with 1161564 additions and 0 deletions

View File

@ -0,0 +1,10 @@
/**
Find a file parsable (Markdown or AsciiDoc) in a book
@param {Book} book
@param {string} filename
@return {Promise<File | Undefined>}
*/
declare function findParsableFile(book: any, filename: any): any;
export default findParsableFile;
//# sourceMappingURL=findParsableFile.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"findParsableFile.d.ts","sourceRoot":"","sources":["../../src/parse/findParsableFile.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AAEH,iBAAS,gBAAgB,CAAC,IAAI,KAAA,EAAE,QAAQ,KAAA,OAoBvC;AAED,eAAe,gBAAgB,CAAC"}

33
book/node_modules/honkit/lib/parse/findParsableFile.js generated vendored Normal file
View File

@ -0,0 +1,33 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = __importDefault(require("path"));
const promise_1 = __importDefault(require("../utils/promise"));
const parsers_1 = __importDefault(require("../parsers"));
/**
Find a file parsable (Markdown or AsciiDoc) in a book
@param {Book} book
@param {string} filename
@return {Promise<File | Undefined>}
*/
function findParsableFile(book, filename) {
const fs = book.getContentFS();
const ext = path_1.default.extname(filename);
const basename = path_1.default.basename(filename, ext);
const basedir = path_1.default.dirname(filename);
// Ordered list of extensions to test
const exts = parsers_1.default.extensions;
return promise_1.default.some(exts, (ext) => {
const filepath = basename + ext;
return fs.findFile(basedir, filepath).then((found) => {
if (!found || book.isContentFileIgnored(found)) {
return undefined;
}
return fs.statFile(found);
});
});
}
exports.default = findParsableFile;

28
book/node_modules/honkit/lib/parse/index.d.ts generated vendored Normal file
View File

@ -0,0 +1,28 @@
import parseBook0 from "./parseBook";
import parseSummary0 from "./parseSummary";
import parseGlossary0 from "./parseGlossary";
import parseReadme0 from "./parseReadme";
import parseConfig0 from "./parseConfig";
import parsePagesList0 from "./parsePagesList";
import parseIgnore0 from "./parseIgnore";
import listAssets0 from "./listAssets";
import parseLanguages0 from "./parseLanguages";
import parsePage0 from "./parsePage";
import parsePageFromString0 from "./parsePageFromString";
import lookupStructureFile0 from "./lookupStructureFile";
declare const _default: {
parseBook: typeof parseBook0;
parseSummary: typeof parseSummary0;
parseGlossary: typeof parseGlossary0;
parseReadme: typeof parseReadme0;
parseConfig: typeof parseConfig0;
parsePagesList: typeof parsePagesList0;
parseIgnore: typeof parseIgnore0;
listAssets: typeof listAssets0;
parseLanguages: typeof parseLanguages0;
parsePage: typeof parsePage0;
parsePageFromString: typeof parsePageFromString0;
lookupStructureFile: typeof lookupStructureFile0;
};
export default _default;
//# sourceMappingURL=index.d.ts.map

1
book/node_modules/honkit/lib/parse/index.d.ts.map generated vendored Normal file
View File

@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parse/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,aAAa,MAAM,gBAAgB,CAAC;AAC3C,OAAO,cAAc,MAAM,iBAAiB,CAAC;AAC7C,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,eAAe,MAAM,kBAAkB,CAAC;AAC/C,OAAO,YAAY,MAAM,eAAe,CAAC;AACzC,OAAO,WAAW,MAAM,cAAc,CAAC;AACvC,OAAO,eAAe,MAAM,kBAAkB,CAAC;AAC/C,OAAO,UAAU,MAAM,aAAa,CAAC;AACrC,OAAO,oBAAoB,MAAM,uBAAuB,CAAC;AACzD,OAAO,oBAAoB,MAAM,uBAAuB,CAAC;;;;;;;;;;;;;;;AAEzD,wBAaE"}

31
book/node_modules/honkit/lib/parse/index.js generated vendored Normal file
View File

@ -0,0 +1,31 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const parseBook_1 = __importDefault(require("./parseBook"));
const parseSummary_1 = __importDefault(require("./parseSummary"));
const parseGlossary_1 = __importDefault(require("./parseGlossary"));
const parseReadme_1 = __importDefault(require("./parseReadme"));
const parseConfig_1 = __importDefault(require("./parseConfig"));
const parsePagesList_1 = __importDefault(require("./parsePagesList"));
const parseIgnore_1 = __importDefault(require("./parseIgnore"));
const listAssets_1 = __importDefault(require("./listAssets"));
const parseLanguages_1 = __importDefault(require("./parseLanguages"));
const parsePage_1 = __importDefault(require("./parsePage"));
const parsePageFromString_1 = __importDefault(require("./parsePageFromString"));
const lookupStructureFile_1 = __importDefault(require("./lookupStructureFile"));
exports.default = {
parseBook: parseBook_1.default,
parseSummary: parseSummary_1.default,
parseGlossary: parseGlossary_1.default,
parseReadme: parseReadme_1.default,
parseConfig: parseConfig_1.default,
parsePagesList: parsePagesList_1.default,
parseIgnore: parseIgnore_1.default,
listAssets: listAssets_1.default,
parseLanguages: parseLanguages_1.default,
parsePage: parsePage_1.default,
parsePageFromString: parsePageFromString_1.default,
lookupStructureFile: lookupStructureFile_1.default
};

11
book/node_modules/honkit/lib/parse/listAssets.d.ts generated vendored Normal file
View File

@ -0,0 +1,11 @@
/**
List all assets in a book
Assets are file not ignored and not a page
@param {Book} book
@param {List<String>} pages
@param
*/
declare function listAssets(book: any, pages: any): any;
export default listAssets;
//# sourceMappingURL=listAssets.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"listAssets.d.ts","sourceRoot":"","sources":["../../src/parse/listAssets.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,iBAAS,UAAU,CAAC,IAAI,KAAA,EAAE,KAAK,KAAA,OA4B9B;AAED,eAAe,UAAU,CAAC"}

36
book/node_modules/honkit/lib/parse/listAssets.js generated vendored Normal file
View File

@ -0,0 +1,36 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const timing_1 = __importDefault(require("../utils/timing"));
/**
List all assets in a book
Assets are file not ignored and not a page
@param {Book} book
@param {List<String>} pages
@param
*/
function listAssets(book, pages) {
const fs = book.getContentFS();
const summary = book.getSummary();
const summaryFile = summary.getFile().getPath();
const glossary = book.getGlossary();
const glossaryFile = glossary.getFile().getPath();
const langs = book.getLanguages();
const langsFile = langs.getFile().getPath();
const config = book.getConfig();
const configFile = config.getFile().getPath();
function filterFile(rawFile) {
const file = rawFile.replace(/\\/g, "/");
return !(file === summaryFile ||
file === glossaryFile ||
file === langsFile ||
file === configFile ||
book.isContentFileIgnored(file) ||
pages.has(file));
}
return timing_1.default.measure("parse.listAssets", fs.listAllFiles(".", filterFile));
}
exports.default = listAssets;

View File

@ -0,0 +1,12 @@
/**
Lookup a structure file (ex: SUMMARY.md, GLOSSARY.md) in a book. Uses
book's config to find it.
@param {Book} book
@param {string} type: one of ["glossary", "readme", "summary", "langs"]
@return {Promise<File | Undefined>} The path of the file found, relative
to the book content root.
*/
declare function lookupStructureFile(book: any, type: any): any;
export default lookupStructureFile;
//# sourceMappingURL=lookupStructureFile.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"lookupStructureFile.d.ts","sourceRoot":"","sources":["../../src/parse/lookupStructureFile.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,iBAAS,mBAAmB,CAAC,IAAI,KAAA,EAAE,IAAI,KAAA,OAMtC;AAED,eAAe,mBAAmB,CAAC"}

View File

@ -0,0 +1,21 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const findParsableFile_1 = __importDefault(require("./findParsableFile"));
/**
Lookup a structure file (ex: SUMMARY.md, GLOSSARY.md) in a book. Uses
book's config to find it.
@param {Book} book
@param {string} type: one of ["glossary", "readme", "summary", "langs"]
@return {Promise<File | Undefined>} The path of the file found, relative
to the book content root.
*/
function lookupStructureFile(book, type) {
const config = book.getConfig();
const fileToSearch = config.getValue(["structure", type]);
return (0, findParsableFile_1.default)(book, fileToSearch);
}
exports.default = lookupStructureFile;

9
book/node_modules/honkit/lib/parse/parseBook.d.ts generated vendored Normal file
View File

@ -0,0 +1,9 @@
/**
Parse a whole book from a filesystem
@param {Book} book
@return {Promise<Book>}
*/
declare function parseBook(book: any): any;
export default parseBook;
//# sourceMappingURL=parseBook.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"parseBook.d.ts","sourceRoot":"","sources":["../../src/parse/parseBook.ts"],"names":[],"mappings":"AAqDA;;;;;GAKG;AAEH,iBAAS,SAAS,CAAC,IAAI,KAAA,OAgBtB;AAED,eAAe,SAAS,CAAC"}

68
book/node_modules/honkit/lib/parse/parseBook.js generated vendored Normal file
View File

@ -0,0 +1,68 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const promise_1 = __importDefault(require("../utils/promise"));
const timing_1 = __importDefault(require("../utils/timing"));
const book_1 = __importDefault(require("../models/book"));
const parseIgnore_1 = __importDefault(require("./parseIgnore"));
const parseConfig_1 = __importDefault(require("./parseConfig"));
const parseGlossary_1 = __importDefault(require("./parseGlossary"));
const parseSummary_1 = __importDefault(require("./parseSummary"));
const parseReadme_1 = __importDefault(require("./parseReadme"));
const parseLanguages_1 = __importDefault(require("./parseLanguages"));
/**
Parse content of a book
@param {Book} book
@return {Promise<Book>}
*/
function parseBookContent(book) {
return (0, promise_1.default)(book).then(parseReadme_1.default).then(parseSummary_1.default).then(parseGlossary_1.default);
}
/**
Parse a multilingual book
@param {Book} book
@return {Promise<Book>}
*/
function parseMultilingualBook(book) {
const languages = book.getLanguages();
const langList = languages.getList();
return promise_1.default.reduce(langList, (currentBook, lang) => {
const langID = lang.getID();
const child = book_1.default.createFromParent(currentBook, langID);
let ignore = currentBook.getIgnore();
return (0, promise_1.default)(child)
.then(parseConfig_1.default)
.then(parseBookContent)
.then((result) => {
// Ignore content of this book when generating parent book
ignore = ignore.add(`${langID}/**`);
currentBook = currentBook.set("ignore", ignore);
return currentBook.addLanguageBook(langID, result);
});
}, book);
}
/**
Parse a whole book from a filesystem
@param {Book} book
@return {Promise<Book>}
*/
function parseBook(book) {
return timing_1.default.measure("parse.book", (0, promise_1.default)(book)
.then(parseIgnore_1.default)
.then(parseConfig_1.default)
.then(parseLanguages_1.default)
.then((resultBook) => {
if (resultBook.isMultilingual()) {
return parseMultilingualBook(resultBook);
}
else {
return parseBookContent(resultBook);
}
}));
}
exports.default = parseBook;

9
book/node_modules/honkit/lib/parse/parseConfig.d.ts generated vendored Normal file
View File

@ -0,0 +1,9 @@
/**
Parse configuration from "book.json" or "book.js"
@param {Book} book
@return {Promise<Book>}
*/
declare function parseConfig(book: any): any;
export default parseConfig;
//# sourceMappingURL=parseConfig.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"parseConfig.d.ts","sourceRoot":"","sources":["../../src/parse/parseConfig.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AAEH,iBAAS,WAAW,CAAC,IAAI,KAAA,OAuCxB;AAED,eAAe,WAAW,CAAC"}

52
book/node_modules/honkit/lib/parse/parseConfig.js generated vendored Normal file
View File

@ -0,0 +1,52 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const promise_1 = __importDefault(require("../utils/promise"));
const validateConfig_1 = __importDefault(require("./validateConfig"));
const configFiles_1 = __importDefault(require("../constants/configFiles"));
/**
Parse configuration from "book.json" or "book.js"
@param {Book} book
@return {Promise<Book>}
*/
function parseConfig(book) {
const fs = book.getFS();
let config = book.getConfig();
return promise_1.default.some(configFiles_1.default, (filename) => {
// Is this file ignored?
if (book.isFileIgnored(filename)) {
return;
}
// Try loading it
return fs
.loadAsObject(filename)
.then((cfg) => {
return fs.statFile(filename).then((file) => {
return {
file: file,
values: cfg
};
});
})
.fail((err) => {
if (err.code != "MODULE_NOT_FOUND")
throw err;
else
return (0, promise_1.default)(false);
});
}).then((result) => {
let values = result ? result.values : {};
values = (0, validateConfig_1.default)(values);
// Set the file
if (result && result.file) {
config = config.setFile(result.file);
}
// Merge with old values
config = config.mergeValues(values);
return book.setConfig(config);
});
}
exports.default = parseConfig;

View File

@ -0,0 +1,9 @@
/**
Parse glossary
@param {Book} book
@return {Promise<Book>}
*/
declare function parseGlossary(book: any): any;
export default parseGlossary;
//# sourceMappingURL=parseGlossary.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"parseGlossary.d.ts","sourceRoot":"","sources":["../../src/parse/parseGlossary.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AAEH,iBAAS,aAAa,CAAC,IAAI,KAAA,OAa1B;AAED,eAAe,aAAa,CAAC"}

25
book/node_modules/honkit/lib/parse/parseGlossary.js generated vendored Normal file
View File

@ -0,0 +1,25 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const parseStructureFile_1 = __importDefault(require("./parseStructureFile"));
const glossary_1 = __importDefault(require("../models/glossary"));
/**
Parse glossary
@param {Book} book
@return {Promise<Book>}
*/
function parseGlossary(book) {
const logger = book.getLogger();
return (0, parseStructureFile_1.default)(book, "glossary").spread((file, entries) => {
if (!file) {
return book;
}
logger.debug.ln("glossary index file found at", file.getPath());
const glossary = glossary_1.default.createFromEntries(file, entries);
return book.set("glossary", glossary);
});
}
exports.default = parseGlossary;

9
book/node_modules/honkit/lib/parse/parseIgnore.d.ts generated vendored Normal file
View File

@ -0,0 +1,9 @@
/**
Parse ignore files
@param {Book}
@return {Book}
*/
declare function parseIgnore(book: any): any;
export default parseIgnore;
//# sourceMappingURL=parseIgnore.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"parseIgnore.d.ts","sourceRoot":"","sources":["../../src/parse/parseIgnore.ts"],"names":[],"mappings":"AAoBA;;;;;GAKG;AAEH,iBAAS,WAAW,CAAC,IAAI,KAAA,OAsBxB;AAED,eAAe,WAAW,CAAC"}

43
book/node_modules/honkit/lib/parse/parseIgnore.js generated vendored Normal file
View File

@ -0,0 +1,43 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const promise_1 = __importDefault(require("../utils/promise"));
const ignoreFiles_1 = __importDefault(require("../constants/ignoreFiles"));
const DEFAULT_IGNORES = [
// Skip Git stuff
".git/",
// Skip OS X meta data
".DS_Store",
// Skip stuff installed by plugins
"node_modules",
// Skip book outputs
"_book",
// Ignore files in the templates folder
"_layouts"
];
/**
Parse ignore files
@param {Book}
@return {Book}
*/
function parseIgnore(book) {
if (book.isLanguageBook()) {
return promise_1.default.reject(new Error("Ignore files could be parsed for language books"));
}
const fs = book.getFS();
let ignore = book.getIgnore();
ignore = ignore.add(DEFAULT_IGNORES);
return promise_1.default.serie(ignoreFiles_1.default, (filename) => {
return fs.readAsString(filename).then((content) => {
ignore = ignore.add(content.toString().split(/\r?\n/));
}, (err) => {
return (0, promise_1.default)();
});
}).then(() => {
return book.setIgnore(ignore);
});
}
exports.default = parseIgnore;

View File

@ -0,0 +1,9 @@
/**
Parse languages list from book
@param {Book} book
@return {Promise<Book>}
*/
declare function parseLanguages(book: any): any;
export default parseLanguages;
//# sourceMappingURL=parseLanguages.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"parseLanguages.d.ts","sourceRoot":"","sources":["../../src/parse/parseLanguages.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AAEH,iBAAS,cAAc,CAAC,IAAI,KAAA,OAe3B;AAED,eAAe,cAAc,CAAC"}

26
book/node_modules/honkit/lib/parse/parseLanguages.js generated vendored Normal file
View File

@ -0,0 +1,26 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const parseStructureFile_1 = __importDefault(require("./parseStructureFile"));
const languages_1 = __importDefault(require("../models/languages"));
/**
Parse languages list from book
@param {Book} book
@return {Promise<Book>}
*/
function parseLanguages(book) {
const logger = book.getLogger();
return (0, parseStructureFile_1.default)(book, "langs").spread((file, result) => {
if (!file) {
return book;
}
const languages = languages_1.default.createFromList(file, result);
logger.debug.ln("languages index file found at", file.getPath());
logger.info.ln("parsing multilingual book, with", languages.getList().size, "languages");
return book.set("languages", languages);
});
}
exports.default = parseLanguages;

10
book/node_modules/honkit/lib/parse/parsePage.d.ts generated vendored Normal file
View File

@ -0,0 +1,10 @@
/**
* Parse a page, read its content and parse the YAMl header
*
* @param {Book} book
* @param {Page} page
* @return {Promise<Page>}
*/
declare function parsePage(book: any, page: any): any;
export default parsePage;
//# sourceMappingURL=parsePage.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"parsePage.d.ts","sourceRoot":"","sources":["../../src/parse/parsePage.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,iBAAS,SAAS,CAAC,IAAI,KAAA,EAAE,IAAI,KAAA,OAO5B;AAED,eAAe,SAAS,CAAC"}

21
book/node_modules/honkit/lib/parse/parsePage.js generated vendored Normal file
View File

@ -0,0 +1,21 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const parsePageFromString_1 = __importDefault(require("./parsePageFromString"));
/**
* Parse a page, read its content and parse the YAMl header
*
* @param {Book} book
* @param {Page} page
* @return {Promise<Page>}
*/
function parsePage(book, page) {
const fs = book.getContentFS();
const file = page.getFile();
return fs.readAsString(file.getPath()).then((content) => {
return (0, parsePageFromString_1.default)(page, content);
});
}
exports.default = parsePage;

View File

@ -0,0 +1,10 @@
/**
* Parse a page, its content and the YAMl header
*
* @param {Page} page
* @param {string} content
* @return {Page}
*/
declare function parsePageFromString(page: any, content: any): any;
export default parsePageFromString;
//# sourceMappingURL=parsePageFromString.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"parsePageFromString.d.ts","sourceRoot":"","sources":["../../src/parse/parsePageFromString.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AAEH,iBAAS,mBAAmB,CAAC,IAAI,KAAA,EAAE,OAAO,KAAA,OASzC;AAED,eAAe,mBAAmB,CAAC"}

View File

@ -0,0 +1,25 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const immutable_1 = __importDefault(require("immutable"));
const front_matter_1 = __importDefault(require("front-matter"));
const direction_1 = __importDefault(require("direction"));
/**
* Parse a page, its content and the YAMl header
*
* @param {Page} page
* @param {string} content
* @return {Page}
*/
function parsePageFromString(page, content) {
// Parse page YAML
const parsed = (0, front_matter_1.default)(content);
return page.merge({
content: parsed.body,
attributes: immutable_1.default.fromJS(parsed.attributes),
dir: (0, direction_1.default)(parsed.body)
});
}
exports.default = parsePageFromString;

View File

@ -0,0 +1,9 @@
/**
Parse all pages from a book as an OrderedMap
@param {Book} book
@return {Promise<OrderedMap<Page>>}
*/
declare function parsePagesList(book: any): any;
export default parsePagesList;
//# sourceMappingURL=parsePagesList.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"parsePagesList.d.ts","sourceRoot":"","sources":["../../src/parse/parsePagesList.ts"],"names":[],"mappings":"AAmCA;;;;;GAKG;AACH,iBAAS,cAAc,CAAC,IAAI,KAAA,OAmD3B;AAED,eAAe,cAAc,CAAC"}

80
book/node_modules/honkit/lib/parse/parsePagesList.js generated vendored Normal file
View File

@ -0,0 +1,80 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const immutable_1 = __importDefault(require("immutable"));
const timing_1 = __importDefault(require("../utils/timing"));
const page_1 = __importDefault(require("../models/page"));
const walkSummary_1 = __importDefault(require("./walkSummary"));
const parsePage_1 = __importDefault(require("./parsePage"));
/**
Parse a page from a path
@param {Book} book
@param {string} filePath
@return {Page?}
*/
function parseFilePage(book, filePath) {
const fs = book.getContentFS();
return fs
.statFile(filePath)
.then((file) => {
const page = page_1.default.createForFile(file);
return (0, parsePage_1.default)(book, page);
}, (err) => {
// file doesn't exist
return null;
})
.fail((err) => {
const logger = book.getLogger();
logger.error.ln(`error while parsing page "${filePath}":`);
throw err;
});
}
/**
Parse all pages from a book as an OrderedMap
@param {Book} book
@return {Promise<OrderedMap<Page>>}
*/
function parsePagesList(book) {
const summary = book.getSummary();
const glossary = book.getGlossary();
let map = immutable_1.default.OrderedMap();
// Parse pages from summary
return (timing_1.default
.measure("parse.listPages", (0, walkSummary_1.default)(summary, (article) => {
if (!article.isPage())
return;
const filepath = article.getPath();
// Is the page ignored?
if (book.isContentFileIgnored(filepath))
return;
return parseFilePage(book, filepath).then((page) => {
// file doesn't exist
if (!page) {
return;
}
map = map.set(filepath, page);
});
}))
// Parse glossary
.then(() => {
const file = glossary.getFile();
if (!file.exists()) {
return;
}
return parseFilePage(book, file.getPath()).then((page) => {
// file doesn't exist
if (!page) {
return;
}
map = map.set(file.getPath(), page);
});
})
.then(() => {
return map;
}));
}
exports.default = parsePagesList;

9
book/node_modules/honkit/lib/parse/parseReadme.d.ts generated vendored Normal file
View File

@ -0,0 +1,9 @@
/**
Parse readme from book
@param {Book} book
@return {Promise<Book>}
*/
declare function parseReadme(book: any): any;
export default parseReadme;
//# sourceMappingURL=parseReadme.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"parseReadme.d.ts","sourceRoot":"","sources":["../../src/parse/parseReadme.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AAEH,iBAAS,WAAW,CAAC,IAAI,KAAA,OAaxB;AAED,eAAe,WAAW,CAAC"}

26
book/node_modules/honkit/lib/parse/parseReadme.js generated vendored Normal file
View File

@ -0,0 +1,26 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const parseStructureFile_1 = __importDefault(require("./parseStructureFile"));
const readme_1 = __importDefault(require("../models/readme"));
const error_1 = __importDefault(require("../utils/error"));
/**
Parse readme from book
@param {Book} book
@return {Promise<Book>}
*/
function parseReadme(book) {
const logger = book.getLogger();
return (0, parseStructureFile_1.default)(book, "readme").spread((file, result) => {
if (!file) {
throw new error_1.default.FileNotFoundError({ filename: "README" });
}
logger.debug.ln("readme found at", file.getPath());
const readme = readme_1.default.create(file, result);
return book.set("readme", readme);
});
}
exports.default = parseReadme;

View File

@ -0,0 +1,11 @@
/**
Parse a structure file (ex: SUMMARY.md, GLOSSARY.md).
It uses the configuration to find the specified file.
@param {Book} book
@param {string} type: one of ["glossary", "readme", "summary"]
@return {Promise<List|Map>}
*/
declare function parseStructureFile(book: any, type: any): any;
export default parseStructureFile;
//# sourceMappingURL=parseStructureFile.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"parseStructureFile.d.ts","sourceRoot":"","sources":["../../src/parse/parseStructureFile.ts"],"names":[],"mappings":"AA8CA;;;;;;;GAOG;AAEH,iBAAS,kBAAkB,CAAC,IAAI,KAAA,EAAE,IAAI,KAAA,OAQrC;AAED,eAAe,kBAAkB,CAAC"}

View File

@ -0,0 +1,66 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const promise_1 = __importDefault(require("../utils/promise"));
const error_1 = __importDefault(require("../utils/error"));
const lookupStructureFile_1 = __importDefault(require("./lookupStructureFile"));
const path_1 = __importDefault(require("path"));
/**
Parse a ParsableFile using a specific method
@param {FS} fs
@param {ParsableFile} file
@param {string} type
@return {Promise<Array<String, List|Map>>}
*/
function parseFile(fs, file, type) {
const filepath = file.getPath();
const parser = file.getParser();
if (!parser) {
return promise_1.default.reject(error_1.default.FileNotParsableError({
filename: filepath
}));
}
const baseDirectory = path_1.default.dirname(filepath);
return fs
.readAsString(filepath)
.then((content) => {
if (type === "readme") {
return parser.parseReadme(content, { baseDirectory });
}
else if (type === "glossary") {
return parser.parseGlossary(content, { baseDirectory });
}
else if (type === "summary") {
return parser.parseSummary(content, { baseDirectory });
}
else if (type === "langs") {
return parser.parseLanguages(content, { baseDirectory });
}
else {
throw new Error(`Parsing invalid type "${type}"`);
}
})
.then((result) => {
return [file, result];
});
}
/**
Parse a structure file (ex: SUMMARY.md, GLOSSARY.md).
It uses the configuration to find the specified file.
@param {Book} book
@param {string} type: one of ["glossary", "readme", "summary"]
@return {Promise<List|Map>}
*/
function parseStructureFile(book, type) {
const fs = book.getContentFS();
return (0, lookupStructureFile_1.default)(book, type).then((file) => {
if (!file)
return [undefined, undefined];
return parseFile(fs, file, type);
});
}
exports.default = parseStructureFile;

10
book/node_modules/honkit/lib/parse/parseSummary.d.ts generated vendored Normal file
View File

@ -0,0 +1,10 @@
/**
Parse summary in a book, the summary can only be parsed
if the readme as be detected before.
@param {Book} book
@return {Promise<Book>}
*/
declare function parseSummary(book: any): any;
export default parseSummary;
//# sourceMappingURL=parseSummary.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"parseSummary.d.ts","sourceRoot":"","sources":["../../src/parse/parseSummary.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AAEH,iBAAS,YAAY,CAAC,IAAI,KAAA,OA6BzB;AAED,eAAe,YAAY,CAAC"}

43
book/node_modules/honkit/lib/parse/parseSummary.js generated vendored Normal file
View File

@ -0,0 +1,43 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const parseStructureFile_1 = __importDefault(require("./parseStructureFile"));
const summary_1 = __importDefault(require("../models/summary"));
const modifiers_1 = __importDefault(require("../modifiers"));
const SummaryModifier = modifiers_1.default.Summary;
/**
Parse summary in a book, the summary can only be parsed
if the readme as be detected before.
@param {Book} book
@return {Promise<Book>}
*/
function parseSummary(book) {
const readme = book.getReadme();
const logger = book.getLogger();
const readmeFile = readme.getFile();
return (0, parseStructureFile_1.default)(book, "summary").spread((file, result) => {
let summary;
if (!file) {
logger.warn.ln("no summary file in this book");
summary = new summary_1.default();
}
else {
logger.debug.ln("summary file found at", file.getPath());
summary = summary_1.default.createFromParts(file, result.parts);
}
// Insert readme as first entry if not in SUMMARY.md
const readmeArticle = summary.getByPath(readmeFile.getPath());
if (readmeFile.exists() && !readmeArticle) {
summary = SummaryModifier.unshiftArticle(summary, {
title: "Introduction",
ref: readmeFile.getPath()
});
}
// Set new summary
return book.setSummary(summary);
});
}
exports.default = parseSummary;

10
book/node_modules/honkit/lib/parse/validateConfig.d.ts generated vendored Normal file
View File

@ -0,0 +1,10 @@
/**
Validate a book.json content
And return a mix with the default value
@param {Object} bookJson
@return {Object}
*/
declare function validateConfig(bookJson: any): any;
export default validateConfig;
//# sourceMappingURL=validateConfig.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"validateConfig.d.ts","sourceRoot":"","sources":["../../src/parse/validateConfig.ts"],"names":[],"mappings":"AAMA;;;;;;GAMG;AAEH,iBAAS,cAAc,CAAC,QAAQ,KAAA,OAc/B;AAED,eAAe,cAAc,CAAC"}

31
book/node_modules/honkit/lib/parse/validateConfig.js generated vendored Normal file
View File

@ -0,0 +1,31 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const jsonschema_1 = __importDefault(require("jsonschema"));
const json_schema_defaults_1 = __importDefault(require("json-schema-defaults"));
const configSchema_1 = __importDefault(require("../constants/configSchema"));
const error_1 = __importDefault(require("../utils/error"));
const mergeDefaults_1 = __importDefault(require("../utils/mergeDefaults"));
/**
Validate a book.json content
And return a mix with the default value
@param {Object} bookJson
@return {Object}
*/
function validateConfig(bookJson) {
const v = new jsonschema_1.default.Validator();
const result = v.validate(bookJson, configSchema_1.default, {
propertyName: "config"
});
// Throw error
if (result.errors.length > 0) {
throw new error_1.default.ConfigurationError(new Error(result.errors[0].stack));
}
// Insert default values
const defaults = (0, json_schema_defaults_1.default)(configSchema_1.default);
return (0, mergeDefaults_1.default)(bookJson, defaults);
}
exports.default = validateConfig;

10
book/node_modules/honkit/lib/parse/walkSummary.d.ts generated vendored Normal file
View File

@ -0,0 +1,10 @@
/**
Walk over summary and execute "fn" on each article
@param {Summary} summary
@param {Function(article)}
@return {Promise}
*/
declare function walkSummary(summary: any, fn: any): any;
export default walkSummary;
//# sourceMappingURL=walkSummary.d.ts.map

View File

@ -0,0 +1 @@
{"version":3,"file":"walkSummary.d.ts","sourceRoot":"","sources":["../../src/parse/walkSummary.ts"],"names":[],"mappings":"AAiBA;;;;;;GAMG;AAEH,iBAAS,WAAW,CAAC,OAAO,KAAA,EAAE,EAAE,KAAA,OAM/B;AAED,eAAe,WAAW,CAAC"}

34
book/node_modules/honkit/lib/parse/walkSummary.js generated vendored Normal file
View File

@ -0,0 +1,34 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const promise_1 = __importDefault(require("../utils/promise"));
/**
Walk over a list of articles
@param {List<Article>} articles
@param {Function(article)}
@return {Promise}
*/
function walkArticles(articles, fn) {
return promise_1.default.forEach(articles, (article) => {
return (0, promise_1.default)(fn(article)).then(() => {
return walkArticles(article.getArticles(), fn);
});
});
}
/**
Walk over summary and execute "fn" on each article
@param {Summary} summary
@param {Function(article)}
@return {Promise}
*/
function walkSummary(summary, fn) {
const parts = summary.getParts();
return promise_1.default.forEach(parts, (part) => {
return walkArticles(part.getArticles(), fn);
});
}
exports.default = walkSummary;