mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-26 12:18:01 +00:00
Compare commits
14 Commits
3.1.1
...
3.2.0-pre.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 695bda312c | |||
| 144bd4c97a | |||
| e105983cf8 | |||
| ea3afbed75 | |||
| d563abe3df | |||
| 70fd4ded29 | |||
| 9ce9388dfc | |||
| c575ad83ae | |||
| 936fa1545b | |||
| c9c2dde2b6 | |||
| d9a1d387c7 | |||
| bf29d187c8 | |||
| d86f9b2667 | |||
| aca4313fc3 |
@@ -2,6 +2,13 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
This project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## 3.2.0 (pre)
|
||||
- Switch markdown parser from `kramed` to `markup-it`
|
||||
- Fix support of `|` in tables
|
||||
- Fix access to `output.name` in templating
|
||||
- Improve options of default search indexer (keywords, disabling per pages)
|
||||
- Improve pertinence of search results
|
||||
|
||||
## 3.1.1
|
||||
- Fix order of plugins during loading
|
||||
- Fix error when using math and conrefs
|
||||
|
||||
@@ -6,10 +6,10 @@ module.exports = {
|
||||
title: 'GitBook Toolchain Documentation',
|
||||
|
||||
// Enforce use of GitBook v3
|
||||
gitbook: '>=3.0.0-pre.0',
|
||||
gitbook: '3.1.1',
|
||||
|
||||
// Use the "official" theme
|
||||
plugins: ['theme-official', 'sitemap'],
|
||||
plugins: ['theme-official@2.1.1', '-sharing', '-fontsettings', 'sitemap'],
|
||||
|
||||
variables: {
|
||||
version: pkg.version
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/* Reduce size of logo to allow long versions like 3.0.0-pre.1 */
|
||||
.gb-page-header .container .logo h1 {
|
||||
font-size: 24px ;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
/* eslint-disable no-console */
|
||||
|
||||
var tinylr = require('tiny-lr');
|
||||
var open = require('open');
|
||||
|
||||
var Parse = require('../parse');
|
||||
var Output = require('../output');
|
||||
@@ -32,9 +33,11 @@ function generateBook(args, kwargs) {
|
||||
var outputFolder = getOutputFolder(args);
|
||||
var book = getBook(args, kwargs);
|
||||
var Generator = Output.getGenerator(kwargs.format);
|
||||
var browser = kwargs['browser'];
|
||||
|
||||
var hasWatch = kwargs['watch'];
|
||||
var hasLiveReloading = kwargs['live'];
|
||||
var hasOpen = kwargs['open'];
|
||||
|
||||
// Stop server if running
|
||||
if (server.isRunning()) console.log('Stopping server');
|
||||
@@ -71,6 +74,10 @@ function generateBook(args, kwargs) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (hasOpen) {
|
||||
open('http://localhost:'+port, browser);
|
||||
}
|
||||
})
|
||||
.then(function() {
|
||||
if (!hasWatch) {
|
||||
@@ -112,6 +119,16 @@ module.exports = {
|
||||
description: 'Enable live reloading',
|
||||
defaults: true
|
||||
},
|
||||
{
|
||||
name: 'open',
|
||||
description: 'Enable opening book in browser',
|
||||
defaults: false
|
||||
},
|
||||
{
|
||||
name: 'browser',
|
||||
description: 'Specify browser for opening book',
|
||||
defaults: ''
|
||||
},
|
||||
options.log,
|
||||
options.format
|
||||
],
|
||||
|
||||
@@ -3,12 +3,12 @@ var encodePage = require('./encodePage');
|
||||
var encodeFile = require('./encodeFile');
|
||||
|
||||
/**
|
||||
Return a JSON representation of a book with a specific file
|
||||
|
||||
@param {Book} output
|
||||
@param {Page} page
|
||||
@return {Object}
|
||||
*/
|
||||
* Return a JSON representation of a book with a specific file
|
||||
*
|
||||
* @param {Book} output
|
||||
* @param {Page} page
|
||||
* @return {Object}
|
||||
*/
|
||||
function encodeBookWithPage(book, page) {
|
||||
var file = page.getFile();
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
var encodeBook = require('./encodeBook');
|
||||
|
||||
/**
|
||||
Encode an output to JSON
|
||||
|
||||
@param {Output}
|
||||
@return {Object}
|
||||
*/
|
||||
* Encode an output to JSON
|
||||
*
|
||||
* @param {Output}
|
||||
* @return {Object}
|
||||
*/
|
||||
function encodeOutputToJson(output) {
|
||||
var book = output.getBook();
|
||||
var generator = output.getGenerator();
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
var encodeOutput = require('./encodeOutput');
|
||||
var encodePage = require('./encodePage');
|
||||
var encodeFile = require('./encodeFile');
|
||||
|
||||
/**
|
||||
* Return a JSON representation of a book with a specific file
|
||||
*
|
||||
* @param {Book} output
|
||||
* @param {Page} page
|
||||
* @return {Object}
|
||||
*/
|
||||
function encodeOutputWithPage(output, page) {
|
||||
var file = page.getFile();
|
||||
var book = output.getBook();
|
||||
|
||||
var result = encodeOutput(output);
|
||||
result.page = encodePage(page, book.getSummary());
|
||||
result.file = encodeFile(file);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
module.exports = encodeOutputWithPage;
|
||||
@@ -2,6 +2,7 @@
|
||||
module.exports = {
|
||||
encodeOutput: require('./encodeOutput'),
|
||||
encodeBookWithPage: require('./encodeBookWithPage'),
|
||||
encodeOutputWithPage: require('./encodeOutputWithPage'),
|
||||
encodeBook: require('./encodeBook'),
|
||||
encodeFile: require('./encodeFile'),
|
||||
encodePage: require('./encodePage'),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
var SummaryArticle = require('../summaryArticle');
|
||||
var File = require('../file');
|
||||
|
||||
describe('SummaryArticle', function() {
|
||||
describe('createChildLevel', function() {
|
||||
@@ -18,6 +19,35 @@ describe('SummaryArticle', function() {
|
||||
expect(article.createChildLevel()).toBe('1.1.2');
|
||||
});
|
||||
});
|
||||
|
||||
describe('isFile', function() {
|
||||
it('must return true when exactly the file', function() {
|
||||
var article = SummaryArticle.create({
|
||||
ref: 'hello.md'
|
||||
}, '1.1');
|
||||
var file = File.createWithFilepath('hello.md');
|
||||
|
||||
expect(article.isFile(file)).toBe(true);
|
||||
});
|
||||
|
||||
it('must return true when path is not normalized', function() {
|
||||
var article = SummaryArticle.create({
|
||||
ref: '/hello.md'
|
||||
}, '1.1');
|
||||
var file = File.createWithFilepath('hello.md');
|
||||
|
||||
expect(article.isFile(file)).toBe(true);
|
||||
});
|
||||
|
||||
it('must return false when has anchor', function() {
|
||||
var article = SummaryArticle.create({
|
||||
ref: 'hello.md#world'
|
||||
}, '1.1');
|
||||
var file = File.createWithFilepath('hello.md');
|
||||
|
||||
expect(article.isFile(file)).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -40,7 +40,8 @@ SummaryArticle.prototype.getDepth = function() {
|
||||
};
|
||||
|
||||
/**
|
||||
* Get path (without anchor) to the pointing file
|
||||
* Get path (without anchor) to the pointing file.
|
||||
* It also normalizes the file path.
|
||||
*
|
||||
* @return {String}
|
||||
*/
|
||||
@@ -58,8 +59,8 @@ SummaryArticle.prototype.getPath = function() {
|
||||
|
||||
var pathname = (parts.length > 1? parts.slice(0, -1).join('#') : ref);
|
||||
|
||||
// Normalize path to remove ('./', etc)
|
||||
return location.normalize(pathname);
|
||||
// Normalize path to remove ('./', '/...', etc)
|
||||
return location.flatten(pathname);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -106,6 +107,32 @@ SummaryArticle.prototype.isPage = function() {
|
||||
return !this.isExternal() && this.getRef();
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if this article is a file (exatcly)
|
||||
*
|
||||
* @param {File} file
|
||||
* @return {Boolean}
|
||||
*/
|
||||
SummaryArticle.prototype.isFile = function(file) {
|
||||
return (
|
||||
file.getPath() === this.getPath()
|
||||
&& this.getAnchor() === undefined
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if this article is the introduction of the book
|
||||
*
|
||||
* @param {Book|Readme} book
|
||||
* @return {Boolean}
|
||||
*/
|
||||
SummaryArticle.prototype.isReadme = function(book) {
|
||||
var readme = book.getFile? book : book.getReadme();
|
||||
var file = readme.getFile();
|
||||
|
||||
return this.isFile(file);
|
||||
};
|
||||
|
||||
/**
|
||||
* Is article pointing to aan absolute url
|
||||
*
|
||||
|
||||
@@ -10,12 +10,12 @@ var createTemplateEngine = require('./createTemplateEngine');
|
||||
var callPageHook = require('./callPageHook');
|
||||
|
||||
/**
|
||||
Prepare and generate HTML for a page
|
||||
|
||||
@param {Output} output
|
||||
@param {Page} page
|
||||
@return {Promise<Page>}
|
||||
*/
|
||||
* Prepare and generate HTML for a page
|
||||
*
|
||||
* @param {Output} output
|
||||
* @param {Page} page
|
||||
* @return {Promise<Page>}
|
||||
*/
|
||||
function generatePage(output, page) {
|
||||
var book = output.getBook();
|
||||
var engine = createTemplateEngine(output);
|
||||
@@ -27,7 +27,7 @@ function generatePage(output, page) {
|
||||
var file = resultPage.getFile();
|
||||
var filePath = file.getPath();
|
||||
var parser = file.getParser();
|
||||
var context = JSONUtils.encodeBookWithPage(book, resultPage);
|
||||
var context = JSONUtils.encodeOutputWithPage(output, resultPage);
|
||||
|
||||
if (!parser) {
|
||||
return Promise.reject(error.FileNotParsableError({
|
||||
|
||||
@@ -9,11 +9,11 @@ var fileToOutput = require('./helper/fileToOutput');
|
||||
var CODEBLOCK = 'code';
|
||||
|
||||
/**
|
||||
Return default modifier to prepare a page for
|
||||
rendering.
|
||||
|
||||
@return {Array<Modifier>}
|
||||
*/
|
||||
* Return default modifier to prepare a page for
|
||||
* rendering.
|
||||
*
|
||||
* @return {Array<Modifier>}
|
||||
*/
|
||||
function getModifiers(output, page) {
|
||||
var book = output.getBook();
|
||||
var plugins = output.getPlugins();
|
||||
|
||||
@@ -6,12 +6,12 @@ var LocationUtils = require('../../utils/location');
|
||||
var OUTPUT_EXTENSION = '.html';
|
||||
|
||||
/**
|
||||
Convert a filePath (absolute) to a filename for output
|
||||
|
||||
@param {Output} output
|
||||
@param {String} filePath
|
||||
@return {String}
|
||||
*/
|
||||
* Convert a filePath (absolute) to a filename for output
|
||||
*
|
||||
* @param {Output} output
|
||||
* @param {String} filePath
|
||||
* @return {String}
|
||||
*/
|
||||
function fileToOutput(output, filePath) {
|
||||
var book = output.getBook();
|
||||
var readme = book.getReadme();
|
||||
|
||||
@@ -3,12 +3,12 @@ var LocationUtils = require('../../utils/location');
|
||||
var fileToURL = require('./fileToURL');
|
||||
|
||||
/**
|
||||
Resolve an absolute path (extracted from a link)
|
||||
|
||||
@param {Output} output
|
||||
@param {String} filePath
|
||||
@return {String}
|
||||
*/
|
||||
* Resolve an absolute path (extracted from a link)
|
||||
*
|
||||
* @param {Output} output
|
||||
* @param {String} filePath
|
||||
* @return {String}
|
||||
*/
|
||||
function resolveFileToURL(output, filePath) {
|
||||
// Convert /test.png -> test.png
|
||||
filePath = LocationUtils.toAbsolute(filePath, '', '');
|
||||
|
||||
@@ -7,11 +7,11 @@ var getModifiers = require('../getModifiers');
|
||||
var JSON_VERSION = '3';
|
||||
|
||||
/**
|
||||
Write a page as a json file
|
||||
|
||||
@param {Output} output
|
||||
@param {Page} page
|
||||
*/
|
||||
* Write a page as a json file
|
||||
*
|
||||
* @param {Output} output
|
||||
* @param {Page} page
|
||||
*/
|
||||
function onPage(output, page) {
|
||||
var file = page.getFile();
|
||||
var readme = output.getBook().getReadme().getFile();
|
||||
|
||||
@@ -59,19 +59,18 @@ function replaceText($, el, search, replace, text_only ) {
|
||||
}
|
||||
|
||||
/**
|
||||
Annotate text using a list of GlossaryEntry
|
||||
|
||||
@param {List<GlossaryEntry>}
|
||||
@param {String} glossaryFilePath
|
||||
@param {HTMLDom} $
|
||||
*/
|
||||
* Annotate text using a list of GlossaryEntry
|
||||
*
|
||||
* @param {List<GlossaryEntry>}
|
||||
* @param {String} glossaryFilePath
|
||||
* @param {HTMLDom} $
|
||||
*/
|
||||
function annotateText(entries, glossaryFilePath, $) {
|
||||
entries.forEach(function(entry) {
|
||||
var entryId = entry.getID();
|
||||
var name = entry.getName();
|
||||
var entryId = entry.getID();
|
||||
var name = entry.getName();
|
||||
var description = entry.getDescription();
|
||||
|
||||
var searchRegex = new RegExp( '\\b(' + pregQuote(name.toLowerCase()) + ')\\b' , 'gi' );
|
||||
var searchRegex = new RegExp( '\\b(' + pregQuote(name.toLowerCase()) + ')\\b' , 'gi' );
|
||||
|
||||
$('*').each(function() {
|
||||
var $this = $(this);
|
||||
|
||||
@@ -12,11 +12,11 @@ var createTemplateEngine = require('./createTemplateEngine');
|
||||
var fileToOutput = require('../helper/fileToOutput');
|
||||
|
||||
/**
|
||||
Write a page as a json file
|
||||
|
||||
@param {Output} output
|
||||
@param {Page} page
|
||||
*/
|
||||
* Write a page as a json file
|
||||
*
|
||||
* @param {Output} output
|
||||
* @param {Page} page
|
||||
*/
|
||||
function onPage(output, page) {
|
||||
var options = output.getOptions();
|
||||
var prefix = options.get('prefix');
|
||||
@@ -40,7 +40,7 @@ function onPage(output, page) {
|
||||
return Modifiers.modifyHTML(page, getModifiers(output, page))
|
||||
.then(function(resultPage) {
|
||||
// Generate the context
|
||||
var context = JSONUtils.encodeBookWithPage(output.getBook(), resultPage);
|
||||
var context = JSONUtils.encodeOutputWithPage(output, resultPage);
|
||||
context.plugins = {
|
||||
resources: Plugins.listResources(plugins, resources).toJS()
|
||||
};
|
||||
|
||||
@@ -39,6 +39,21 @@ describe('LocationUtils', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('.flatten', function() {
|
||||
it('should remove leading slash', function() {
|
||||
expect(LocationUtils.flatten('/test.md')).toBe('test.md');
|
||||
expect(LocationUtils.flatten('/hello/cool.md')).toBe('hello/cool.md');
|
||||
});
|
||||
|
||||
it('should remove leading slashes', function() {
|
||||
expect(LocationUtils.flatten('///test.md')).toBe('test.md');
|
||||
});
|
||||
|
||||
it('should not break paths', function() {
|
||||
expect(LocationUtils.flatten('hello/cool.md')).toBe('hello/cool.md');
|
||||
});
|
||||
});
|
||||
|
||||
describe('.toAbsolute', function() {
|
||||
it('should correctly transform as absolute', function() {
|
||||
expect(LocationUtils.toAbsolute('http://google.fr')).toBe('http://google.fr');
|
||||
|
||||
+51
-35
@@ -40,13 +40,28 @@ function normalize(s) {
|
||||
}
|
||||
|
||||
/**
|
||||
Convert a relative path to absolute
|
||||
* Flatten a path, it removes the leading "/"
|
||||
*
|
||||
* @param {String} href
|
||||
* @return {String}
|
||||
*/
|
||||
function flatten(href) {
|
||||
href = normalize(href);
|
||||
if (href[0] == '/') {
|
||||
href = normalize(href.slice(1));
|
||||
}
|
||||
|
||||
@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}
|
||||
*/
|
||||
return href;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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}
|
||||
*/
|
||||
function toAbsolute(_href, dir, outdir) {
|
||||
if (isExternal(_href) || isDataURI(_href)) {
|
||||
return _href;
|
||||
@@ -74,50 +89,51 @@ function toAbsolute(_href, dir, outdir) {
|
||||
}
|
||||
|
||||
/**
|
||||
Convert an absolute path to a relative path for a specific folder (dir)
|
||||
('test/', 'hello.md') -> '../hello.md'
|
||||
|
||||
@param {String} dir: current directory
|
||||
@param {String} file: absolute path of file
|
||||
@return {String}
|
||||
*/
|
||||
* Convert an absolute path to a relative path for a specific folder (dir)
|
||||
* ('test/', 'hello.md') -> '../hello.md'
|
||||
*
|
||||
* @param {String} dir: current directory
|
||||
* @param {String} file: absolute path of file
|
||||
* @return {String}
|
||||
*/
|
||||
function relative(dir, file) {
|
||||
var isDirectory = file.slice(-1) === '/';
|
||||
return normalize(path.relative(dir, file)) + (isDirectory? '/': '');
|
||||
}
|
||||
|
||||
/**
|
||||
Convert an absolute path to a relative path for a specific folder (dir)
|
||||
('test/test.md', 'hello.md') -> '../hello.md'
|
||||
|
||||
@param {String} baseFile: current file
|
||||
@param {String} file: absolute path of file
|
||||
@return {String}
|
||||
*/
|
||||
* Convert an absolute path to a relative path for a specific folder (dir)
|
||||
* ('test/test.md', 'hello.md') -> '../hello.md'
|
||||
*
|
||||
* @param {String} baseFile: current file
|
||||
* @param {String} file: absolute path of file
|
||||
* @return {String}
|
||||
*/
|
||||
function relativeForFile(baseFile, file) {
|
||||
return relative(path.dirname(baseFile), file);
|
||||
}
|
||||
|
||||
/**
|
||||
Compare two paths, return true if they are identical
|
||||
('README.md', './README.md') -> true
|
||||
|
||||
@param {String} p1: first path
|
||||
@param {String} p2: second path
|
||||
@return {Boolean}
|
||||
*/
|
||||
* Compare two paths, return true if they are identical
|
||||
* ('README.md', './README.md') -> true
|
||||
*
|
||||
* @param {String} p1: first path
|
||||
* @param {String} p2: second path
|
||||
* @return {Boolean}
|
||||
*/
|
||||
function areIdenticalPaths(p1, p2) {
|
||||
return normalize(p1) === normalize(p2);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
areIdenticalPaths: areIdenticalPaths,
|
||||
isDataURI: isDataURI,
|
||||
isExternal: isExternal,
|
||||
isRelative: isRelative,
|
||||
isAnchor: isAnchor,
|
||||
normalize: normalize,
|
||||
toAbsolute: toAbsolute,
|
||||
relative: relative,
|
||||
relativeForFile: relativeForFile
|
||||
isDataURI: isDataURI,
|
||||
isExternal: isExternal,
|
||||
isRelative: isRelative,
|
||||
isAnchor: isAnchor,
|
||||
normalize: normalize,
|
||||
toAbsolute: toAbsolute,
|
||||
relative: relative,
|
||||
relativeForFile: relativeForFile,
|
||||
flatten: flatten
|
||||
};
|
||||
|
||||
+44
-43
@@ -2,34 +2,35 @@ var Q = require('q');
|
||||
var Immutable = require('immutable');
|
||||
|
||||
// Debugging for long stack traces
|
||||
if (global.__DEV__ || process.env.DEBUG) {
|
||||
if (process.env.DEBUG || process.env.CI) {
|
||||
Q.longStackSupport = true;
|
||||
}
|
||||
|
||||
/**
|
||||
Reduce an array to a promise
|
||||
|
||||
@param {Array|List} arr
|
||||
@param {Function(value, element, index)}
|
||||
@return {Promise<Mixed>}
|
||||
*/
|
||||
* Reduce an array to a promise
|
||||
*
|
||||
* @param {Array|List} arr
|
||||
* @param {Function(value, element, index)}
|
||||
* @return {Promise<Mixed>}
|
||||
*/
|
||||
function reduce(arr, iter, base) {
|
||||
arr = Immutable.Iterable.isIterable(arr)? arr : Immutable.List(arr);
|
||||
|
||||
return arr.reduce(function(prev, elem, key) {
|
||||
return prev.then(function(val) {
|
||||
return prev
|
||||
.then(function(val) {
|
||||
return iter(val, elem, key);
|
||||
});
|
||||
}, Q(base));
|
||||
}
|
||||
|
||||
/**
|
||||
Iterate over an array using an async iter
|
||||
|
||||
@param {Array|List} arr
|
||||
@param {Function(value, element, index)}
|
||||
@return {Promise}
|
||||
*/
|
||||
* Iterate over an array using an async iter
|
||||
*
|
||||
* @param {Array|List} arr
|
||||
* @param {Function(value, element, index)}
|
||||
* @return {Promise}
|
||||
*/
|
||||
function forEach(arr, iter) {
|
||||
return reduce(arr, function(val, el, key) {
|
||||
return iter(el, key);
|
||||
@@ -37,12 +38,12 @@ function forEach(arr, iter) {
|
||||
}
|
||||
|
||||
/**
|
||||
Transform an array
|
||||
|
||||
@param {Array|List} arr
|
||||
@param {Function(value, element, index)}
|
||||
@return {Promise}
|
||||
*/
|
||||
* Transform an array
|
||||
*
|
||||
* @param {Array|List} arr
|
||||
* @param {Function(value, element, index)}
|
||||
* @return {Promise}
|
||||
*/
|
||||
function serie(arr, iter, base) {
|
||||
return reduce(arr, function(before, item, key) {
|
||||
return Q(iter(item, key))
|
||||
@@ -54,12 +55,12 @@ function serie(arr, iter, base) {
|
||||
}
|
||||
|
||||
/**
|
||||
Iter over an array and return first result (not null)
|
||||
|
||||
@param {Array|List} arr
|
||||
@param {Function(element, index)}
|
||||
@return {Promise<Mixed>}
|
||||
*/
|
||||
* Iter over an array and return first result (not null)
|
||||
*
|
||||
* @param {Array|List} arr
|
||||
* @param {Function(element, index)}
|
||||
* @return {Promise<Mixed>}
|
||||
*/
|
||||
function some(arr, iter) {
|
||||
arr = Immutable.List(arr);
|
||||
|
||||
@@ -73,12 +74,12 @@ function some(arr, iter) {
|
||||
}
|
||||
|
||||
/**
|
||||
Map an array using an async (promised) iterator
|
||||
|
||||
@param {Array|List} arr
|
||||
@param {Function(element, index)}
|
||||
@return {Promise<List>}
|
||||
*/
|
||||
* Map an array using an async (promised) iterator
|
||||
*
|
||||
* @param {Array|List} arr
|
||||
* @param {Function(element, index)}
|
||||
* @return {Promise<List>}
|
||||
*/
|
||||
function mapAsList(arr, iter) {
|
||||
return reduce(arr, function(prev, entry, i) {
|
||||
return Q(iter(entry, i))
|
||||
@@ -90,12 +91,12 @@ function mapAsList(arr, iter) {
|
||||
}
|
||||
|
||||
/**
|
||||
Map an array or map
|
||||
|
||||
@param {Array|List|Map|OrderedMap} arr
|
||||
@param {Function(element, key)}
|
||||
@return {Promise<List|Map|OrderedMap>}
|
||||
*/
|
||||
* Map an array or map
|
||||
*
|
||||
* @param {Array|List|Map|OrderedMap} arr
|
||||
* @param {Function(element, key)}
|
||||
* @return {Promise<List|Map|OrderedMap>}
|
||||
*/
|
||||
function map(arr, iter) {
|
||||
if (Immutable.Map.isMap(arr)) {
|
||||
var type = 'Map';
|
||||
@@ -122,11 +123,11 @@ function map(arr, iter) {
|
||||
|
||||
|
||||
/**
|
||||
Wrap a function in a promise
|
||||
|
||||
@param {Function} func
|
||||
@return {Funciton}
|
||||
*/
|
||||
* Wrap a function in a promise
|
||||
*
|
||||
* @param {Function} func
|
||||
* @return {Funciton}
|
||||
*/
|
||||
function wrap(func) {
|
||||
return function() {
|
||||
var args = Array.prototype.slice.call(arguments, 0);
|
||||
|
||||
+4
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gitbook",
|
||||
"version": "3.1.1",
|
||||
"version": "3.2.0-pre.1",
|
||||
"homepage": "https://www.gitbook.com",
|
||||
"description": "Library and cmd utility to generate GitBooks",
|
||||
"main": "lib/index.js",
|
||||
@@ -22,11 +22,11 @@
|
||||
"fresh-require": "1.0.3",
|
||||
"front-matter": "^2.1.0",
|
||||
"gitbook-asciidoc": "1.2.2",
|
||||
"gitbook-markdown": "1.3.2",
|
||||
"gitbook-markdown": "2.0.1",
|
||||
"gitbook-plugin-fontsettings": "2.0.0",
|
||||
"gitbook-plugin-highlight": "2.0.2",
|
||||
"gitbook-plugin-livereload": "0.0.1",
|
||||
"gitbook-plugin-lunr": "1.1.0",
|
||||
"gitbook-plugin-lunr": "1.2.0",
|
||||
"gitbook-plugin-search": "2.2.1",
|
||||
"gitbook-plugin-sharing": "1.0.2",
|
||||
"gitbook-plugin-theme-default": "1.0.4",
|
||||
@@ -48,6 +48,7 @@
|
||||
"nunjucks-do": "1.0.0",
|
||||
"object-path": "^0.9.2",
|
||||
"omit-keys": "^0.1.0",
|
||||
"open": "0.0.5",
|
||||
"q": "1.4.1",
|
||||
"read-installed": "^4.0.3",
|
||||
"request": "2.72.0",
|
||||
|
||||
Reference in New Issue
Block a user