From 3d9b305dddaa70ca8bf2c35ce6e56fd0035faecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ionic=C4=83=20Biz=C4=83u?= Date: Tue, 26 Apr 2016 08:59:25 +0300 Subject: [PATCH] Updated docs --- CONTRIBUTING.md | 4 +++- DOCUMENTATION.md | 60 ++++++++++++++++++++++++++++++++++++++++++++++++ README.md | 10 +++++++- 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 DOCUMENTATION.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 12051c3..85ebee6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -59,6 +59,8 @@ Contributions are more than welcome! Thanks! :sweat_smile: + + [1]: https://github.com/IonicaBizau/nodeice/issues -[2]: https://github.com/IonicaBizau/code-style \ No newline at end of file +[2]: https://github.com/IonicaBizau/code-style diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md new file mode 100644 index 0000000..f816149 --- /dev/null +++ b/DOCUMENTATION.md @@ -0,0 +1,60 @@ +## Documentation + +You can see below the API reference of this module. + +### `Invoice(options)` +This is the constructor that creates a new instance containing the needed +methods. + +#### Params +- **Object** `options`: The options for creating the new invoice: + - `config` (Object): + - `template` (String): The HTML root template. + - `data` (Object): + - `currencyBalance` (Object): + - `main` (Number): The main balance. + - `secondary` (Number): The converted main balance. + - `tasks` (Array): An array with the tasks (description of the services you did). + - `invoice` (Object): Information about invoice. + - `seller` (Object): Information about seller. + - `buyer` (Object): Information about buyer. + +### `initTemplates(callback)` +Inits the HTML templates. + +#### Params +- **Function** `callback`: The callback function. + +### `toHtml(output, callback)` +Renders the invoice in HTML format. + +#### Params +- **String** `output`: An optional path to the output file. +- **Function** `callback`: The callback function. + +#### Return +- **Invoice** The `Nodeice` instance. + +### `convertToSecondary(input)` +Converts a currency into another currency according to the currency +balance provided in the options + +#### Params +- **Number** `input`: The number that should be converted + +#### Return +- **Number** The converted input + +### `toPdf(options, callback)` +Renders invoice as pdf + +#### Params +- **Object|String|Stream** `options`: The path the output pdf file, the stream object, or an object containing: + + - `output` (String|Stream): The path to the output file or the stream object. + - `converter` (Object): An object containing custom settings for the [`phantom-html-to-pdf`](https://github.com/pofider/phantom-html-to-pdf). +- **Function** `callback`: The callback function + +#### Return +- **Invoice** The Invoice instance + diff --git a/README.md b/README.md index fbdfd36..14ffe0c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ + [![nodeice](http://i.imgur.com/NuF1OI0.png)](#) # nodeice [![PayPal](https://img.shields.io/badge/%24-paypal-f39c12.svg)][paypal-donations] [![Version](https://img.shields.io/npm/v/nodeice.svg)](https://www.npmjs.com/package/nodeice) [![Downloads](https://img.shields.io/npm/dt/nodeice.svg)](https://www.npmjs.com/package/nodeice) [![Get help on Codementor](https://cdn.codementor.io/badges/get_help_github.svg)](https://www.codementor.io/johnnyb?utm_source=github&utm_medium=button&utm_term=johnnyb&utm_campaign=github) @@ -12,8 +13,11 @@ $ npm i --save nodeice ``` + ## :clipboard: Example + + ```js const Invoice = require("nodeice"); @@ -123,6 +127,7 @@ require("http").createServer((req, res) => { ## :memo: Documentation + ### `Invoice(options)` This is the constructor that creates a new instance containing the needed methods. @@ -179,9 +184,12 @@ Renders invoice as pdf #### Return - **Invoice** The Invoice instance + + ## :yum: How to contribute Have an idea? Found a bug? See [how to contribute][contributing]. + ## :scroll: License [MIT][license] © [Ionică Bizău][website] @@ -192,4 +200,4 @@ Have an idea? Found a bug? See [how to contribute][contributing]. [license]: http://showalicense.com/?fullname=Ionic%C4%83%20Biz%C4%83u%20%3Cbizauionica%40gmail.com%3E%20(http%3A%2F%2Fionicabizau.net)&year=2014#license-mit [website]: http://ionicabizau.net [contributing]: /CONTRIBUTING.md -[docs]: /DOCUMENTATION.md \ No newline at end of file +[docs]: /DOCUMENTATION.md