id
int32
0
58k
repo
stringlengths
5
67
path
stringlengths
4
116
func_name
stringlengths
0
58
original_string
stringlengths
52
373k
language
stringclasses
1 value
code
stringlengths
52
373k
code_tokens
list
docstring
stringlengths
4
11.8k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
86
226
1,100
GitbookIO/gitbook
lib/output/website/copyPluginAssets.js
copyResources
function copyResources(output, plugin) { var logger = output.getLogger(); var options = output.getOptions(); var outputRoot = options.get('root'); var state = output.getState(); var resources = state.getResources(); var pluginRoot = plugin.getPath(); var pluginResources = resource...
javascript
function copyResources(output, plugin) { var logger = output.getLogger(); var options = output.getOptions(); var outputRoot = options.get('root'); var state = output.getState(); var resources = state.getResources(); var pluginRoot = plugin.getPath(); var pluginResources = resource...
[ "function", "copyResources", "(", "output", ",", "plugin", ")", "{", "var", "logger", "=", "output", ".", "getLogger", "(", ")", ";", "var", "options", "=", "output", ".", "getOptions", "(", ")", ";", "var", "outputRoot", "=", "options", ".", "get", "(...
Copy resources from a plugin @param {Plugin} @return {Promise}
[ "Copy", "resources", "from", "a", "plugin" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/website/copyPluginAssets.js#L78-L115
1,101
GitbookIO/gitbook
lib/output/helper/writeFile.js
writeFile
function writeFile(output, filePath, content) { var rootFolder = output.getRoot(); filePath = path.join(rootFolder, filePath); return fs.ensureFile(filePath) .then(function() { return fs.writeFile(filePath, content); }) .thenResolve(output); }
javascript
function writeFile(output, filePath, content) { var rootFolder = output.getRoot(); filePath = path.join(rootFolder, filePath); return fs.ensureFile(filePath) .then(function() { return fs.writeFile(filePath, content); }) .thenResolve(output); }
[ "function", "writeFile", "(", "output", ",", "filePath", ",", "content", ")", "{", "var", "rootFolder", "=", "output", ".", "getRoot", "(", ")", ";", "filePath", "=", "path", ".", "join", "(", "rootFolder", ",", "filePath", ")", ";", "return", "fs", "....
Write a file to the output folder @param {Output} output @param {String} filePath @param {Buffer|String} content @return {Promise}
[ "Write", "a", "file", "to", "the", "output", "folder" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/helper/writeFile.js#L12-L21
1,102
GitbookIO/gitbook
lib/api/encodeProgress.js
encodeProgress
function encodeProgress(output, page) { var current = page.getPath(); var navigation = encodeNavigation(output); navigation = Immutable.Map(navigation); var n = navigation.size; var percent = 0, prevPercent = 0, currentChapter = null; var done = true; var chapters = navigation .map...
javascript
function encodeProgress(output, page) { var current = page.getPath(); var navigation = encodeNavigation(output); navigation = Immutable.Map(navigation); var n = navigation.size; var percent = 0, prevPercent = 0, currentChapter = null; var done = true; var chapters = navigation .map...
[ "function", "encodeProgress", "(", "output", ",", "page", ")", "{", "var", "current", "=", "page", ".", "getPath", "(", ")", ";", "var", "navigation", "=", "encodeNavigation", "(", "output", ")", ";", "navigation", "=", "Immutable", ".", "Map", "(", "nav...
page.progress is a deprecated property from GitBook v2 @param {Output} @param {Page} @return {Object}
[ "page", ".", "progress", "is", "a", "deprecated", "property", "from", "GitBook", "v2" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/encodeProgress.js#L11-L60
1,103
GitbookIO/gitbook
lib/output/modifiers/inlineAssets.js
inlineAssets
function inlineAssets(rootFolder, currentFile) { return function($) { return Promise() // Resolving images and fetching external images should be // done before svg conversion .then(resolveImages.bind(null, currentFile, $)) .then(fetchRemoteImages.bind(null, rootFolder, curr...
javascript
function inlineAssets(rootFolder, currentFile) { return function($) { return Promise() // Resolving images and fetching external images should be // done before svg conversion .then(resolveImages.bind(null, currentFile, $)) .then(fetchRemoteImages.bind(null, rootFolder, curr...
[ "function", "inlineAssets", "(", "rootFolder", ",", "currentFile", ")", "{", "return", "function", "(", "$", ")", "{", "return", "Promise", "(", ")", "// Resolving images and fetching external images should be", "// done before svg conversion", ".", "then", "(", "resolv...
Inline all assets in a page @param {String} rootFolder
[ "Inline", "all", "assets", "in", "a", "page" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/modifiers/inlineAssets.js#L14-L27
1,104
GitbookIO/gitbook
lib/plugins/findForBook.js
findForBook
function findForBook(book) { return timing.measure( 'plugins.findForBook', Promise.all([ findInstalled(locateRootFolder()), findInstalled(book.getRoot()) ]) // Merge all plugins .then(function(results) { return Immutable.List(results) ...
javascript
function findForBook(book) { return timing.measure( 'plugins.findForBook', Promise.all([ findInstalled(locateRootFolder()), findInstalled(book.getRoot()) ]) // Merge all plugins .then(function(results) { return Immutable.List(results) ...
[ "function", "findForBook", "(", "book", ")", "{", "return", "timing", ".", "measure", "(", "'plugins.findForBook'", ",", "Promise", ".", "all", "(", "[", "findInstalled", "(", "locateRootFolder", "(", ")", ")", ",", "findInstalled", "(", "book", ".", "getRoo...
List all plugins installed in a book @param {Book} @return {Promise<OrderedMap<String:Plugin>>}
[ "List", "all", "plugins", "installed", "in", "a", "book" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/plugins/findForBook.js#L14-L31
1,105
GitbookIO/gitbook
lib/parse/parseIgnore.js
parseIgnore
function parseIgnore(book) { if (book.isLanguageBook()) { return Promise.reject(new Error('Ignore files could be parsed for language books')); } var fs = book.getFS(); var ignore = book.getIgnore(); ignore = ignore.add(DEFAULT_IGNORES); return Promise.serie(IGNORE_FILES, function(file...
javascript
function parseIgnore(book) { if (book.isLanguageBook()) { return Promise.reject(new Error('Ignore files could be parsed for language books')); } var fs = book.getFS(); var ignore = book.getIgnore(); ignore = ignore.add(DEFAULT_IGNORES); return Promise.serie(IGNORE_FILES, function(file...
[ "function", "parseIgnore", "(", "book", ")", "{", "if", "(", "book", ".", "isLanguageBook", "(", ")", ")", "{", "return", "Promise", ".", "reject", "(", "new", "Error", "(", "'Ignore files could be parsed for language books'", ")", ")", ";", "}", "var", "fs"...
Parse ignore files @param {Book} @return {Book}
[ "Parse", "ignore", "files" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/parse/parseIgnore.js#L27-L49
1,106
GitbookIO/gitbook
lib/cli/getOutputFolder.js
getOutputFolder
function getOutputFolder(args) { var bookRoot = path.resolve(args[0] || process.cwd()); var defaultOutputRoot = path.join(bookRoot, '_book'); var outputFolder = args[1]? path.resolve(process.cwd(), args[1]) : defaultOutputRoot; return outputFolder; }
javascript
function getOutputFolder(args) { var bookRoot = path.resolve(args[0] || process.cwd()); var defaultOutputRoot = path.join(bookRoot, '_book'); var outputFolder = args[1]? path.resolve(process.cwd(), args[1]) : defaultOutputRoot; return outputFolder; }
[ "function", "getOutputFolder", "(", "args", ")", "{", "var", "bookRoot", "=", "path", ".", "resolve", "(", "args", "[", "0", "]", "||", "process", ".", "cwd", "(", ")", ")", ";", "var", "defaultOutputRoot", "=", "path", ".", "join", "(", "bookRoot", ...
Return path to output folder @param {Array} args @return {String}
[ "Return", "path", "to", "output", "folder" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/cli/getOutputFolder.js#L9-L15
1,107
GitbookIO/gitbook
lib/api/decodeConfig.js
decodeGlobal
function decodeGlobal(config, result) { var values = result.values; delete values.generator; delete values.output; return config.updateValues(values); }
javascript
function decodeGlobal(config, result) { var values = result.values; delete values.generator; delete values.output; return config.updateValues(values); }
[ "function", "decodeGlobal", "(", "config", ",", "result", ")", "{", "var", "values", "=", "result", ".", "values", ";", "delete", "values", ".", "generator", ";", "delete", "values", ".", "output", ";", "return", "config", ".", "updateValues", "(", "values...
Decode changes from a JS API to a config object @param {Config} config @param {Object} result: result from API @return {Config}
[ "Decode", "changes", "from", "a", "JS", "API", "to", "a", "config", "object" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/decodeConfig.js#L8-L15
1,108
GitbookIO/gitbook
lib/api/encodeNavigation.js
encodeNavigation
function encodeNavigation(output) { var book = output.getBook(); var pages = output.getPages(); var summary = book.getSummary(); var articles = summary.getArticlesAsList(); var navigation = articles .map(function(article, i) { var ref = article.getRef(); if (!ref) {...
javascript
function encodeNavigation(output) { var book = output.getBook(); var pages = output.getPages(); var summary = book.getSummary(); var articles = summary.getArticlesAsList(); var navigation = articles .map(function(article, i) { var ref = article.getRef(); if (!ref) {...
[ "function", "encodeNavigation", "(", "output", ")", "{", "var", "book", "=", "output", ".", "getBook", "(", ")", ";", "var", "pages", "=", "output", ".", "getPages", "(", ")", ";", "var", "summary", "=", "book", ".", "getSummary", "(", ")", ";", "var...
this.navigation is a deprecated property from GitBook v2 @param {Output} @return {Object}
[ "this", ".", "navigation", "is", "a", "deprecated", "property", "from", "GitBook", "v2" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/encodeNavigation.js#L28-L62
1,109
GitbookIO/gitbook
lib/json/encodeOutput.js
encodeOutputToJson
function encodeOutputToJson(output) { var book = output.getBook(); var generator = output.getGenerator(); var options = output.getOptions(); var result = encodeBook(book); result.output = { name: generator }; result.options = options.toJS(); return result; }
javascript
function encodeOutputToJson(output) { var book = output.getBook(); var generator = output.getGenerator(); var options = output.getOptions(); var result = encodeBook(book); result.output = { name: generator }; result.options = options.toJS(); return result; }
[ "function", "encodeOutputToJson", "(", "output", ")", "{", "var", "book", "=", "output", ".", "getBook", "(", ")", ";", "var", "generator", "=", "output", ".", "getGenerator", "(", ")", ";", "var", "options", "=", "output", ".", "getOptions", "(", ")", ...
Encode an output to JSON @param {Output} @return {Object}
[ "Encode", "an", "output", "to", "JSON" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/json/encodeOutput.js#L9-L23
1,110
GitbookIO/gitbook
lib/parse/parsePage.js
parsePage
function parsePage(book, page) { var fs = book.getContentFS(); var file = page.getFile(); return fs.readAsString(file.getPath()) .then(function(content) { return parsePageFromString(page, content); }); }
javascript
function parsePage(book, page) { var fs = book.getContentFS(); var file = page.getFile(); return fs.readAsString(file.getPath()) .then(function(content) { return parsePageFromString(page, content); }); }
[ "function", "parsePage", "(", "book", ",", "page", ")", "{", "var", "fs", "=", "book", ".", "getContentFS", "(", ")", ";", "var", "file", "=", "page", ".", "getFile", "(", ")", ";", "return", "fs", ".", "readAsString", "(", "file", ".", "getPath", ...
Parse a page, read its content and parse the YAMl header @param {Book} book @param {Page} page @return {Promise<Page>}
[ "Parse", "a", "page", "read", "its", "content", "and", "parse", "the", "YAMl", "header" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/parse/parsePage.js#L10-L18
1,111
GitbookIO/gitbook
lib/parse/listAssets.js
listAssets
function listAssets(book, pages) { var fs = book.getContentFS(); var summary = book.getSummary(); var summaryFile = summary.getFile().getPath(); var glossary = book.getGlossary(); var glossaryFile = glossary.getFile().getPath(); var langs = book.getLanguages(); var langsFile = langs.getFi...
javascript
function listAssets(book, pages) { var fs = book.getContentFS(); var summary = book.getSummary(); var summaryFile = summary.getFile().getPath(); var glossary = book.getGlossary(); var glossaryFile = glossary.getFile().getPath(); var langs = book.getLanguages(); var langsFile = langs.getFi...
[ "function", "listAssets", "(", "book", ",", "pages", ")", "{", "var", "fs", "=", "book", ".", "getContentFS", "(", ")", ";", "var", "summary", "=", "book", ".", "getSummary", "(", ")", ";", "var", "summaryFile", "=", "summary", ".", "getFile", "(", "...
List all assets in a book Assets are file not ignored and not a page @param {Book} book @param {List<String>} pages @param
[ "List", "all", "assets", "in", "a", "book", "Assets", "are", "file", "not", "ignored", "and", "not", "a", "page" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/parse/listAssets.js#L11-L41
1,112
GitbookIO/gitbook
lib/fs/mock.js
createMockFS
function createMockFS(files) { files = Immutable.fromJS(files); var mtime = new Date(); function getFile(filePath) { var parts = path.normalize(filePath).split(path.sep); return parts.reduce(function(list, part, i) { if (!list) return null; var file; if...
javascript
function createMockFS(files) { files = Immutable.fromJS(files); var mtime = new Date(); function getFile(filePath) { var parts = path.normalize(filePath).split(path.sep); return parts.reduce(function(list, part, i) { if (!list) return null; var file; if...
[ "function", "createMockFS", "(", "files", ")", "{", "files", "=", "Immutable", ".", "fromJS", "(", "files", ")", ";", "var", "mtime", "=", "new", "Date", "(", ")", ";", "function", "getFile", "(", "filePath", ")", "{", "var", "parts", "=", "path", "....
Create a fake filesystem for unit testing GitBook. @param {Map<String:String|Map>}
[ "Create", "a", "fake", "filesystem", "for", "unit", "testing", "GitBook", "." ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/fs/mock.js#L14-L93
1,113
GitbookIO/gitbook
lib/utils/fs.js
fileExists
function fileExists(filename) { var d = Promise.defer(); fs.exists(filename, function(exists) { d.resolve(exists); }); return d.promise; }
javascript
function fileExists(filename) { var d = Promise.defer(); fs.exists(filename, function(exists) { d.resolve(exists); }); return d.promise; }
[ "function", "fileExists", "(", "filename", ")", "{", "var", "d", "=", "Promise", ".", "defer", "(", ")", ";", "fs", ".", "exists", "(", "filename", ",", "function", "(", "exists", ")", "{", "d", ".", "resolve", "(", "exists", ")", ";", "}", ")", ...
Return a promise resolved with a boolean
[ "Return", "a", "promise", "resolved", "with", "a", "boolean" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/fs.js#L43-L51
1,114
GitbookIO/gitbook
lib/utils/fs.js
ensureFile
function ensureFile(filename) { var base = path.dirname(filename); return Promise.nfcall(mkdirp, base); }
javascript
function ensureFile(filename) { var base = path.dirname(filename); return Promise.nfcall(mkdirp, base); }
[ "function", "ensureFile", "(", "filename", ")", "{", "var", "base", "=", "path", ".", "dirname", "(", "filename", ")", ";", "return", "Promise", ".", "nfcall", "(", "mkdirp", ",", "base", ")", ";", "}" ]
Create all required folder to create a file
[ "Create", "all", "required", "folder", "to", "create", "a", "file" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/fs.js#L88-L91
1,115
GitbookIO/gitbook
lib/utils/fs.js
pickFile
function pickFile(rootFolder, fileName) { var result = path.join(rootFolder, fileName); if (fs.existsSync(result)) { return result; } return undefined; }
javascript
function pickFile(rootFolder, fileName) { var result = path.join(rootFolder, fileName); if (fs.existsSync(result)) { return result; } return undefined; }
[ "function", "pickFile", "(", "rootFolder", ",", "fileName", ")", "{", "var", "result", "=", "path", ".", "join", "(", "rootFolder", ",", "fileName", ")", ";", "if", "(", "fs", ".", "existsSync", "(", "result", ")", ")", "{", "return", "result", ";", ...
Pick a file, returns the absolute path if exists, undefined otherwise @param {String} rootFolder @param {String} fileName @return {String}
[ "Pick", "a", "file", "returns", "the", "absolute", "path", "if", "exists", "undefined", "otherwise" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/fs.js#L123-L130
1,116
GitbookIO/gitbook
lib/utils/fs.js
ensureFolder
function ensureFolder(rootFolder) { return rmDir(rootFolder) .fail(function() { return Promise(); }) .then(function() { return Promise.nfcall(mkdirp, rootFolder); }); }
javascript
function ensureFolder(rootFolder) { return rmDir(rootFolder) .fail(function() { return Promise(); }) .then(function() { return Promise.nfcall(mkdirp, rootFolder); }); }
[ "function", "ensureFolder", "(", "rootFolder", ")", "{", "return", "rmDir", "(", "rootFolder", ")", ".", "fail", "(", "function", "(", ")", "{", "return", "Promise", "(", ")", ";", "}", ")", ".", "then", "(", "function", "(", ")", "{", "return", "Pro...
Ensure that a directory exists and is empty @param {String} folder @return {Promise}
[ "Ensure", "that", "a", "directory", "exists", "and", "is", "empty" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/fs.js#L138-L146
1,117
GitbookIO/gitbook
lib/api/decodeGlobal.js
decodeGlobal
function decodeGlobal(output, result) { var book = output.getBook(); var config = book.getConfig(); // Update config config = decodeConfig(config, result.config); book = book.set('config', config); return output.set('book', book); }
javascript
function decodeGlobal(output, result) { var book = output.getBook(); var config = book.getConfig(); // Update config config = decodeConfig(config, result.config); book = book.set('config', config); return output.set('book', book); }
[ "function", "decodeGlobal", "(", "output", ",", "result", ")", "{", "var", "book", "=", "output", ".", "getBook", "(", ")", ";", "var", "config", "=", "book", ".", "getConfig", "(", ")", ";", "// Update config", "config", "=", "decodeConfig", "(", "confi...
Decode changes from a JS API to a output object. Only the configuration can be edited by plugin's hooks @param {Output} output @param {Object} result: result from API @return {Output}
[ "Decode", "changes", "from", "a", "JS", "API", "to", "a", "output", "object", ".", "Only", "the", "configuration", "can", "be", "edited", "by", "plugin", "s", "hooks" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/decodeGlobal.js#L11-L20
1,118
GitbookIO/gitbook
lib/json/encodeFile.js
encodeFileToJson
function encodeFileToJson(file) { var filePath = file.getPath(); if (!filePath) { return undefined; } return { path: filePath, mtime: file.getMTime(), type: file.getType() }; }
javascript
function encodeFileToJson(file) { var filePath = file.getPath(); if (!filePath) { return undefined; } return { path: filePath, mtime: file.getMTime(), type: file.getType() }; }
[ "function", "encodeFileToJson", "(", "file", ")", "{", "var", "filePath", "=", "file", ".", "getPath", "(", ")", ";", "if", "(", "!", "filePath", ")", "{", "return", "undefined", ";", "}", "return", "{", "path", ":", "filePath", ",", "mtime", ":", "f...
Return a JSON representation of a file @param {File} file @return {Object}
[ "Return", "a", "JSON", "representation", "of", "a", "file" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/json/encodeFile.js#L8-L19
1,119
GitbookIO/gitbook
lib/parse/parseLanguages.js
parseLanguages
function parseLanguages(book) { var logger = book.getLogger(); return parseStructureFile(book, 'langs') .spread(function(file, result) { if (!file) { return book; } var languages = Languages.createFromList(file, result); logger.debug.ln('languages index file fo...
javascript
function parseLanguages(book) { var logger = book.getLogger(); return parseStructureFile(book, 'langs') .spread(function(file, result) { if (!file) { return book; } var languages = Languages.createFromList(file, result); logger.debug.ln('languages index file fo...
[ "function", "parseLanguages", "(", "book", ")", "{", "var", "logger", "=", "book", ".", "getLogger", "(", ")", ";", "return", "parseStructureFile", "(", "book", ",", "'langs'", ")", ".", "spread", "(", "function", "(", "file", ",", "result", ")", "{", ...
Parse languages list from book @param {Book} book @return {Promise<Book>}
[ "Parse", "languages", "list", "from", "book" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/parse/parseLanguages.js#L10-L26
1,120
GitbookIO/gitbook
lib/output/website/onFinish.js
onFinish
function onFinish(output) { var book = output.getBook(); var options = output.getOptions(); var prefix = options.get('prefix'); if (!book.isMultilingual()) { return Promise(output); } var filePath = 'index.html'; var engine = createTemplateEngine(output, filePath); var context ...
javascript
function onFinish(output) { var book = output.getBook(); var options = output.getOptions(); var prefix = options.get('prefix'); if (!book.isMultilingual()) { return Promise(output); } var filePath = 'index.html'; var engine = createTemplateEngine(output, filePath); var context ...
[ "function", "onFinish", "(", "output", ")", "{", "var", "book", "=", "output", ".", "getBook", "(", ")", ";", "var", "options", "=", "output", ".", "getOptions", "(", ")", ";", "var", "prefix", "=", "options", ".", "get", "(", "'prefix'", ")", ";", ...
Finish the generation, write the languages index @param {Output} @return {Output}
[ "Finish", "the", "generation", "write", "the", "languages", "index" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/website/onFinish.js#L13-L33
1,121
GitbookIO/gitbook
lib/output/generatePages.js
generatePages
function generatePages(generator, output) { var pages = output.getPages(); var logger = output.getLogger(); // Is generator ignoring assets? if (!generator.onPage) { return Promise(output); } return Promise.reduce(pages, function(out, page) { var file = page.getFile(); ...
javascript
function generatePages(generator, output) { var pages = output.getPages(); var logger = output.getLogger(); // Is generator ignoring assets? if (!generator.onPage) { return Promise(output); } return Promise.reduce(pages, function(out, page) { var file = page.getFile(); ...
[ "function", "generatePages", "(", "generator", ",", "output", ")", "{", "var", "pages", "=", "output", ".", "getPages", "(", ")", ";", "var", "logger", "=", "output", ".", "getLogger", "(", ")", ";", "// Is generator ignoring assets?", "if", "(", "!", "gen...
Output all pages using a generator @param {Generator} generator @param {Output} output @return {Promise<Output>}
[ "Output", "all", "pages", "using", "a", "generator" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/generatePages.js#L11-L34
1,122
GitbookIO/gitbook
lib/modifiers/config/addPlugin.js
addPlugin
function addPlugin(config, pluginName, version) { // For default plugin, we only ensure it is enabled if (isDefaultPlugin(pluginName, version)) { return togglePlugin(config, pluginName, true); } var deps = config.getPluginDependencies(); var dep = PluginDependency.create(pluginName, version...
javascript
function addPlugin(config, pluginName, version) { // For default plugin, we only ensure it is enabled if (isDefaultPlugin(pluginName, version)) { return togglePlugin(config, pluginName, true); } var deps = config.getPluginDependencies(); var dep = PluginDependency.create(pluginName, version...
[ "function", "addPlugin", "(", "config", ",", "pluginName", ",", "version", ")", "{", "// For default plugin, we only ensure it is enabled", "if", "(", "isDefaultPlugin", "(", "pluginName", ",", "version", ")", ")", "{", "return", "togglePlugin", "(", "config", ",", ...
Add a plugin to a book's configuration @param {Config} config @param {String} pluginName @param {String} version (optional) @return {Config}
[ "Add", "a", "plugin", "to", "a", "book", "s", "configuration" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/modifiers/config/addPlugin.js#L12-L23
1,123
GitbookIO/gitbook
lib/output/prepareAssets.js
prepareAssets
function prepareAssets(output) { var book = output.getBook(); var pages = output.getPages(); var logger = output.getLogger(); return Parse.listAssets(book, pages) .then(function(assets) { logger.info.ln('found', assets.size, 'asset files'); return output.set('assets', assets); ...
javascript
function prepareAssets(output) { var book = output.getBook(); var pages = output.getPages(); var logger = output.getLogger(); return Parse.listAssets(book, pages) .then(function(assets) { logger.info.ln('found', assets.size, 'asset files'); return output.set('assets', assets); ...
[ "function", "prepareAssets", "(", "output", ")", "{", "var", "book", "=", "output", ".", "getBook", "(", ")", ";", "var", "pages", "=", "output", ".", "getPages", "(", ")", ";", "var", "logger", "=", "output", ".", "getLogger", "(", ")", ";", "return...
List all assets in the book @param {Output} @return {Promise<Output>}
[ "List", "all", "assets", "in", "the", "book" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/prepareAssets.js#L9-L20
1,124
GitbookIO/gitbook
lib/json/encodeGlossary.js
encodeGlossary
function encodeGlossary(glossary) { var file = glossary.getFile(); var entries = glossary.getEntries(); return { file: encodeFile(file), entries: entries .map(encodeGlossaryEntry).toJS() }; }
javascript
function encodeGlossary(glossary) { var file = glossary.getFile(); var entries = glossary.getEntries(); return { file: encodeFile(file), entries: entries .map(encodeGlossaryEntry).toJS() }; }
[ "function", "encodeGlossary", "(", "glossary", ")", "{", "var", "file", "=", "glossary", ".", "getFile", "(", ")", ";", "var", "entries", "=", "glossary", ".", "getEntries", "(", ")", ";", "return", "{", "file", ":", "encodeFile", "(", "file", ")", ","...
Encode a glossary to JSON @param {Glossary} @return {Object}
[ "Encode", "a", "glossary", "to", "JSON" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/json/encodeGlossary.js#L10-L19
1,125
GitbookIO/gitbook
lib/utils/timing.js
measure
function measure(type, p) { timers[type] = timers[type] || { type: type, count: 0, total: 0, min: undefined, max: 0 }; var start = Date.now(); return p .fin(function() { var end = Date.now(); var duration = (end - start); timers[type...
javascript
function measure(type, p) { timers[type] = timers[type] || { type: type, count: 0, total: 0, min: undefined, max: 0 }; var start = Date.now(); return p .fin(function() { var end = Date.now(); var duration = (end - start); timers[type...
[ "function", "measure", "(", "type", ",", "p", ")", "{", "timers", "[", "type", "]", "=", "timers", "[", "type", "]", "||", "{", "type", ":", "type", ",", "count", ":", "0", ",", "total", ":", "0", ",", "min", ":", "undefined", ",", "max", ":", ...
Mesure an operation @parqm {String} type @param {Promise} p @return {Promise}
[ "Mesure", "an", "operation" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/timing.js#L14-L41
1,126
GitbookIO/gitbook
lib/utils/timing.js
dump
function dump(logger) { var prefix = ' > '; var measured = 0; var totalDuration = Date.now() - startDate; // Enable debug logging var logLevel = logger.getLevel(); logger.setLevel('debug'); Immutable.Map(timers) .valueSeq() .sortBy(function(timer) { measured ...
javascript
function dump(logger) { var prefix = ' > '; var measured = 0; var totalDuration = Date.now() - startDate; // Enable debug logging var logLevel = logger.getLevel(); logger.setLevel('debug'); Immutable.Map(timers) .valueSeq() .sortBy(function(timer) { measured ...
[ "function", "dump", "(", "logger", ")", "{", "var", "prefix", "=", "' > '", ";", "var", "measured", "=", "0", ";", "var", "totalDuration", "=", "Date", ".", "now", "(", ")", "-", "startDate", ";", "// Enable debug logging", "var", "logLevel", "=", "lo...
Dump all timers to a logger @param {Logger} logger
[ "Dump", "all", "timers", "to", "a", "logger" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/timing.js#L62-L92
1,127
GitbookIO/gitbook
lib/plugins/loadPlugin.js
loadPlugin
function loadPlugin(book, plugin) { var logger = book.getLogger(); var name = plugin.getName(); var pkgPath = plugin.getPath(); // Try loading plugins from different location var p = Promise() .then(function() { var packageContent; var packageMain; var content; ...
javascript
function loadPlugin(book, plugin) { var logger = book.getLogger(); var name = plugin.getName(); var pkgPath = plugin.getPath(); // Try loading plugins from different location var p = Promise() .then(function() { var packageContent; var packageMain; var content; ...
[ "function", "loadPlugin", "(", "book", ",", "plugin", ")", "{", "var", "logger", "=", "book", ".", "getLogger", "(", ")", ";", "var", "name", "=", "plugin", ".", "getName", "(", ")", ";", "var", "pkgPath", "=", "plugin", ".", "getPath", "(", ")", "...
Load a plugin in a book @param {Book} book @param {Plugin} plugin @param {String} pkgPath (optional) @return {Promise<Plugin>}
[ "Load", "a", "plugin", "in", "a", "book" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/plugins/loadPlugin.js#L25-L86
1,128
GitbookIO/gitbook
lib/plugins/installPlugin.js
installPlugin
function installPlugin(book, plugin) { var logger = book.getLogger(); var installFolder = book.getRoot(); var name = plugin.getName(); var requirement = plugin.getVersion(); logger.info.ln(''); logger.info.ln('installing plugin "' + name + '"'); // Find a version to install return res...
javascript
function installPlugin(book, plugin) { var logger = book.getLogger(); var installFolder = book.getRoot(); var name = plugin.getName(); var requirement = plugin.getVersion(); logger.info.ln(''); logger.info.ln('installing plugin "' + name + '"'); // Find a version to install return res...
[ "function", "installPlugin", "(", "book", ",", "plugin", ")", "{", "var", "logger", "=", "book", ".", "getLogger", "(", ")", ";", "var", "installFolder", "=", "book", ".", "getRoot", "(", ")", ";", "var", "name", "=", "plugin", ".", "getName", "(", "...
Install a plugin for a book @param {Book} @param {PluginDependency} @return {Promise}
[ "Install", "a", "plugin", "for", "a", "book" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/plugins/installPlugin.js#L13-L45
1,129
GitbookIO/gitbook
lib/api/encodeSummary.js
encodeSummary
function encodeSummary(output, summary) { var result = { /** Iterate over the summary, it stops when the "iter" returns false @param {Function} iter */ walk: function (iter) { summary.getArticle(function(article) { var jsonArticle = encode...
javascript
function encodeSummary(output, summary) { var result = { /** Iterate over the summary, it stops when the "iter" returns false @param {Function} iter */ walk: function (iter) { summary.getArticle(function(article) { var jsonArticle = encode...
[ "function", "encodeSummary", "(", "output", ",", "summary", ")", "{", "var", "result", "=", "{", "/**\n Iterate over the summary, it stops when the \"iter\" returns false\n\n @param {Function} iter\n */", "walk", ":", "function", "(", "iter", ")", "...
Encode summary to provide an API to plugin @param {Output} output @param {Config} config @return {Object}
[ "Encode", "summary", "to", "provide", "an", "API", "to", "plugin" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/encodeSummary.js#L10-L49
1,130
GitbookIO/gitbook
lib/api/encodeSummary.js
function (iter) { summary.getArticle(function(article) { var jsonArticle = encodeSummaryArticle(article, false); return iter(jsonArticle); }); }
javascript
function (iter) { summary.getArticle(function(article) { var jsonArticle = encodeSummaryArticle(article, false); return iter(jsonArticle); }); }
[ "function", "(", "iter", ")", "{", "summary", ".", "getArticle", "(", "function", "(", "article", ")", "{", "var", "jsonArticle", "=", "encodeSummaryArticle", "(", "article", ",", "false", ")", ";", "return", "iter", "(", "jsonArticle", ")", ";", "}", ")...
Iterate over the summary, it stops when the "iter" returns false @param {Function} iter
[ "Iterate", "over", "the", "summary", "it", "stops", "when", "the", "iter", "returns", "false" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/encodeSummary.js#L17-L23
1,131
GitbookIO/gitbook
lib/modifiers/summary/indexLevels.js
indexLevels
function indexLevels(summary) { var parts = summary.getParts(); parts = parts.map(indexPartLevels); return summary.set('parts', parts); }
javascript
function indexLevels(summary) { var parts = summary.getParts(); parts = parts.map(indexPartLevels); return summary.set('parts', parts); }
[ "function", "indexLevels", "(", "summary", ")", "{", "var", "parts", "=", "summary", ".", "getParts", "(", ")", ";", "parts", "=", "parts", ".", "map", "(", "indexPartLevels", ")", ";", "return", "summary", ".", "set", "(", "'parts'", ",", "parts", ")"...
Index all levels in the summary @param {Summary} @return {Summary}
[ "Index", "all", "levels", "in", "the", "summary" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/modifiers/summary/indexLevels.js#L9-L14
1,132
GitbookIO/gitbook
lib/models/templateBlock.js
extractKwargs
function extractKwargs(args) { var last = args[args.length - 1]; return (is.object(last) && last.__keywords)? args.pop() : {}; }
javascript
function extractKwargs(args) { var last = args[args.length - 1]; return (is.object(last) && last.__keywords)? args.pop() : {}; }
[ "function", "extractKwargs", "(", "args", ")", "{", "var", "last", "=", "args", "[", "args", ".", "length", "-", "1", "]", ";", "return", "(", "is", ".", "object", "(", "last", ")", "&&", "last", ".", "__keywords", ")", "?", "args", ".", "pop", "...
Extract kwargs from an arguments array @param {Array} args @return {Object}
[ "Extract", "kwargs", "from", "an", "arguments", "array" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/models/templateBlock.js#L276-L279
1,133
GitbookIO/gitbook
lib/json/encodePage.js
encodePage
function encodePage(page, summary) { var file = page.getFile(); var attributes = page.getAttributes(); var article = summary.getByPath(file.getPath()); var result = attributes.toJS(); if (article) { result.title = article.getTitle(); result.level = article.getLevel(); resul...
javascript
function encodePage(page, summary) { var file = page.getFile(); var attributes = page.getAttributes(); var article = summary.getByPath(file.getPath()); var result = attributes.toJS(); if (article) { result.title = article.getTitle(); result.level = article.getLevel(); resul...
[ "function", "encodePage", "(", "page", ",", "summary", ")", "{", "var", "file", "=", "page", ".", "getFile", "(", ")", ";", "var", "attributes", "=", "page", ".", "getAttributes", "(", ")", ";", "var", "article", "=", "summary", ".", "getByPath", "(", ...
Return a JSON representation of a page @param {Page} page @param {Summary} summary @return {Object}
[ "Return", "a", "JSON", "representation", "of", "a", "page" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/json/encodePage.js#L10-L37
1,134
GitbookIO/gitbook
lib/plugins/findInstalled.js
findInstalled
function findInstalled(folder) { var options = { dev: false, log: function() {}, depth: 4 }; var results = Immutable.OrderedMap(); function onPackage(pkg, parent) { if (!pkg.name) return; var name = pkg.name; var version = pkg.version; var pkgPat...
javascript
function findInstalled(folder) { var options = { dev: false, log: function() {}, depth: 4 }; var results = Immutable.OrderedMap(); function onPackage(pkg, parent) { if (!pkg.name) return; var name = pkg.name; var version = pkg.version; var pkgPat...
[ "function", "findInstalled", "(", "folder", ")", "{", "var", "options", "=", "{", "dev", ":", "false", ",", "log", ":", "function", "(", ")", "{", "}", ",", "depth", ":", "4", "}", ";", "var", "results", "=", "Immutable", ".", "OrderedMap", "(", ")...
List all packages installed inside a folder @param {String} folder @return {OrderedMap<String:Plugin>}
[ "List", "all", "packages", "installed", "inside", "a", "folder" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/plugins/findInstalled.js#L26-L89
1,135
GitbookIO/gitbook
lib/api/encodePage.js
encodePage
function encodePage(output, page) { var book = output.getBook(); var summary = book.getSummary(); var fs = book.getContentFS(); var file = page.getFile(); // JS Page is based on the JSON output var result = JSONUtils.encodePage(page, summary); result.type = file.getType(); result.path ...
javascript
function encodePage(output, page) { var book = output.getBook(); var summary = book.getSummary(); var fs = book.getContentFS(); var file = page.getFile(); // JS Page is based on the JSON output var result = JSONUtils.encodePage(page, summary); result.type = file.getType(); result.path ...
[ "function", "encodePage", "(", "output", ",", "page", ")", "{", "var", "book", "=", "output", ".", "getBook", "(", ")", ";", "var", "summary", "=", "book", ".", "getSummary", "(", ")", ";", "var", "fs", "=", "book", ".", "getContentFS", "(", ")", "...
Encode a page in a context to a JS API @param {Output} output @param {Page} page @return {Object}
[ "Encode", "a", "page", "in", "a", "context", "to", "a", "JS", "API" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/encodePage.js#L12-L37
1,136
GitbookIO/gitbook
lib/api/deprecate.js
logNotice
function logNotice(book, key, message) { if (logged[key] || disabled[key]) return; logged[key] = true; var logger = book.getLogger(); logger.warn.ln(message); }
javascript
function logNotice(book, key, message) { if (logged[key] || disabled[key]) return; logged[key] = true; var logger = book.getLogger(); logger.warn.ln(message); }
[ "function", "logNotice", "(", "book", ",", "key", ",", "message", ")", "{", "if", "(", "logged", "[", "key", "]", "||", "disabled", "[", "key", "]", ")", "return", ";", "logged", "[", "key", "]", "=", "true", ";", "var", "logger", "=", "book", "....
Log a deprecated notice @param {Book|Output} book @param {String} key @param {String} message
[ "Log", "a", "deprecated", "notice" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/deprecate.js#L14-L21
1,137
GitbookIO/gitbook
lib/api/deprecate.js
deprecateMethod
function deprecateMethod(book, key, fn, msg) { return function() { logNotice(book, key, msg); return fn.apply(this, arguments); }; }
javascript
function deprecateMethod(book, key, fn, msg) { return function() { logNotice(book, key, msg); return fn.apply(this, arguments); }; }
[ "function", "deprecateMethod", "(", "book", ",", "key", ",", "fn", ",", "msg", ")", "{", "return", "function", "(", ")", "{", "logNotice", "(", "book", ",", "key", ",", "msg", ")", ";", "return", "fn", ".", "apply", "(", "this", ",", "arguments", "...
Deprecate a function @param {Book|Output} book @param {String} key: unique identitifer for the deprecated @param {Function} fn @param {String} msg: message to print when called @return {Function}
[ "Deprecate", "a", "function" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/deprecate.js#L32-L38
1,138
GitbookIO/gitbook
lib/api/deprecate.js
deprecateField
function deprecateField(book, key, instance, property, value, msg) { var store = undefined; var prepare = function() { if (!is.undefined(store)) return; if (is.fn(value)) store = value(); else store = value; }; var getter = function(){ prepare(); logNotice(boo...
javascript
function deprecateField(book, key, instance, property, value, msg) { var store = undefined; var prepare = function() { if (!is.undefined(store)) return; if (is.fn(value)) store = value(); else store = value; }; var getter = function(){ prepare(); logNotice(boo...
[ "function", "deprecateField", "(", "book", ",", "key", ",", "instance", ",", "property", ",", "value", ",", "msg", ")", "{", "var", "store", "=", "undefined", ";", "var", "prepare", "=", "function", "(", ")", "{", "if", "(", "!", "is", ".", "undefine...
Deprecate a property of an object @param {Book|Output} book @param {String} key: unique identitifer for the deprecated @param {Object} instance @param {String|Function} property @param {String} msg: message to print when called @return {Function}
[ "Deprecate", "a", "property", "of", "an", "object" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/deprecate.js#L50-L80
1,139
GitbookIO/gitbook
lib/api/deprecate.js
deprecateRenamedMethod
function deprecateRenamedMethod(book, key, instance, oldName, newName, msg) { msg = msg || ('"' + oldName + '" is deprecated, use "' + newName + '()" instead'); var fn = objectPath.get(instance, newName); instance[oldName] = deprecateMethod(book, key, fn, msg); }
javascript
function deprecateRenamedMethod(book, key, instance, oldName, newName, msg) { msg = msg || ('"' + oldName + '" is deprecated, use "' + newName + '()" instead'); var fn = objectPath.get(instance, newName); instance[oldName] = deprecateMethod(book, key, fn, msg); }
[ "function", "deprecateRenamedMethod", "(", "book", ",", "key", ",", "instance", ",", "oldName", ",", "newName", ",", "msg", ")", "{", "msg", "=", "msg", "||", "(", "'\"'", "+", "oldName", "+", "'\" is deprecated, use \"'", "+", "newName", "+", "'()\" instead...
Deprecate a method in favor of another one @param {Book} book @param {String} key @param {Object} instance @param {String} oldName @param {String} newName
[ "Deprecate", "a", "method", "in", "favor", "of", "another", "one" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/deprecate.js#L109-L114
1,140
GitbookIO/gitbook
lib/output/modifiers/modifyHTML.js
modifyHTML
function modifyHTML(page, operations) { var html = page.getContent(); var $ = cheerio.load(html); return Promise.forEach(operations, function(op) { return op($); }) .then(function() { var resultHTML = $.html(); return page.set('content', resultHTML); }); }
javascript
function modifyHTML(page, operations) { var html = page.getContent(); var $ = cheerio.load(html); return Promise.forEach(operations, function(op) { return op($); }) .then(function() { var resultHTML = $.html(); return page.set('content', resultHTML); }); }
[ "function", "modifyHTML", "(", "page", ",", "operations", ")", "{", "var", "html", "=", "page", ".", "getContent", "(", ")", ";", "var", "$", "=", "cheerio", ".", "load", "(", "html", ")", ";", "return", "Promise", ".", "forEach", "(", "operations", ...
Apply a list of operations to a page and output the new page. @param {Page} @param {List|Array<Transformation>} @return {Promise<Page>}
[ "Apply", "a", "list", "of", "operations", "to", "a", "page", "and", "output", "the", "new", "page", "." ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/modifiers/modifyHTML.js#L12-L23
1,141
GitbookIO/gitbook
lib/parse/validateConfig.js
validateConfig
function validateConfig(bookJson) { var v = new jsonschema.Validator(); var result = v.validate(bookJson, schema, { propertyName: 'config' }); // Throw error if (result.errors.length > 0) { throw new error.ConfigurationError(new Error(result.errors[0].stack)); } // Insert d...
javascript
function validateConfig(bookJson) { var v = new jsonschema.Validator(); var result = v.validate(bookJson, schema, { propertyName: 'config' }); // Throw error if (result.errors.length > 0) { throw new error.ConfigurationError(new Error(result.errors[0].stack)); } // Insert d...
[ "function", "validateConfig", "(", "bookJson", ")", "{", "var", "v", "=", "new", "jsonschema", ".", "Validator", "(", ")", ";", "var", "result", "=", "v", ".", "validate", "(", "bookJson", ",", "schema", ",", "{", "propertyName", ":", "'config'", "}", ...
Validate a book.json content And return a mix with the default value @param {Object} bookJson @return {Object}
[ "Validate", "a", "book", ".", "json", "content", "And", "return", "a", "mix", "with", "the", "default", "value" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/parse/validateConfig.js#L15-L29
1,142
GitbookIO/gitbook
lib/plugins/locateRootFolder.js
locateRootFolder
function locateRootFolder() { var firstDefaultPlugin = DEFAULT_PLUGINS.first(); var pluginPath = resolve.sync(firstDefaultPlugin.getNpmID() + '/package.json', { basedir: __dirname }); var nodeModules = path.resolve(pluginPath, '../../..'); return nodeModules; }
javascript
function locateRootFolder() { var firstDefaultPlugin = DEFAULT_PLUGINS.first(); var pluginPath = resolve.sync(firstDefaultPlugin.getNpmID() + '/package.json', { basedir: __dirname }); var nodeModules = path.resolve(pluginPath, '../../..'); return nodeModules; }
[ "function", "locateRootFolder", "(", ")", "{", "var", "firstDefaultPlugin", "=", "DEFAULT_PLUGINS", ".", "first", "(", ")", ";", "var", "pluginPath", "=", "resolve", ".", "sync", "(", "firstDefaultPlugin", ".", "getNpmID", "(", ")", "+", "'/package.json'", ","...
Resolve the root folder containing for node_modules since gitbook can be used as a library and dependency can be flattened. @return {String} folderPath
[ "Resolve", "the", "root", "folder", "containing", "for", "node_modules", "since", "gitbook", "can", "be", "used", "as", "a", "library", "and", "dependency", "can", "be", "flattened", "." ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/plugins/locateRootFolder.js#L12-L20
1,143
GitbookIO/gitbook
lib/output/generateBook.js
generateBook
function generateBook(generator, book, options) { options = generator.Options(options); var state = generator.State? generator.State({}) : Immutable.Map(); var start = Date.now(); return Promise( new Output({ book: book, options: options, state: state, ...
javascript
function generateBook(generator, book, options) { options = generator.Options(options); var state = generator.State? generator.State({}) : Immutable.Map(); var start = Date.now(); return Promise( new Output({ book: book, options: options, state: state, ...
[ "function", "generateBook", "(", "generator", ",", "book", ",", "options", ")", "{", "options", "=", "generator", ".", "Options", "(", "options", ")", ";", "var", "state", "=", "generator", ".", "State", "?", "generator", ".", "State", "(", "{", "}", "...
Generate a book using a generator. The overall process is: 1. List and load plugins for this book 2. Call hook "config" 3. Call hook "init" 4. Initialize generator 5. List all assets and pages 6. Copy all assets to output 7. Generate all pages 8. Call hook "finish:before" 9. Finish generation 10. Call hook "finish" ...
[ "Generate", "a", "book", "using", "a", "generator", "." ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/generateBook.js#L155-L191
1,144
GitbookIO/gitbook
lib/api/encodeConfig.js
encodeConfig
function encodeConfig(output, config) { var result = { values: config.getValues().toJS(), get: function(key, defaultValue) { return objectPath.get(result.values, key, defaultValue); }, set: function(key, value) { return objectPath.set(result.values, key, val...
javascript
function encodeConfig(output, config) { var result = { values: config.getValues().toJS(), get: function(key, defaultValue) { return objectPath.get(result.values, key, defaultValue); }, set: function(key, value) { return objectPath.set(result.values, key, val...
[ "function", "encodeConfig", "(", "output", ",", "config", ")", "{", "var", "result", "=", "{", "values", ":", "config", ".", "getValues", "(", ")", ".", "toJS", "(", ")", ",", "get", ":", "function", "(", "key", ",", "defaultValue", ")", "{", "return...
Encode a config object into a JS config api @param {Output} output @param {Config} config @return {Object}
[ "Encode", "a", "config", "object", "into", "a", "JS", "config", "api" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/encodeConfig.js#L11-L34
1,145
GitbookIO/gitbook
lib/modifiers/config/getPluginConfig.js
getPluginConfig
function getPluginConfig(config, pluginName) { var pluginsConfig = config.getValues().get('pluginsConfig'); if (pluginsConfig === undefined) { return {}; } var pluginConf = pluginsConfig.get(pluginName); if (pluginConf === undefined) { return {}; } else { return pluginCon...
javascript
function getPluginConfig(config, pluginName) { var pluginsConfig = config.getValues().get('pluginsConfig'); if (pluginsConfig === undefined) { return {}; } var pluginConf = pluginsConfig.get(pluginName); if (pluginConf === undefined) { return {}; } else { return pluginCon...
[ "function", "getPluginConfig", "(", "config", ",", "pluginName", ")", "{", "var", "pluginsConfig", "=", "config", ".", "getValues", "(", ")", ".", "get", "(", "'pluginsConfig'", ")", ";", "if", "(", "pluginsConfig", "===", "undefined", ")", "{", "return", ...
Return the configuration for a plugin @param {Config} config @param {String} pluginName @return {Object}
[ "Return", "the", "configuration", "for", "a", "plugin" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/modifiers/config/getPluginConfig.js#L7-L18
1,146
GitbookIO/gitbook
lib/json/encodeLanguages.js
encodeLanguages
function encodeLanguages(languages) { var file = languages.getFile(); var list = languages.getList(); return { file: encodeFile(file), list: list .valueSeq() .map(function(lang) { return { id: lang.getID(), titl...
javascript
function encodeLanguages(languages) { var file = languages.getFile(); var list = languages.getList(); return { file: encodeFile(file), list: list .valueSeq() .map(function(lang) { return { id: lang.getID(), titl...
[ "function", "encodeLanguages", "(", "languages", ")", "{", "var", "file", "=", "languages", ".", "getFile", "(", ")", ";", "var", "list", "=", "languages", ".", "getList", "(", ")", ";", "return", "{", "file", ":", "encodeFile", "(", "file", ")", ",", ...
Encode a languages listing to JSON @param {Languages} @return {Object}
[ "Encode", "a", "languages", "listing", "to", "JSON" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/json/encodeLanguages.js#L9-L24
1,147
GitbookIO/gitbook
lib/constants/defaultPlugins.js
createFromDependency
function createFromDependency(pluginName) { var npmID = PluginDependency.nameToNpmID(pluginName); var version = pkg.dependencies[npmID]; return PluginDependency.create(pluginName, version); }
javascript
function createFromDependency(pluginName) { var npmID = PluginDependency.nameToNpmID(pluginName); var version = pkg.dependencies[npmID]; return PluginDependency.create(pluginName, version); }
[ "function", "createFromDependency", "(", "pluginName", ")", "{", "var", "npmID", "=", "PluginDependency", ".", "nameToNpmID", "(", "pluginName", ")", ";", "var", "version", "=", "pkg", ".", "dependencies", "[", "npmID", "]", ";", "return", "PluginDependency", ...
Create a PluginDependency from a dependency of gitbook @param {String} pluginName @return {PluginDependency}
[ "Create", "a", "PluginDependency", "from", "a", "dependency", "of", "gitbook" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/constants/defaultPlugins.js#L11-L16
1,148
GitbookIO/gitbook
lib/parse/parseStructureFile.js
parseFile
function parseFile(fs, file, type) { var filepath = file.getPath(); var parser = file.getParser(); if (!parser) { return Promise.reject( error.FileNotParsableError({ filename: filepath }) ); } return fs.readAsString(filepath) .then(functi...
javascript
function parseFile(fs, file, type) { var filepath = file.getPath(); var parser = file.getParser(); if (!parser) { return Promise.reject( error.FileNotParsableError({ filename: filepath }) ); } return fs.readAsString(filepath) .then(functi...
[ "function", "parseFile", "(", "fs", ",", "file", ",", "type", ")", "{", "var", "filepath", "=", "file", ".", "getPath", "(", ")", ";", "var", "parser", "=", "file", ".", "getParser", "(", ")", ";", "if", "(", "!", "parser", ")", "{", "return", "P...
Parse a ParsableFile using a specific method @param {FS} fs @param {ParsableFile} file @param {String} type @return {Promise<Array<String, List|Map>>}
[ "Parse", "a", "ParsableFile", "using", "a", "specific", "method" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/parse/parseStructureFile.js#L13-L45
1,149
GitbookIO/gitbook
lib/plugins/listFilters.js
listFilters
function listFilters(plugins) { return plugins .reverse() .reduce(function(result, plugin) { return result.merge(plugin.getFilters()); }, Immutable.Map()); }
javascript
function listFilters(plugins) { return plugins .reverse() .reduce(function(result, plugin) { return result.merge(plugin.getFilters()); }, Immutable.Map()); }
[ "function", "listFilters", "(", "plugins", ")", "{", "return", "plugins", ".", "reverse", "(", ")", ".", "reduce", "(", "function", "(", "result", ",", "plugin", ")", "{", "return", "result", ".", "merge", "(", "plugin", ".", "getFilters", "(", ")", ")...
List filters from a list of plugins @param {OrderedMap<String:Plugin>} @return {Map<String:Function>}
[ "List", "filters", "from", "a", "list", "of", "plugins" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/plugins/listFilters.js#L9-L15
1,150
GitbookIO/gitbook
lib/output/preparePlugins.js
preparePlugins
function preparePlugins(output) { var book = output.getBook(); return Promise() // Only load plugins for main book .then(function() { if (book.isLanguageBook()) { return output.getPlugins(); } else { return Plugins.loadForBook(book); } }) // Upd...
javascript
function preparePlugins(output) { var book = output.getBook(); return Promise() // Only load plugins for main book .then(function() { if (book.isLanguageBook()) { return output.getPlugins(); } else { return Plugins.loadForBook(book); } }) // Upd...
[ "function", "preparePlugins", "(", "output", ")", "{", "var", "book", "=", "output", ".", "getBook", "(", ")", ";", "return", "Promise", "(", ")", "// Only load plugins for main book", ".", "then", "(", "function", "(", ")", "{", "if", "(", "book", ".", ...
Load and setup plugins @param {Output} @return {Promise<Output>}
[ "Load", "and", "setup", "plugins" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/preparePlugins.js#L10-L34
1,151
GitbookIO/gitbook
lib/json/encodeSummary.js
encodeSummary
function encodeSummary(summary) { var file = summary.getFile(); var parts = summary.getParts(); return { file: encodeFile(file), parts: parts.map(encodeSummaryPart).toJS() }; }
javascript
function encodeSummary(summary) { var file = summary.getFile(); var parts = summary.getParts(); return { file: encodeFile(file), parts: parts.map(encodeSummaryPart).toJS() }; }
[ "function", "encodeSummary", "(", "summary", ")", "{", "var", "file", "=", "summary", ".", "getFile", "(", ")", ";", "var", "parts", "=", "summary", ".", "getParts", "(", ")", ";", "return", "{", "file", ":", "encodeFile", "(", "file", ")", ",", "par...
Encode a summary to JSON @param {Summary} @return {Object}
[ "Encode", "a", "summary", "to", "JSON" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/json/encodeSummary.js#L10-L18
1,152
GitbookIO/gitbook
lib/modifiers/summary/indexArticleLevels.js
indexArticleLevels
function indexArticleLevels(article, baseLevel) { baseLevel = baseLevel || article.getLevel(); var articles = article.getArticles(); articles = articles.map(function(inner, i) { return indexArticleLevels(inner, baseLevel + '.' + (i + 1)); }); return article.merge({ level: baseLevel...
javascript
function indexArticleLevels(article, baseLevel) { baseLevel = baseLevel || article.getLevel(); var articles = article.getArticles(); articles = articles.map(function(inner, i) { return indexArticleLevels(inner, baseLevel + '.' + (i + 1)); }); return article.merge({ level: baseLevel...
[ "function", "indexArticleLevels", "(", "article", ",", "baseLevel", ")", "{", "baseLevel", "=", "baseLevel", "||", "article", ".", "getLevel", "(", ")", ";", "var", "articles", "=", "article", ".", "getArticles", "(", ")", ";", "articles", "=", "articles", ...
Index levels in an article tree @param {Article} @param {String} baseLevel @return {Article}
[ "Index", "levels", "in", "an", "article", "tree" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/modifiers/summary/indexArticleLevels.js#L9-L21
1,153
GitbookIO/gitbook
lib/output/callHook.js
callHook
function callHook(name, getArgument, handleResult, output) { getArgument = getArgument || defaultGetArgument; handleResult = handleResult || defaultHandleResult; var logger = output.getLogger(); var plugins = output.getPlugins(); logger.debug.ln('calling hook "' + name + '"'); // Create the J...
javascript
function callHook(name, getArgument, handleResult, output) { getArgument = getArgument || defaultGetArgument; handleResult = handleResult || defaultHandleResult; var logger = output.getLogger(); var plugins = output.getPlugins(); logger.debug.ln('calling hook "' + name + '"'); // Create the J...
[ "function", "callHook", "(", "name", ",", "getArgument", ",", "handleResult", ",", "output", ")", "{", "getArgument", "=", "getArgument", "||", "defaultGetArgument", ";", "handleResult", "=", "handleResult", "||", "defaultHandleResult", ";", "var", "logger", "=", ...
Call a "global" hook for an output @param {String} name @param {Function(Output) -> Mixed} getArgument @param {Function(Output, result) -> Output} handleResult @param {Output} output @return {Promise<Output>}
[ "Call", "a", "global", "hook", "for", "an", "output" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/callHook.js#L22-L58
1,154
GitbookIO/gitbook
lib/cli/server.js
redirect
function redirect() { var resultURL = urlTransform(req.url, function(parsed) { parsed.pathname += '/'; return parsed; }); res.statusCode = 301; res.setHeader('Location', resultURL); res.end('Redirect...
javascript
function redirect() { var resultURL = urlTransform(req.url, function(parsed) { parsed.pathname += '/'; return parsed; }); res.statusCode = 301; res.setHeader('Location', resultURL); res.end('Redirect...
[ "function", "redirect", "(", ")", "{", "var", "resultURL", "=", "urlTransform", "(", "req", ".", "url", ",", "function", "(", "parsed", ")", "{", "parsed", ".", "pathname", "+=", "'/'", ";", "return", "parsed", ";", "}", ")", ";", "res", ".", "status...
Redirect to directory's index.html
[ "Redirect", "to", "directory", "s", "index", ".", "html" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/cli/server.js#L73-L82
1,155
GitbookIO/gitbook
lib/modifiers/summary/mergeAtLevel.js
editArticleInList
function editArticleInList(articles, level, newArticle) { return articles.map(function(article) { var articleLevel = article.getLevel(); if (articleLevel === level) { // it is the article to edit return article.merge(newArticle); } else if (level.indexOf(articleLevel...
javascript
function editArticleInList(articles, level, newArticle) { return articles.map(function(article) { var articleLevel = article.getLevel(); if (articleLevel === level) { // it is the article to edit return article.merge(newArticle); } else if (level.indexOf(articleLevel...
[ "function", "editArticleInList", "(", "articles", ",", "level", ",", "newArticle", ")", "{", "return", "articles", ".", "map", "(", "function", "(", "article", ")", "{", "var", "articleLevel", "=", "article", ".", "getLevel", "(", ")", ";", "if", "(", "a...
Edit a list of articles @param {List<Article>} articles @param {String} level @param {Article} newArticle @return {List<Article>}
[ "Edit", "a", "list", "of", "articles" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/modifiers/summary/mergeAtLevel.js#L10-L26
1,156
GitbookIO/gitbook
lib/modifiers/summary/mergeAtLevel.js
editArticleInPart
function editArticleInPart(part, level, newArticle) { var articles = part.getArticles(); articles = editArticleInList(articles, level, newArticle); return part.set('articles', articles); }
javascript
function editArticleInPart(part, level, newArticle) { var articles = part.getArticles(); articles = editArticleInList(articles, level, newArticle); return part.set('articles', articles); }
[ "function", "editArticleInPart", "(", "part", ",", "level", ",", "newArticle", ")", "{", "var", "articles", "=", "part", ".", "getArticles", "(", ")", ";", "articles", "=", "editArticleInList", "(", "articles", ",", "level", ",", "newArticle", ")", ";", "r...
Edit an article in a part @param {Part} part @param {String} level @param {Article} newArticle @return {Part}
[ "Edit", "an", "article", "in", "a", "part" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/modifiers/summary/mergeAtLevel.js#L37-L42
1,157
GitbookIO/gitbook
lib/modifiers/summary/mergeAtLevel.js
mergeAtLevel
function mergeAtLevel(summary, level, newValue) { var levelParts = level.split('.'); var partIndex = Number(levelParts[0]) -1; var parts = summary.getParts(); var part = parts.get(partIndex); if (!part) { return summary; } var isEditingPart = levelParts.length < 2; if (isEditin...
javascript
function mergeAtLevel(summary, level, newValue) { var levelParts = level.split('.'); var partIndex = Number(levelParts[0]) -1; var parts = summary.getParts(); var part = parts.get(partIndex); if (!part) { return summary; } var isEditingPart = levelParts.length < 2; if (isEditin...
[ "function", "mergeAtLevel", "(", "summary", ",", "level", ",", "newValue", ")", "{", "var", "levelParts", "=", "level", ".", "split", "(", "'.'", ")", ";", "var", "partIndex", "=", "Number", "(", "levelParts", "[", "0", "]", ")", "-", "1", ";", "var"...
Edit an article, or a part, in a summary. Does a shallow merge. @param {Summary} summary @param {String} level @param {Article|Part} newValue @return {Summary}
[ "Edit", "an", "article", "or", "a", "part", "in", "a", "summary", ".", "Does", "a", "shallow", "merge", "." ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/modifiers/summary/mergeAtLevel.js#L53-L72
1,158
GitbookIO/gitbook
lib/utils/location.js
isExternal
function isExternal(href) { try { return Boolean(url.parse(href).protocol) && !isDataURI(href); } catch(err) { return false; } }
javascript
function isExternal(href) { try { return Boolean(url.parse(href).protocol) && !isDataURI(href); } catch(err) { return false; } }
[ "function", "isExternal", "(", "href", ")", "{", "try", "{", "return", "Boolean", "(", "url", ".", "parse", "(", "href", ")", ".", "protocol", ")", "&&", "!", "isDataURI", "(", "href", ")", ";", "}", "catch", "(", "err", ")", "{", "return", "false"...
Is the url an external url
[ "Is", "the", "url", "an", "external", "url" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/location.js#L5-L11
1,159
GitbookIO/gitbook
lib/utils/location.js
isAnchor
function isAnchor(href) { try { var parsed = url.parse(href); return !!(!parsed.protocol && !parsed.path && parsed.hash); } catch(err) { return false; } }
javascript
function isAnchor(href) { try { var parsed = url.parse(href); return !!(!parsed.protocol && !parsed.path && parsed.hash); } catch(err) { return false; } }
[ "function", "isAnchor", "(", "href", ")", "{", "try", "{", "var", "parsed", "=", "url", ".", "parse", "(", "href", ")", ";", "return", "!", "!", "(", "!", "parsed", ".", "protocol", "&&", "!", "parsed", ".", "path", "&&", "parsed", ".", "hash", "...
Return true if the link is an achor
[ "Return", "true", "if", "the", "link", "is", "an", "achor" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/location.js#L28-L35
1,160
GitbookIO/gitbook
lib/utils/location.js
toAbsolute
function toAbsolute(_href, dir, outdir) { if (isExternal(_href) || isDataURI(_href)) { return _href; } outdir = outdir == undefined? dir : outdir; _href = normalize(_href); dir = normalize(dir); outdir = normalize(outdir); // Path "_href" inside the base folder var hrefInRoot ...
javascript
function toAbsolute(_href, dir, outdir) { if (isExternal(_href) || isDataURI(_href)) { return _href; } outdir = outdir == undefined? dir : outdir; _href = normalize(_href); dir = normalize(dir); outdir = normalize(outdir); // Path "_href" inside the base folder var hrefInRoot ...
[ "function", "toAbsolute", "(", "_href", ",", "dir", ",", "outdir", ")", "{", "if", "(", "isExternal", "(", "_href", ")", "||", "isDataURI", "(", "_href", ")", ")", "{", "return", "_href", ";", "}", "outdir", "=", "outdir", "==", "undefined", "?", "di...
Convert a relative path to absolute @param {String} href @param {String} dir: directory parent of the file currently in rendering process @param {String} outdir: directory parent from the html output @return {String}
[ "Convert", "a", "relative", "path", "to", "absolute" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/location.js#L65-L89
1,161
GitbookIO/gitbook
lib/parse/parsePageFromString.js
parsePageFromString
function parsePageFromString(page, content) { // Parse page YAML var parsed = fm(content); return page.merge({ content: parsed.body, attributes: Immutable.fromJS(parsed.attributes), dir: direction(parsed.body) }); }
javascript
function parsePageFromString(page, content) { // Parse page YAML var parsed = fm(content); return page.merge({ content: parsed.body, attributes: Immutable.fromJS(parsed.attributes), dir: direction(parsed.body) }); }
[ "function", "parsePageFromString", "(", "page", ",", "content", ")", "{", "// Parse page YAML", "var", "parsed", "=", "fm", "(", "content", ")", ";", "return", "page", ".", "merge", "(", "{", "content", ":", "parsed", ".", "body", ",", "attributes", ":", ...
Parse a page, its content and the YAMl header @param {Page} page @return {Page}
[ "Parse", "a", "page", "its", "content", "and", "the", "YAMl", "header" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/parse/parsePageFromString.js#L11-L20
1,162
GitbookIO/gitbook
lib/output/json/onFinish.js
onFinish
function onFinish(output) { var book = output.getBook(); var outputRoot = output.getRoot(); if (!book.isMultilingual()) { return Promise(output); } // Get main language var languages = book.getLanguages(); var mainLanguage = languages.getDefaultLanguage(); // Read the main JSO...
javascript
function onFinish(output) { var book = output.getBook(); var outputRoot = output.getRoot(); if (!book.isMultilingual()) { return Promise(output); } // Get main language var languages = book.getLanguages(); var mainLanguage = languages.getDefaultLanguage(); // Read the main JSO...
[ "function", "onFinish", "(", "output", ")", "{", "var", "book", "=", "output", ".", "getBook", "(", ")", ";", "var", "outputRoot", "=", "output", ".", "getRoot", "(", ")", ";", "if", "(", "!", "book", ".", "isMultilingual", "(", ")", ")", "{", "ret...
Finish the generation @param {Output} @return {Output}
[ "Finish", "the", "generation" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/json/onFinish.js#L13-L45
1,163
GitbookIO/gitbook
lib/modifiers/summary/removeArticle.js
removeArticle
function removeArticle(summary, level) { // Coerce to level level = is.string(level)? level : level.getLevel(); var parent = summary.getParent(level); var articles = parent.getArticles(); // Find the index to remove var index = articles.findIndex(function(art) { return art.getLevel() =...
javascript
function removeArticle(summary, level) { // Coerce to level level = is.string(level)? level : level.getLevel(); var parent = summary.getParent(level); var articles = parent.getArticles(); // Find the index to remove var index = articles.findIndex(function(art) { return art.getLevel() =...
[ "function", "removeArticle", "(", "summary", ",", "level", ")", "{", "// Coerce to level", "level", "=", "is", ".", "string", "(", "level", ")", "?", "level", ":", "level", ".", "getLevel", "(", ")", ";", "var", "parent", "=", "summary", ".", "getParent"...
Remove an article from a level. @param {Summary} summary @param {String|SummaryArticle} level: level to remove @return {Summary}
[ "Remove", "an", "article", "from", "a", "level", "." ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/modifiers/summary/removeArticle.js#L12-L35
1,164
GitbookIO/gitbook
lib/modifiers/summary/editPartTitle.js
editPartTitle
function editPartTitle(summary, index, newTitle) { var parts = summary.getParts(); var part = parts.get(index); if (!part) { return summary; } part = part.set('title', newTitle); parts = parts.set(index, part); return summary.set('parts', parts); }
javascript
function editPartTitle(summary, index, newTitle) { var parts = summary.getParts(); var part = parts.get(index); if (!part) { return summary; } part = part.set('title', newTitle); parts = parts.set(index, part); return summary.set('parts', parts); }
[ "function", "editPartTitle", "(", "summary", ",", "index", ",", "newTitle", ")", "{", "var", "parts", "=", "summary", ".", "getParts", "(", ")", ";", "var", "part", "=", "parts", ".", "get", "(", "index", ")", ";", "if", "(", "!", "part", ")", "{",...
Edit title of a part in the summary @param {Summary} summary @param {Number} index @param {String} newTitle @return {Summary}
[ "Edit", "title", "of", "a", "part", "in", "the", "summary" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/modifiers/summary/editPartTitle.js#L9-L21
1,165
GitbookIO/gitbook
lib/output/preparePages.js
preparePages
function preparePages(output) { var book = output.getBook(); var logger = book.getLogger(); if (book.isMultilingual()) { return Promise(output); } return Parse.parsePagesList(book) .then(function(pages) { logger.info.ln('found', pages.size, 'pages'); return output.set(...
javascript
function preparePages(output) { var book = output.getBook(); var logger = book.getLogger(); if (book.isMultilingual()) { return Promise(output); } return Parse.parsePagesList(book) .then(function(pages) { logger.info.ln('found', pages.size, 'pages'); return output.set(...
[ "function", "preparePages", "(", "output", ")", "{", "var", "book", "=", "output", ".", "getBook", "(", ")", ";", "var", "logger", "=", "book", ".", "getLogger", "(", ")", ";", "if", "(", "book", ".", "isMultilingual", "(", ")", ")", "{", "return", ...
List and prepare all pages @param {Output} @return {Promise<Output>}
[ "List", "and", "prepare", "all", "pages" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/preparePages.js#L10-L24
1,166
GitbookIO/gitbook
lib/output/modifiers/svgToPng.js
svgToPng
function svgToPng(rootFolder, currentFile, $) { var currentDirectory = path.dirname(currentFile); return editHTMLElement($, 'img', function($img) { var src = $img.attr('src'); if (path.extname(src) !== '.svg') { return; } // Calcul absolute path for this src...
javascript
function svgToPng(rootFolder, currentFile, $) { var currentDirectory = path.dirname(currentFile); return editHTMLElement($, 'img', function($img) { var src = $img.attr('src'); if (path.extname(src) !== '.svg') { return; } // Calcul absolute path for this src...
[ "function", "svgToPng", "(", "rootFolder", ",", "currentFile", ",", "$", ")", "{", "var", "currentDirectory", "=", "path", ".", "dirname", "(", "currentFile", ")", ";", "return", "editHTMLElement", "(", "$", ",", "'img'", ",", "function", "(", "$img", ")",...
Convert all SVG images to PNG @param {String} rootFolder @param {HTMLDom} $ @return {Promise}
[ "Convert", "all", "SVG", "images", "to", "PNG" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/modifiers/svgToPng.js#L17-L50
1,167
GitbookIO/gitbook
lib/plugins/installPlugins.js
installPlugins
function installPlugins(book) { var logger = book.getLogger(); var config = book.getConfig(); var plugins = config.getPluginDependencies(); // Remove default plugins // (only if version is same as installed) plugins = plugins.filterNot(function(plugin) { var dependency = DEFAULT_PLUGINS...
javascript
function installPlugins(book) { var logger = book.getLogger(); var config = book.getConfig(); var plugins = config.getPluginDependencies(); // Remove default plugins // (only if version is same as installed) plugins = plugins.filterNot(function(plugin) { var dependency = DEFAULT_PLUGINS...
[ "function", "installPlugins", "(", "book", ")", "{", "var", "logger", "=", "book", ".", "getLogger", "(", ")", ";", "var", "config", "=", "book", ".", "getConfig", "(", ")", ";", "var", "plugins", "=", "config", ".", "getPluginDependencies", "(", ")", ...
Install plugin requirements for a book @param {Book} @return {Promise<Number>}
[ "Install", "plugin", "requirements", "for", "a", "book" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/plugins/installPlugins.js#L13-L46
1,168
GitbookIO/gitbook
lib/modifiers/config/removePlugin.js
removePlugin
function removePlugin(config, pluginName) { var deps = config.getPluginDependencies(); // For default plugin, we have to disable it instead of removing from the list if (isDefaultPlugin(pluginName)) { return togglePlugin(config, pluginName, false); } // Remove the dependency from the list ...
javascript
function removePlugin(config, pluginName) { var deps = config.getPluginDependencies(); // For default plugin, we have to disable it instead of removing from the list if (isDefaultPlugin(pluginName)) { return togglePlugin(config, pluginName, false); } // Remove the dependency from the list ...
[ "function", "removePlugin", "(", "config", ",", "pluginName", ")", "{", "var", "deps", "=", "config", ".", "getPluginDependencies", "(", ")", ";", "// For default plugin, we have to disable it instead of removing from the list", "if", "(", "isDefaultPlugin", "(", "pluginN...
Remove a plugin from a book's configuration @param {Config} config @param {String} plugin @return {Config}
[ "Remove", "a", "plugin", "from", "a", "book", "s", "configuration" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/modifiers/config/removePlugin.js#L10-L23
1,169
GitbookIO/gitbook
lib/api/decodePage.js
decodePage
function decodePage(output, page, result) { var originalContent = page.getContent(); // No returned value // Existing content will be used if (!result) { return page; } deprecate.disable('page.sections'); // GitBook 3 // Use returned page.content if different from original con...
javascript
function decodePage(output, page, result) { var originalContent = page.getContent(); // No returned value // Existing content will be used if (!result) { return page; } deprecate.disable('page.sections'); // GitBook 3 // Use returned page.content if different from original con...
[ "function", "decodePage", "(", "output", ",", "page", ",", "result", ")", "{", "var", "originalContent", "=", "page", ".", "getContent", "(", ")", ";", "// No returned value", "// Existing content will be used", "if", "(", "!", "result", ")", "{", "return", "p...
Decode changes from a JS API to a page object. Only the content can be edited by plugin's hooks. @param {Output} output @param {Page} page: page instance to edit @param {Object} result: result from API @return {Page}
[ "Decode", "changes", "from", "a", "JS", "API", "to", "a", "page", "object", ".", "Only", "the", "content", "can", "be", "edited", "by", "plugin", "s", "hooks", "." ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/api/decodePage.js#L12-L42
1,170
GitbookIO/gitbook
lib/utils/command.js
spawnCmd
function spawnCmd(command, args, options) { var d = Promise.defer(); var child = spawn(command, args, options); child.on('error', function(error) { return d.reject(error); }); child.stdout.on('data', function (data) { d.notify(data); }); child.stderr.on('data', function (d...
javascript
function spawnCmd(command, args, options) { var d = Promise.defer(); var child = spawn(command, args, options); child.on('error', function(error) { return d.reject(error); }); child.stdout.on('data', function (data) { d.notify(data); }); child.stderr.on('data', function (d...
[ "function", "spawnCmd", "(", "command", ",", "args", ",", "options", ")", "{", "var", "d", "=", "Promise", ".", "defer", "(", ")", ";", "var", "child", "=", "spawn", "(", "command", ",", "args", ",", "options", ")", ";", "child", ".", "on", "(", ...
Spawn an executable @param {String} command @param {Array} args @param {Object} options @return {Promise}
[ "Spawn", "an", "executable" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/command.js#L44-L69
1,171
GitbookIO/gitbook
lib/utils/command.js
escapeShellArg
function escapeShellArg(value) { if (is.number(value)) { return value; } value = String(value); value = value.replace(/"/g, '\\"'); return '"' + value + '"'; }
javascript
function escapeShellArg(value) { if (is.number(value)) { return value; } value = String(value); value = value.replace(/"/g, '\\"'); return '"' + value + '"'; }
[ "function", "escapeShellArg", "(", "value", ")", "{", "if", "(", "is", ".", "number", "(", "value", ")", ")", "{", "return", "value", ";", "}", "value", "=", "String", "(", "value", ")", ";", "value", "=", "value", ".", "replace", "(", "/", "\"", ...
Transform an option object to a command line string @param {String|number} value @param {String}
[ "Transform", "an", "option", "object", "to", "a", "command", "line", "string" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/command.js#L77-L86
1,172
GitbookIO/gitbook
lib/utils/command.js
optionsToShellArgs
function optionsToShellArgs(options) { var result = []; for (var key in options) { var value = options[key]; if (value === null || value === undefined || value === false) { continue; } if (is.bool(value)) { result.push(key); } else { ...
javascript
function optionsToShellArgs(options) { var result = []; for (var key in options) { var value = options[key]; if (value === null || value === undefined || value === false) { continue; } if (is.bool(value)) { result.push(key); } else { ...
[ "function", "optionsToShellArgs", "(", "options", ")", "{", "var", "result", "=", "[", "]", ";", "for", "(", "var", "key", "in", "options", ")", "{", "var", "value", "=", "options", "[", "key", "]", ";", "if", "(", "value", "===", "null", "||", "va...
Transform a map of options into a command line arguments string @param {Object} options @return {String}
[ "Transform", "a", "map", "of", "options", "into", "a", "command", "line", "arguments", "string" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/command.js#L94-L112
1,173
GitbookIO/gitbook
lib/output/website/onInit.js
onInit
function onInit(output) { return Promise(output) .then(prepareI18n) .then(prepareResources) .then(copyPluginAssets); }
javascript
function onInit(output) { return Promise(output) .then(prepareI18n) .then(prepareResources) .then(copyPluginAssets); }
[ "function", "onInit", "(", "output", ")", "{", "return", "Promise", "(", "output", ")", ".", "then", "(", "prepareI18n", ")", ".", "then", "(", "prepareResources", ")", ".", "then", "(", "copyPluginAssets", ")", ";", "}" ]
Initialize the generator @param {Output} @return {Output}
[ "Initialize", "the", "generator" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/website/onInit.js#L13-L18
1,174
GitbookIO/gitbook
lib/output/callPageHook.js
callPageHook
function callPageHook(name, output, page) { return callHook( name, function(out) { return Api.encodePage(out, page); }, function(out, result) { return Api.decodePage(out, page, result); }, output ); }
javascript
function callPageHook(name, output, page) { return callHook( name, function(out) { return Api.encodePage(out, page); }, function(out, result) { return Api.decodePage(out, page, result); }, output ); }
[ "function", "callPageHook", "(", "name", ",", "output", ",", "page", ")", "{", "return", "callHook", "(", "name", ",", "function", "(", "out", ")", "{", "return", "Api", ".", "encodePage", "(", "out", ",", "page", ")", ";", "}", ",", "function", "(",...
Call a hook for a specific page @param {String} name @param {Output} output @param {Page} page @return {Promise<Page>}
[ "Call", "a", "hook", "for", "a", "specific", "page" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/output/callPageHook.js#L12-L26
1,175
GitbookIO/gitbook
lib/utils/reducedObject.js
reducedObject
function reducedObject(defaultVersion, currentVersion) { if(defaultVersion === undefined) { return currentVersion; } return currentVersion.reduce(function(result, value, key) { var defaultValue = defaultVersion.get(key); if (Immutable.Map.isMap(value)) { var diffs = red...
javascript
function reducedObject(defaultVersion, currentVersion) { if(defaultVersion === undefined) { return currentVersion; } return currentVersion.reduce(function(result, value, key) { var defaultValue = defaultVersion.get(key); if (Immutable.Map.isMap(value)) { var diffs = red...
[ "function", "reducedObject", "(", "defaultVersion", ",", "currentVersion", ")", "{", "if", "(", "defaultVersion", "===", "undefined", ")", "{", "return", "currentVersion", ";", "}", "return", "currentVersion", ".", "reduce", "(", "function", "(", "result", ",", ...
Reduce the difference between a map and its default version @param {Map} defaultVersion @param {Map} currentVersion @return {Map} The properties of currentVersion that differs from defaultVersion
[ "Reduce", "the", "difference", "between", "a", "map", "and", "its", "default", "version" ]
6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4
https://github.com/GitbookIO/gitbook/blob/6c6ef7f4af32a2977e44dd23d3feb6ebf28970f4/lib/utils/reducedObject.js#L9-L31
1,176
ksky521/nodeppt
packages/nodeppt-serve/config/app.js
ensureRelative
function ensureRelative(outputDir, p) { if (path.isAbsolute(p)) { return path.relative(outputDir, p); } else { return p; } }
javascript
function ensureRelative(outputDir, p) { if (path.isAbsolute(p)) { return path.relative(outputDir, p); } else { return p; } }
[ "function", "ensureRelative", "(", "outputDir", ",", "p", ")", "{", "if", "(", "path", ".", "isAbsolute", "(", "p", ")", ")", "{", "return", "path", ".", "relative", "(", "outputDir", ",", "p", ")", ";", "}", "else", "{", "return", "p", ";", "}", ...
ensure the filename passed to html-webpack-plugin is a relative path because it cannot correctly handle absolute paths
[ "ensure", "the", "filename", "passed", "to", "html", "-", "webpack", "-", "plugin", "is", "a", "relative", "path", "because", "it", "cannot", "correctly", "handle", "absolute", "paths" ]
ca77e29ef818c08b0522b31e3925b073cf159b9c
https://github.com/ksky521/nodeppt/blob/ca77e29ef818c08b0522b31e3925b073cf159b9c/packages/nodeppt-serve/config/app.js#L9-L15
1,177
ksky521/nodeppt
packages/nodeppt-parser/lib/markdown/attrs/index.js
get
function get(arr, n) { return n >= 0 ? arr[n] : arr[arr.length + n]; }
javascript
function get(arr, n) { return n >= 0 ? arr[n] : arr[arr.length + n]; }
[ "function", "get", "(", "arr", ",", "n", ")", "{", "return", "n", ">=", "0", "?", "arr", "[", "n", "]", ":", "arr", "[", "arr", ".", "length", "+", "n", "]", ";", "}" ]
Get n item of array. Supports negative n, where -1 is last element in array. @param {array} arr @param {number} n
[ "Get", "n", "item", "of", "array", ".", "Supports", "negative", "n", "where", "-", "1", "is", "last", "element", "in", "array", "." ]
ca77e29ef818c08b0522b31e3925b073cf159b9c
https://github.com/ksky521/nodeppt/blob/ca77e29ef818c08b0522b31e3925b073cf159b9c/packages/nodeppt-parser/lib/markdown/attrs/index.js#L158-L160
1,178
ksky521/nodeppt
packages/nodeppt-parser/lib/markdown/prism.js
selectLanguage
function selectLanguage(options, lang) { let langToUse = lang; if (langToUse === '' && options.defaultLanguageForUnspecified !== undefined) { langToUse = options.defaultLanguageForUnspecified; } let prismLang = loadPrismLang(langToUse); if (prismLang === undefined && options.defaultLanguageF...
javascript
function selectLanguage(options, lang) { let langToUse = lang; if (langToUse === '' && options.defaultLanguageForUnspecified !== undefined) { langToUse = options.defaultLanguageForUnspecified; } let prismLang = loadPrismLang(langToUse); if (prismLang === undefined && options.defaultLanguageF...
[ "function", "selectLanguage", "(", "options", ",", "lang", ")", "{", "let", "langToUse", "=", "lang", ";", "if", "(", "langToUse", "===", "''", "&&", "options", ".", "defaultLanguageForUnspecified", "!==", "undefined", ")", "{", "langToUse", "=", "options", ...
Select the language to use for highlighting, based on the provided options and the specified language. @param {Object} options The options that were used to initialise the plugin. @param {String} lang Code of the language to highlight the text in. @return {Array} An array where the first element is the name of the lan...
[ "Select", "the", "language", "to", "use", "for", "highlighting", "based", "on", "the", "provided", "options", "and", "the", "specified", "language", "." ]
ca77e29ef818c08b0522b31e3925b073cf159b9c
https://github.com/ksky521/nodeppt/blob/ca77e29ef818c08b0522b31e3925b073cf159b9c/packages/nodeppt-parser/lib/markdown/prism.js#L80-L91
1,179
ksky521/nodeppt
packages/nodeppt-parser/lib/markdown/prism.js
checkLanguageOption
function checkLanguageOption(options, optionName) { const language = options[optionName]; if (language !== undefined && loadPrismLang(language) === undefined) { throw new Error(`Bad option ${optionName}: There is no Prism language '${language}'.`); } }
javascript
function checkLanguageOption(options, optionName) { const language = options[optionName]; if (language !== undefined && loadPrismLang(language) === undefined) { throw new Error(`Bad option ${optionName}: There is no Prism language '${language}'.`); } }
[ "function", "checkLanguageOption", "(", "options", ",", "optionName", ")", "{", "const", "language", "=", "options", "[", "optionName", "]", ";", "if", "(", "language", "!==", "undefined", "&&", "loadPrismLang", "(", "language", ")", "===", "undefined", ")", ...
Checks whether an option represents a valid Prism language @param {MarkdownItPrismOptions} options The options that have been used to initialise the plugin. @param optionName The key of the option insides {@code options} that shall be checked. @throws {Error} If the option is not set to a valid Prism language.
[ "Checks", "whether", "an", "option", "represents", "a", "valid", "Prism", "language" ]
ca77e29ef818c08b0522b31e3925b073cf159b9c
https://github.com/ksky521/nodeppt/blob/ca77e29ef818c08b0522b31e3925b073cf159b9c/packages/nodeppt-parser/lib/markdown/prism.js#L152-L157
1,180
ksky521/nodeppt
packages/nodeppt-parser/lib/markdown/plus-list.js
applyClass
function applyClass(token) { // init attributes token.attrs = token.attrs || []; // get index of class attribute let keys = token.attrs.map(arr => arr[0]); let idx = keys.indexOf('class'); if (idx === -1) { // Add class attribute if not defined token.attrs.push(['class', classN...
javascript
function applyClass(token) { // init attributes token.attrs = token.attrs || []; // get index of class attribute let keys = token.attrs.map(arr => arr[0]); let idx = keys.indexOf('class'); if (idx === -1) { // Add class attribute if not defined token.attrs.push(['class', classN...
[ "function", "applyClass", "(", "token", ")", "{", "// init attributes", "token", ".", "attrs", "=", "token", ".", "attrs", "||", "[", "]", ";", "// get index of class attribute", "let", "keys", "=", "token", ".", "attrs", ".", "map", "(", "arr", "=>", "arr...
Adds class to token @param {any} token @param {string} className
[ "Adds", "class", "to", "token" ]
ca77e29ef818c08b0522b31e3925b073cf159b9c
https://github.com/ksky521/nodeppt/blob/ca77e29ef818c08b0522b31e3925b073cf159b9c/packages/nodeppt-parser/lib/markdown/plus-list.js#L17-L39
1,181
react-bootstrap/react-bootstrap
www/src/components/SideNav.js
attachSearch
function attachSearch(ref) { if (ref && window) import('docsearch.js').then(({ default: docsearch }) => { docsearch({ apiKey: '00f98b765b687b91399288e7c4c68ce1', indexName: 'react_bootstrap_v4', inputSelector: `#${ref.id}`, debug: process.env.NODE_ENV !== 'production', // Set...
javascript
function attachSearch(ref) { if (ref && window) import('docsearch.js').then(({ default: docsearch }) => { docsearch({ apiKey: '00f98b765b687b91399288e7c4c68ce1', indexName: 'react_bootstrap_v4', inputSelector: `#${ref.id}`, debug: process.env.NODE_ENV !== 'production', // Set...
[ "function", "attachSearch", "(", "ref", ")", "{", "if", "(", "ref", "&&", "window", ")", "import", "(", "'docsearch.js'", ")", ".", "then", "(", "(", "{", "default", ":", "docsearch", "}", ")", "=>", "{", "docsearch", "(", "{", "apiKey", ":", "'00f98...
We need to configure this
[ "We", "need", "to", "configure", "this" ]
f0dc81f91ae90eb54bd1e4c04fa9419872d347dc
https://github.com/react-bootstrap/react-bootstrap/blob/f0dc81f91ae90eb54bd1e4c04fa9419872d347dc/www/src/components/SideNav.js#L141-L151
1,182
react-bootstrap/react-bootstrap
src/utils/ElementChildren.js
map
function map(children, func) { let index = 0; return React.Children.map(children, child => React.isValidElement(child) ? func(child, index++) : child, ); }
javascript
function map(children, func) { let index = 0; return React.Children.map(children, child => React.isValidElement(child) ? func(child, index++) : child, ); }
[ "function", "map", "(", "children", ",", "func", ")", "{", "let", "index", "=", "0", ";", "return", "React", ".", "Children", ".", "map", "(", "children", ",", "child", "=>", "React", ".", "isValidElement", "(", "child", ")", "?", "func", "(", "child...
Iterates through children that are typically specified as `props.children`, but only maps over children that are "valid elements". The mapFunction provided index will be normalised to the components mapped, so an invalid component would not increase the index.
[ "Iterates", "through", "children", "that", "are", "typically", "specified", "as", "props", ".", "children", "but", "only", "maps", "over", "children", "that", "are", "valid", "elements", "." ]
f0dc81f91ae90eb54bd1e4c04fa9419872d347dc
https://github.com/react-bootstrap/react-bootstrap/blob/f0dc81f91ae90eb54bd1e4c04fa9419872d347dc/src/utils/ElementChildren.js#L11-L17
1,183
react-bootstrap/react-bootstrap
src/utils/ElementChildren.js
forEach
function forEach(children, func) { let index = 0; React.Children.forEach(children, child => { if (React.isValidElement(child)) func(child, index++); }); }
javascript
function forEach(children, func) { let index = 0; React.Children.forEach(children, child => { if (React.isValidElement(child)) func(child, index++); }); }
[ "function", "forEach", "(", "children", ",", "func", ")", "{", "let", "index", "=", "0", ";", "React", ".", "Children", ".", "forEach", "(", "children", ",", "child", "=>", "{", "if", "(", "React", ".", "isValidElement", "(", "child", ")", ")", "func...
Iterates through children that are "valid elements". The provided forEachFunc(child, index) will be called for each leaf child with the index reflecting the position relative to "valid components".
[ "Iterates", "through", "children", "that", "are", "valid", "elements", "." ]
f0dc81f91ae90eb54bd1e4c04fa9419872d347dc
https://github.com/react-bootstrap/react-bootstrap/blob/f0dc81f91ae90eb54bd1e4c04fa9419872d347dc/src/utils/ElementChildren.js#L25-L30
1,184
openlayers/openlayers
examples/image-filter.js
convolve
function convolve(context, kernel) { const canvas = context.canvas; const width = canvas.width; const height = canvas.height; const size = Math.sqrt(kernel.length); const half = Math.floor(size / 2); const inputData = context.getImageData(0, 0, width, height).data; const output = context.createImageDat...
javascript
function convolve(context, kernel) { const canvas = context.canvas; const width = canvas.width; const height = canvas.height; const size = Math.sqrt(kernel.length); const half = Math.floor(size / 2); const inputData = context.getImageData(0, 0, width, height).data; const output = context.createImageDat...
[ "function", "convolve", "(", "context", ",", "kernel", ")", "{", "const", "canvas", "=", "context", ".", "canvas", ";", "const", "width", "=", "canvas", ".", "width", ";", "const", "height", "=", "canvas", ".", "height", ";", "const", "size", "=", "Mat...
Apply a convolution kernel to canvas. This works for any size kernel, but performance starts degrading above 3 x 3. @param {CanvasRenderingContext2D} context Canvas 2d context. @param {Array<number>} kernel Kernel.
[ "Apply", "a", "convolution", "kernel", "to", "canvas", ".", "This", "works", "for", "any", "size", "kernel", "but", "performance", "starts", "degrading", "above", "3", "x", "3", "." ]
f366eaea522388fb575b11010e69d309164baca7
https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/image-filter.js#L106-L145
1,185
openlayers/openlayers
examples/color-manipulation.js
rgb2hcl
function rgb2hcl(pixel) { const red = rgb2xyz(pixel[0]); const green = rgb2xyz(pixel[1]); const blue = rgb2xyz(pixel[2]); const x = xyz2lab( (0.4124564 * red + 0.3575761 * green + 0.1804375 * blue) / Xn); const y = xyz2lab( (0.2126729 * red + 0.7151522 * green + 0.0721750 * blue) / Yn); const z = x...
javascript
function rgb2hcl(pixel) { const red = rgb2xyz(pixel[0]); const green = rgb2xyz(pixel[1]); const blue = rgb2xyz(pixel[2]); const x = xyz2lab( (0.4124564 * red + 0.3575761 * green + 0.1804375 * blue) / Xn); const y = xyz2lab( (0.2126729 * red + 0.7151522 * green + 0.0721750 * blue) / Yn); const z = x...
[ "function", "rgb2hcl", "(", "pixel", ")", "{", "const", "red", "=", "rgb2xyz", "(", "pixel", "[", "0", "]", ")", ";", "const", "green", "=", "rgb2xyz", "(", "pixel", "[", "1", "]", ")", ";", "const", "blue", "=", "rgb2xyz", "(", "pixel", "[", "2"...
Convert an RGB pixel into an HCL pixel. @param {Array<number>} pixel A pixel in RGB space. @return {Array<number>} A pixel in HCL space.
[ "Convert", "an", "RGB", "pixel", "into", "an", "HCL", "pixel", "." ]
f366eaea522388fb575b11010e69d309164baca7
https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/color-manipulation.js#L26-L53
1,186
openlayers/openlayers
examples/color-manipulation.js
hcl2rgb
function hcl2rgb(pixel) { const h = pixel[0]; const c = pixel[1]; const l = pixel[2]; const a = Math.cos(h) * c; const b = Math.sin(h) * c; let y = (l + 16) / 116; let x = isNaN(a) ? y : y + a / 500; let z = isNaN(b) ? y : y - b / 200; y = Yn * lab2xyz(y); x = Xn * lab2xyz(x); z = Zn * lab2xyz(...
javascript
function hcl2rgb(pixel) { const h = pixel[0]; const c = pixel[1]; const l = pixel[2]; const a = Math.cos(h) * c; const b = Math.sin(h) * c; let y = (l + 16) / 116; let x = isNaN(a) ? y : y + a / 500; let z = isNaN(b) ? y : y - b / 200; y = Yn * lab2xyz(y); x = Xn * lab2xyz(x); z = Zn * lab2xyz(...
[ "function", "hcl2rgb", "(", "pixel", ")", "{", "const", "h", "=", "pixel", "[", "0", "]", ";", "const", "c", "=", "pixel", "[", "1", "]", ";", "const", "l", "=", "pixel", "[", "2", "]", ";", "const", "a", "=", "Math", ".", "cos", "(", "h", ...
Convert an HCL pixel into an RGB pixel. @param {Array<number>} pixel A pixel in HCL space. @return {Array<number>} A pixel in RGB space.
[ "Convert", "an", "HCL", "pixel", "into", "an", "RGB", "pixel", "." ]
f366eaea522388fb575b11010e69d309164baca7
https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/color-manipulation.js#L61-L82
1,187
openlayers/openlayers
examples/webpack/example-builder.js
createWordIndex
function createWordIndex(exampleData) { const index = {}; const keys = ['shortdesc', 'title', 'tags']; exampleData.forEach((data, i) => { keys.forEach(key => { let text = data[key]; if (Array.isArray(text)) { text = text.join(' '); } const words = text ? text.split(/\W+/) : [];...
javascript
function createWordIndex(exampleData) { const index = {}; const keys = ['shortdesc', 'title', 'tags']; exampleData.forEach((data, i) => { keys.forEach(key => { let text = data[key]; if (Array.isArray(text)) { text = text.join(' '); } const words = text ? text.split(/\W+/) : [];...
[ "function", "createWordIndex", "(", "exampleData", ")", "{", "const", "index", "=", "{", "}", ";", "const", "keys", "=", "[", "'shortdesc'", ",", "'title'", ",", "'tags'", "]", ";", "exampleData", ".", "forEach", "(", "(", "data", ",", "i", ")", "=>", ...
Create an inverted index of keywords from examples. Property names are lowercased words. Property values are objects mapping example index to word count. @param {Array<Object>} exampleData Array of example data objects. @return {Object} Word index.
[ "Create", "an", "inverted", "index", "of", "keywords", "from", "examples", ".", "Property", "names", "are", "lowercased", "words", ".", "Property", "values", "are", "objects", "mapping", "example", "index", "to", "word", "count", "." ]
f366eaea522388fb575b11010e69d309164baca7
https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/webpack/example-builder.js#L33-L63
1,188
openlayers/openlayers
examples/webpack/example-builder.js
getJsSource
function getJsSource(chunk, jsName) { let jsSource; for (let i = 0, ii = chunk.modules.length; i < ii; ++i) { const module = chunk.modules[i]; if (module.modules) { jsSource = getJsSource(module, jsName); if (jsSource) { return jsSource; } } if (module.identifier.endsWith(j...
javascript
function getJsSource(chunk, jsName) { let jsSource; for (let i = 0, ii = chunk.modules.length; i < ii; ++i) { const module = chunk.modules[i]; if (module.modules) { jsSource = getJsSource(module, jsName); if (jsSource) { return jsSource; } } if (module.identifier.endsWith(j...
[ "function", "getJsSource", "(", "chunk", ",", "jsName", ")", "{", "let", "jsSource", ";", "for", "(", "let", "i", "=", "0", ",", "ii", "=", "chunk", ".", "modules", ".", "length", ";", "i", "<", "ii", ";", "++", "i", ")", "{", "const", "module", ...
Gets the source for the chunk that matches the jsPath @param {Object} chunk Chunk. @param {string} jsName Name of the file. @return {string} The source.
[ "Gets", "the", "source", "for", "the", "chunk", "that", "matches", "the", "jsPath" ]
f366eaea522388fb575b11010e69d309164baca7
https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/webpack/example-builder.js#L71-L85
1,189
openlayers/openlayers
examples/webpack/example-builder.js
getDependencies
function getDependencies(jsSource) { const lines = jsSource.split('\n'); const dependencies = { ol: pkg.version }; for (let i = 0, ii = lines.length; i < ii; ++i) { const line = lines[i]; const importMatch = line.match(importRegEx); if (importMatch) { const imp = importMatch[1]; if (...
javascript
function getDependencies(jsSource) { const lines = jsSource.split('\n'); const dependencies = { ol: pkg.version }; for (let i = 0, ii = lines.length; i < ii; ++i) { const line = lines[i]; const importMatch = line.match(importRegEx); if (importMatch) { const imp = importMatch[1]; if (...
[ "function", "getDependencies", "(", "jsSource", ")", "{", "const", "lines", "=", "jsSource", ".", "split", "(", "'\\n'", ")", ";", "const", "dependencies", "=", "{", "ol", ":", "pkg", ".", "version", "}", ";", "for", "(", "let", "i", "=", "0", ",", ...
Gets dependencies from the js source. @param {string} jsSource Source. @return {Object<string, string>} dependencies
[ "Gets", "dependencies", "from", "the", "js", "source", "." ]
f366eaea522388fb575b11010e69d309164baca7
https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/webpack/example-builder.js#L92-L117
1,190
openlayers/openlayers
src/ol/format/KML.js
setCommonGeometryProperties
function setCommonGeometryProperties(multiGeometry, geometries) { const ii = geometries.length; const extrudes = new Array(geometries.length); const tessellates = new Array(geometries.length); const altitudeModes = new Array(geometries.length); let hasExtrude, hasTessellate, hasAltitudeMode; hasExtrude = ha...
javascript
function setCommonGeometryProperties(multiGeometry, geometries) { const ii = geometries.length; const extrudes = new Array(geometries.length); const tessellates = new Array(geometries.length); const altitudeModes = new Array(geometries.length); let hasExtrude, hasTessellate, hasAltitudeMode; hasExtrude = ha...
[ "function", "setCommonGeometryProperties", "(", "multiGeometry", ",", "geometries", ")", "{", "const", "ii", "=", "geometries", ".", "length", ";", "const", "extrudes", "=", "new", "Array", "(", "geometries", ".", "length", ")", ";", "const", "tessellates", "=...
Reads an array of geometries and creates arrays for common geometry properties. Then sets them to the multi geometry. @param {MultiPoint|MultiLineString|MultiPolygon} multiGeometry A multi-geometry. @param {Array<import("../geom/Geometry.js").default>} geometries List of geometries.
[ "Reads", "an", "array", "of", "geometries", "and", "creates", "arrays", "for", "common", "geometry", "properties", ".", "Then", "sets", "them", "to", "the", "multi", "geometry", "." ]
f366eaea522388fb575b11010e69d309164baca7
https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/format/KML.js#L1753-L1778
1,191
openlayers/openlayers
src/ol/pointer/MsSource.js
msPointerDown
function msPointerDown(inEvent) { this.pointerMap[inEvent.pointerId.toString()] = inEvent; const e = this.prepareEvent_(inEvent); this.dispatcher.down(e, inEvent); }
javascript
function msPointerDown(inEvent) { this.pointerMap[inEvent.pointerId.toString()] = inEvent; const e = this.prepareEvent_(inEvent); this.dispatcher.down(e, inEvent); }
[ "function", "msPointerDown", "(", "inEvent", ")", "{", "this", ".", "pointerMap", "[", "inEvent", ".", "pointerId", ".", "toString", "(", ")", "]", "=", "inEvent", ";", "const", "e", "=", "this", ".", "prepareEvent_", "(", "inEvent", ")", ";", "this", ...
Handler for `msPointerDown`. @this {MsSource} @param {MSPointerEvent} inEvent The in event.
[ "Handler", "for", "msPointerDown", "." ]
f366eaea522388fb575b11010e69d309164baca7
https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/pointer/MsSource.js#L55-L59
1,192
openlayers/openlayers
src/ol/pointer/MsSource.js
msPointerUp
function msPointerUp(inEvent) { const e = this.prepareEvent_(inEvent); this.dispatcher.up(e, inEvent); this.cleanup(inEvent.pointerId); }
javascript
function msPointerUp(inEvent) { const e = this.prepareEvent_(inEvent); this.dispatcher.up(e, inEvent); this.cleanup(inEvent.pointerId); }
[ "function", "msPointerUp", "(", "inEvent", ")", "{", "const", "e", "=", "this", ".", "prepareEvent_", "(", "inEvent", ")", ";", "this", ".", "dispatcher", ".", "up", "(", "e", ",", "inEvent", ")", ";", "this", ".", "cleanup", "(", "inEvent", ".", "po...
Handler for `msPointerUp`. @this {MsSource} @param {MSPointerEvent} inEvent The in event.
[ "Handler", "for", "msPointerUp", "." ]
f366eaea522388fb575b11010e69d309164baca7
https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/pointer/MsSource.js#L78-L82
1,193
openlayers/openlayers
src/ol/pointer/MsSource.js
msPointerCancel
function msPointerCancel(inEvent) { const e = this.prepareEvent_(inEvent); this.dispatcher.cancel(e, inEvent); this.cleanup(inEvent.pointerId); }
javascript
function msPointerCancel(inEvent) { const e = this.prepareEvent_(inEvent); this.dispatcher.cancel(e, inEvent); this.cleanup(inEvent.pointerId); }
[ "function", "msPointerCancel", "(", "inEvent", ")", "{", "const", "e", "=", "this", ".", "prepareEvent_", "(", "inEvent", ")", ";", "this", ".", "dispatcher", ".", "cancel", "(", "e", ",", "inEvent", ")", ";", "this", ".", "cleanup", "(", "inEvent", "....
Handler for `msPointerCancel`. @this {MsSource} @param {MSPointerEvent} inEvent The in event.
[ "Handler", "for", "msPointerCancel", "." ]
f366eaea522388fb575b11010e69d309164baca7
https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/pointer/MsSource.js#L112-L116
1,194
openlayers/openlayers
src/ol/pointer/MsSource.js
msLostPointerCapture
function msLostPointerCapture(inEvent) { const e = this.dispatcher.makeEvent('lostpointercapture', inEvent, inEvent); this.dispatcher.dispatchEvent(e); }
javascript
function msLostPointerCapture(inEvent) { const e = this.dispatcher.makeEvent('lostpointercapture', inEvent, inEvent); this.dispatcher.dispatchEvent(e); }
[ "function", "msLostPointerCapture", "(", "inEvent", ")", "{", "const", "e", "=", "this", ".", "dispatcher", ".", "makeEvent", "(", "'lostpointercapture'", ",", "inEvent", ",", "inEvent", ")", ";", "this", ".", "dispatcher", ".", "dispatchEvent", "(", "e", ")...
Handler for `msLostPointerCapture`. @this {MsSource} @param {MSPointerEvent} inEvent The in event.
[ "Handler", "for", "msLostPointerCapture", "." ]
f366eaea522388fb575b11010e69d309164baca7
https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/pointer/MsSource.js#L124-L127
1,195
openlayers/openlayers
src/ol/pointer/MsSource.js
msGotPointerCapture
function msGotPointerCapture(inEvent) { const e = this.dispatcher.makeEvent('gotpointercapture', inEvent, inEvent); this.dispatcher.dispatchEvent(e); }
javascript
function msGotPointerCapture(inEvent) { const e = this.dispatcher.makeEvent('gotpointercapture', inEvent, inEvent); this.dispatcher.dispatchEvent(e); }
[ "function", "msGotPointerCapture", "(", "inEvent", ")", "{", "const", "e", "=", "this", ".", "dispatcher", ".", "makeEvent", "(", "'gotpointercapture'", ",", "inEvent", ",", "inEvent", ")", ";", "this", ".", "dispatcher", ".", "dispatchEvent", "(", "e", ")",...
Handler for `msGotPointerCapture`. @this {MsSource} @param {MSPointerEvent} inEvent The in event.
[ "Handler", "for", "msGotPointerCapture", "." ]
f366eaea522388fb575b11010e69d309164baca7
https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/pointer/MsSource.js#L135-L138
1,196
openlayers/openlayers
src/ol/source/Source.js
adaptAttributions
function adaptAttributions(attributionLike) { if (!attributionLike) { return null; } if (Array.isArray(attributionLike)) { return function(frameState) { return attributionLike; }; } if (typeof attributionLike === 'function') { return attributionLike; } return function(frameState) {...
javascript
function adaptAttributions(attributionLike) { if (!attributionLike) { return null; } if (Array.isArray(attributionLike)) { return function(frameState) { return attributionLike; }; } if (typeof attributionLike === 'function') { return attributionLike; } return function(frameState) {...
[ "function", "adaptAttributions", "(", "attributionLike", ")", "{", "if", "(", "!", "attributionLike", ")", "{", "return", "null", ";", "}", "if", "(", "Array", ".", "isArray", "(", "attributionLike", ")", ")", "{", "return", "function", "(", "frameState", ...
Turns the attributions option into an attributions function. @param {AttributionLike|undefined} attributionLike The attribution option. @return {?Attribution} An attribution function (or null).
[ "Turns", "the", "attributions", "option", "into", "an", "attributions", "function", "." ]
f366eaea522388fb575b11010e69d309164baca7
https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/src/ol/source/Source.js#L184-L201
1,197
openlayers/openlayers
examples/measure.js
function(evt) { if (evt.dragging) { return; } /** @type {string} */ let helpMsg = 'Click to start drawing'; if (sketch) { const geom = sketch.getGeometry(); if (geom instanceof Polygon) { helpMsg = continuePolygonMsg; } else if (geom instanceof LineString) { helpMsg = continueLine...
javascript
function(evt) { if (evt.dragging) { return; } /** @type {string} */ let helpMsg = 'Click to start drawing'; if (sketch) { const geom = sketch.getGeometry(); if (geom instanceof Polygon) { helpMsg = continuePolygonMsg; } else if (geom instanceof LineString) { helpMsg = continueLine...
[ "function", "(", "evt", ")", "{", "if", "(", "evt", ".", "dragging", ")", "{", "return", ";", "}", "/** @type {string} */", "let", "helpMsg", "=", "'Click to start drawing'", ";", "if", "(", "sketch", ")", "{", "const", "geom", "=", "sketch", ".", "getGe...
Handle pointer move. @param {import("../src/ol/MapBrowserEvent").default} evt The event.
[ "Handle", "pointer", "move", "." ]
f366eaea522388fb575b11010e69d309164baca7
https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/measure.js#L92-L112
1,198
openlayers/openlayers
examples/measure.js
function(line) { const length = getLength(line); let output; if (length > 100) { output = (Math.round(length / 1000 * 100) / 100) + ' ' + 'km'; } else { output = (Math.round(length * 100) / 100) + ' ' + 'm'; } return output; }
javascript
function(line) { const length = getLength(line); let output; if (length > 100) { output = (Math.round(length / 1000 * 100) / 100) + ' ' + 'km'; } else { output = (Math.round(length * 100) / 100) + ' ' + 'm'; } return output; }
[ "function", "(", "line", ")", "{", "const", "length", "=", "getLength", "(", "line", ")", ";", "let", "output", ";", "if", "(", "length", ">", "100", ")", "{", "output", "=", "(", "Math", ".", "round", "(", "length", "/", "1000", "*", "100", ")",...
global so we can remove it later Format length output. @param {LineString} line The line. @return {string} The formatted length.
[ "global", "so", "we", "can", "remove", "it", "later", "Format", "length", "output", "." ]
f366eaea522388fb575b11010e69d309164baca7
https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/measure.js#L140-L151
1,199
openlayers/openlayers
examples/measure.js
function(polygon) { const area = getArea(polygon); let output; if (area > 10000) { output = (Math.round(area / 1000000 * 100) / 100) + ' ' + 'km<sup>2</sup>'; } else { output = (Math.round(area * 100) / 100) + ' ' + 'm<sup>2</sup>'; } return output; }
javascript
function(polygon) { const area = getArea(polygon); let output; if (area > 10000) { output = (Math.round(area / 1000000 * 100) / 100) + ' ' + 'km<sup>2</sup>'; } else { output = (Math.round(area * 100) / 100) + ' ' + 'm<sup>2</sup>'; } return output; }
[ "function", "(", "polygon", ")", "{", "const", "area", "=", "getArea", "(", "polygon", ")", ";", "let", "output", ";", "if", "(", "area", ">", "10000", ")", "{", "output", "=", "(", "Math", ".", "round", "(", "area", "/", "1000000", "*", "100", "...
Format area output. @param {Polygon} polygon The polygon. @return {string} Formatted area.
[ "Format", "area", "output", "." ]
f366eaea522388fb575b11010e69d309164baca7
https://github.com/openlayers/openlayers/blob/f366eaea522388fb575b11010e69d309164baca7/examples/measure.js#L159-L170