mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-29 21:49:26 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ef84a34fcd | |||
| 5df4c358a4 |
+1
-1
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"lerna": "2.0.0-beta.31",
|
||||
"version": "4.0.0-alpha.5"
|
||||
"version": "4.0.0-alpha.6"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gitbook-core",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"description": "Core for GitBook plugins API",
|
||||
"main": "./lib/index.js",
|
||||
"dependencies": {
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
"description": "Button to copy code blocks",
|
||||
"main": "index.js",
|
||||
"browser": "./_assets/plugin.js",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"dependencies": {
|
||||
"copy-to-clipboard": "^3.0.5",
|
||||
"gitbook-core": "^4.0.0-alpha.5"
|
||||
"gitbook-core": "^4.0.0-alpha.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gitbook-plugin": "^4.0.0-alpha.5"
|
||||
"gitbook-plugin": "^4.0.0-alpha.6"
|
||||
},
|
||||
"engines": {
|
||||
"gitbook": ">=3.0.0"
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
"description": "Automatically add anchors to headings",
|
||||
"main": "index.js",
|
||||
"browser": "./_assets/plugin.js",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"dependencies": {
|
||||
"classnames": "^2.2.5",
|
||||
"gitbook-core": "^4.0.0-alpha.5"
|
||||
"gitbook-core": "^4.0.0-alpha.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gitbook-plugin": "^4.0.0-alpha.5"
|
||||
"gitbook-plugin": "^4.0.0-alpha.6"
|
||||
},
|
||||
"engines": {
|
||||
"gitbook": ">=3.0.0"
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
"description": "Syntax highlighter for Gitbook",
|
||||
"main": "index.js",
|
||||
"browser": "./_assets/plugin.js",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"dependencies": {
|
||||
"gitbook-core": "^4.0.0-alpha.5",
|
||||
"gitbook-core": "^4.0.0-alpha.6",
|
||||
"highlight.js": "9.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gitbook-plugin": "^4.0.0-alpha.5"
|
||||
"gitbook-plugin": "^4.0.0-alpha.6"
|
||||
},
|
||||
"engines": {
|
||||
"gitbook": ">=3.0.0"
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
"description": "Defines four types of styled hint blocks: info, danger, tip, working.",
|
||||
"main": "index.js",
|
||||
"browser": "./_assets/plugin.js",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"dependencies": {
|
||||
"classnames": "^2.2.5",
|
||||
"gitbook-core": "^4.0.0-alpha.5"
|
||||
"gitbook-core": "^4.0.0-alpha.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gitbook-plugin": "^4.0.0-alpha.5"
|
||||
"gitbook-plugin": "^4.0.0-alpha.6"
|
||||
},
|
||||
"engines": {
|
||||
"gitbook": ">=4.0.0"
|
||||
|
||||
@@ -3,15 +3,15 @@
|
||||
"description": "Live reloading for your gitbook",
|
||||
"main": "index.js",
|
||||
"browser": "./_assets/plugin.js",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"engines": {
|
||||
"gitbook": "*"
|
||||
},
|
||||
"dependencies": {
|
||||
"gitbook-core": "^4.0.0-alpha.5"
|
||||
"gitbook-core": "^4.0.0-alpha.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gitbook-plugin": "^4.0.0-alpha.5"
|
||||
"gitbook-plugin": "^4.0.0-alpha.6"
|
||||
},
|
||||
"scripts": {
|
||||
"build-js": "gitbook-plugin build ./src/index.js ./_assets/plugin.js",
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
"description": "Static and local index for search in GitBook",
|
||||
"main": "index.js",
|
||||
"browser": "./_assets/theme.js",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"dependencies": {
|
||||
"gitbook-core": "^4.0.0-alpha.5",
|
||||
"gitbook-core": "^4.0.0-alpha.6",
|
||||
"html-entities": "1.2.0",
|
||||
"lunr": "0.5.12"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gitbook-plugin": "^4.0.0-alpha.5"
|
||||
"gitbook-plugin": "^4.0.0-alpha.6"
|
||||
},
|
||||
"engines": {
|
||||
"gitbook": ">=3.0.0"
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
"description": "Search integration in GitBook",
|
||||
"main": "index.js",
|
||||
"browser": "./_assets/theme.js",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"dependencies": {
|
||||
"gitbook-core": "^4.0.0-alpha.5",
|
||||
"gitbook-core": "^4.0.0-alpha.6",
|
||||
"react": "^15.4.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gitbook-plugin": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin": "^4.0.0-alpha.6",
|
||||
"react-highlighter": "^0.3.3"
|
||||
},
|
||||
"engines": {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"description": "Sharing buttons in the toolbar",
|
||||
"main": "index.js",
|
||||
"browser": "./_assets/plugin.js",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"gitbook": {
|
||||
"properties": {
|
||||
"facebook": {
|
||||
@@ -53,10 +53,10 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"gitbook-core": "^4.0.0-alpha.5"
|
||||
"gitbook-core": "^4.0.0-alpha.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"gitbook-plugin": "^4.0.0-alpha.5"
|
||||
"gitbook-plugin": "^4.0.0-alpha.6"
|
||||
},
|
||||
"engines": {
|
||||
"gitbook": ">=3.0.0"
|
||||
|
||||
@@ -3,19 +3,19 @@
|
||||
"description": "Default theme for GitBook",
|
||||
"main": "./index.js",
|
||||
"browser": "./_assets/theme.js",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"engines": {
|
||||
"gitbook": ">=3.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"debounce": "^1.0.0",
|
||||
"gitbook-core": "^4.0.0-alpha.5"
|
||||
"gitbook-core": "^4.0.0-alpha.6"
|
||||
},
|
||||
"devDependencies": {
|
||||
"classnames": "^2.2.5",
|
||||
"font-awesome": "^4.6.3",
|
||||
"gitbook-markdown-css": "^1.0.1",
|
||||
"gitbook-plugin": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin": "^4.0.0-alpha.6",
|
||||
"less": "^2.7.1",
|
||||
"less-plugin-clean-css": "^1.5.1",
|
||||
"preboot": "git+https://github.com/mdo/preboot.git#4aab4edd85f076d50609cbe28e4fe66cc0771701"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gitbook-plugin",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"description": "CLI for compiling and testing plugins",
|
||||
"main": "./lib/index.js",
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "gitbook",
|
||||
"version": "4.0.0-alpha.5",
|
||||
"version": "4.0.0-alpha.6",
|
||||
"homepage": "https://www.gitbook.com",
|
||||
"description": "Library and cmd utility to generate GitBooks",
|
||||
"main": "lib/index.js",
|
||||
@@ -22,16 +22,16 @@
|
||||
"extend": "^3.0.0",
|
||||
"fresh-require": "1.0.3",
|
||||
"front-matter": "^2.1.0",
|
||||
"gitbook-core": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin-copy-code": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin-headings": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin-highlight": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin-hints": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin-livereload": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin-lunr": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin-search": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin-sharing": "^4.0.0-alpha.5",
|
||||
"gitbook-plugin-theme-default": "^4.0.0-alpha.5",
|
||||
"gitbook-core": "^4.0.0-alpha.6",
|
||||
"gitbook-plugin-copy-code": "^4.0.0-alpha.6",
|
||||
"gitbook-plugin-headings": "^4.0.0-alpha.6",
|
||||
"gitbook-plugin-highlight": "^4.0.0-alpha.6",
|
||||
"gitbook-plugin-hints": "^4.0.0-alpha.6",
|
||||
"gitbook-plugin-livereload": "^4.0.0-alpha.6",
|
||||
"gitbook-plugin-lunr": "^4.0.0-alpha.6",
|
||||
"gitbook-plugin-search": "^4.0.0-alpha.6",
|
||||
"gitbook-plugin-sharing": "^4.0.0-alpha.6",
|
||||
"gitbook-plugin-theme-default": "^4.0.0-alpha.6",
|
||||
"github-slugid": "1.0.1",
|
||||
"graceful-fs": "4.1.4",
|
||||
"i18n-t": "1.0.1",
|
||||
|
||||
@@ -2,9 +2,7 @@ const { Record } = require('immutable');
|
||||
const File = require('./file');
|
||||
|
||||
const DEFAULTS = {
|
||||
file: new File(),
|
||||
title: String(),
|
||||
description: String()
|
||||
file: new File()
|
||||
};
|
||||
|
||||
class Readme extends Record(DEFAULTS) {
|
||||
@@ -12,14 +10,6 @@ class Readme extends Record(DEFAULTS) {
|
||||
return this.get('file');
|
||||
}
|
||||
|
||||
getTitle() {
|
||||
return this.get('title');
|
||||
}
|
||||
|
||||
getDescription() {
|
||||
return this.get('description');
|
||||
}
|
||||
|
||||
/**
|
||||
* Set file linked to the readme.
|
||||
* @param {File} file
|
||||
@@ -32,7 +22,6 @@ class Readme extends Record(DEFAULTS) {
|
||||
/**
|
||||
* Create a new readme
|
||||
*
|
||||
* @param {File} file
|
||||
* @param {Object} def
|
||||
* @return {Readme}
|
||||
*/
|
||||
@@ -40,8 +29,7 @@ class Readme extends Record(DEFAULTS) {
|
||||
def = def || {};
|
||||
|
||||
return new Readme({
|
||||
title: def.title || '',
|
||||
description: def.description || ''
|
||||
file: def.file || ''
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,8 +16,6 @@ describe('parseReadme', () => {
|
||||
const file = readme.getFile();
|
||||
|
||||
expect(file.exists()).toBeTruthy();
|
||||
expect(readme.title).toBe('Hello');
|
||||
expect(readme.description).toBe('And here is the description.');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
const expect = require('expect');
|
||||
const readDocument = require('./utils/readDocument');
|
||||
const readmeFromDocument = require('../readmeFromDocument');
|
||||
|
||||
function readReadme(filename) {
|
||||
const document = readDocument(filename);
|
||||
return readmeFromDocument(document);
|
||||
}
|
||||
|
||||
describe('readmeFromDocument', () => {
|
||||
|
||||
it('should parse only title', () => {
|
||||
const readme = readReadme('readme/only-title.yaml');
|
||||
expect(readme.title).toBe('Hello World');
|
||||
expect(readme.description).toBe('');
|
||||
});
|
||||
|
||||
it('should parse title and description', () => {
|
||||
const readme = readReadme('readme/normal.yaml');
|
||||
expect(readme.title).toBe('Hello World');
|
||||
expect(readme.description).toBe('This is a description');
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
const lookupStructureFile = require('./lookupStructureFile');
|
||||
const readmeFromDocument = require('./readmeFromDocument');
|
||||
const Readme = require('../models/readme');
|
||||
const error = require('../utils/error');
|
||||
|
||||
/**
|
||||
@@ -10,7 +10,6 @@ const error = require('../utils/error');
|
||||
*/
|
||||
function parseReadme(book) {
|
||||
const { logger } = book;
|
||||
const fs = book.getContentFS();
|
||||
|
||||
return lookupStructureFile(book, 'readme')
|
||||
.then((file) => {
|
||||
@@ -19,12 +18,8 @@ function parseReadme(book) {
|
||||
}
|
||||
|
||||
logger.debug.ln(`readme found at ${file.path}`);
|
||||
return file.parse(fs)
|
||||
.then((document) => {
|
||||
let readme = readmeFromDocument(document);
|
||||
readme = readme.setFile(file);
|
||||
return book.set('readme', readme);
|
||||
});
|
||||
|
||||
return book.set('readme', Readme.create({ file }));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
const { BLOCKS } = require('markup-it');
|
||||
const Readme = require('../models/readme');
|
||||
|
||||
/**
|
||||
* Parse a readme from a document.
|
||||
* @param {Document} document
|
||||
* @return {Readme} readme
|
||||
*/
|
||||
function readmeFromDocument(document) {
|
||||
const { nodes } = document;
|
||||
|
||||
const first = nodes.first();
|
||||
const second = nodes.get(1);
|
||||
|
||||
return Readme.create({
|
||||
title: first && first.type == BLOCKS.HEADING_1 ? first.text : '',
|
||||
description: second && second.type == BLOCKS.PARAGRAPH ? second.text : ''
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = readmeFromDocument;
|
||||
Reference in New Issue
Block a user