diff options
author | Samy Pesse <samypesse@gmail.com> | 2016-02-29 21:50:48 +0100 |
---|---|---|
committer | Samy Pesse <samypesse@gmail.com> | 2016-02-29 21:50:48 +0100 |
commit | c08e5ce62c30cb8d014151448bfe6da6b5a47fcf (patch) | |
tree | fd9504c00d46786aebe2c65c6a95fa62edb363a7 /docs | |
parent | ec353e179dedf1ebf1ab6e54f6217a88d087ea75 (diff) | |
download | gitbook-c08e5ce62c30cb8d014151448bfe6da6b5a47fcf.zip gitbook-c08e5ce62c30cb8d014151448bfe6da6b5a47fcf.tar.gz gitbook-c08e5ce62c30cb8d014151448bfe6da6b5a47fcf.tar.bz2 |
Improve structure of doc
Diffstat (limited to 'docs')
-rw-r--r-- | docs/SUMMARY.md | 15 | ||||
-rw-r--r-- | docs/plugins/README.md (renamed from docs/plugins.md) | 0 | ||||
-rw-r--r-- | docs/plugins/create.md | 63 | ||||
-rw-r--r-- | docs/plugins/hooks.md | 0 | ||||
-rw-r--r-- | docs/plugins/testing.md | 22 | ||||
-rw-r--r-- | docs/templating/README.md (renamed from docs/templating.md) | 0 | ||||
-rw-r--r-- | docs/templating/conrefs.md (renamed from docs/conrefs.md) | 0 | ||||
-rw-r--r-- | docs/templating/variables.md (renamed from docs/variables.md) | 0 | ||||
-rw-r--r-- | docs/themes/README.md (renamed from docs/themes.md) | 0 |
9 files changed, 92 insertions, 8 deletions
diff --git a/docs/SUMMARY.md b/docs/SUMMARY.md index a304801..2919ab7 100644 --- a/docs/SUMMARY.md +++ b/docs/SUMMARY.md @@ -14,16 +14,15 @@ * [Configuration](config.md) * [AsciiDoc](asciidoc.md) -### Miscellaneous - -* [Templating](templating.md) -* [Content References](conrefs.md) -* [Variables](variables.md) - ### Customization -* [Plugins](plugins.md) -* [Theming](themes.md) +* [Templating](templating/README.md) + * [Content References](templating/conrefs.md) + * [Variables](templating/variables.md) +* [Plugins](plugins/README.md) + * [Create a plugin](plugins/create.md) + * [Test your plugin](plugins/testing.md) +* [Theming](themes/README.md) -- diff --git a/docs/plugins.md b/docs/plugins/README.md index ff56b7b..ff56b7b 100644 --- a/docs/plugins.md +++ b/docs/plugins/README.md diff --git a/docs/plugins/create.md b/docs/plugins/create.md new file mode 100644 index 0000000..787b191 --- /dev/null +++ b/docs/plugins/create.md @@ -0,0 +1,63 @@ +# Create and publish a plugin + +A GitBook plugin is a node package published on NPM that follow a defined convention. + +## Structure + +#### package.json + +The `package.json` is a manifest format for describing **Node.js modules**. GitBook plugins are built on top of Node modules. It declares dependencies, version, ownership, and other information required to run a plugin in GitBook. This document describes the schema in detail. + +``` +{ + "name": "gitbook-plugin-mytest", + "version": "0.0.1", + "description": "This is my first GitBook plugin", + "engines": { + "gitbook": ">1.x.x" + } +} +``` + +You can learn more about `package.json` from the [NPM documentation](https://docs.npmjs.com/files/package.json). + +The **package name** must begin with `gitbook-plugin-` and the **package engines** should contains `gitbook`. + +#### index.js + +The `index.js` is main entry point of your plugin runtime: + +```js +module.exports = { + // Map of hooks + hooks: {}, + + // Map of new blocks + blocks: {}, + + // Map of new filters + filters: {} +}; +``` + +## Publish your plugin + +GitBook plugins can be published on [NPM](https://www.npmjs.com). + +To publish a new plugin, you need to create an account on [npmjs.com](https://www.npmjs.com) then publish it from the command line: + +``` +$ npm publish +``` + +## Private plugins + +Private plugins can be hosted on GitHub and included using `git` urls: + +``` +{ + "plugins": [ + "git+https://github.com/MyCompany/mygitbookplugin.git#1.0.0" + ] +} +``` diff --git a/docs/plugins/hooks.md b/docs/plugins/hooks.md new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/docs/plugins/hooks.md diff --git a/docs/plugins/testing.md b/docs/plugins/testing.md new file mode 100644 index 0000000..bf00da2 --- /dev/null +++ b/docs/plugins/testing.md @@ -0,0 +1,22 @@ +# Testing your plugin + +### Testing your plugin locally + +Testing your plugin on your book before plushing it is possible using [npm link](https://docs.npmjs.com/cli/link). + +In the plugin's folder, run: + +``` +$ npm link +``` + +The nin your book's folder: + +``` +$ npm link gitbook-plugin-<plugin's name> +``` + +### Unit testing on Travis + +[gitbook-tester](https://github.com/todvora/gitbook-tester) makes it easy to write **Node.js/Mocha** unit tests for your plugins. Using [Travis.org](https://travis.org), tests can be run on each commits/tags. + diff --git a/docs/templating.md b/docs/templating/README.md index 38df38e..38df38e 100644 --- a/docs/templating.md +++ b/docs/templating/README.md diff --git a/docs/conrefs.md b/docs/templating/conrefs.md index 7844e9c..7844e9c 100644 --- a/docs/conrefs.md +++ b/docs/templating/conrefs.md diff --git a/docs/variables.md b/docs/templating/variables.md index 3dbd6f7..3dbd6f7 100644 --- a/docs/variables.md +++ b/docs/templating/variables.md diff --git a/docs/themes.md b/docs/themes/README.md index 48c19db..48c19db 100644 --- a/docs/themes.md +++ b/docs/themes/README.md |