From 7d05d69707b8c631ea89b13c019ccbad00f85b1c Mon Sep 17 00:00:00 2001
From: Dolan
Date: Sat, 4 Aug 2018 04:03:08 +0100
Subject: [PATCH] Update documentation and README
---
README.md | 59 +++++++------------------------
docs/README.md | 34 ++++++++++++++----
docs/contribution-guidelines.md | 4 +--
docs/index.html | 39 +++++++++++---------
docs/usage/headers-and-footers.md | 8 ++---
docs/usage/images.md | 10 +++---
6 files changed, 74 insertions(+), 80 deletions(-)
diff --git a/README.md b/README.md
index 60da1a934b..204317b421 100644
--- a/README.md
+++ b/README.md
@@ -31,15 +31,15 @@ Press `endpoint` on the `RunKit` website:

-* https://runkit.com/dolanmiu/docx-demo1 - Simple paragraph and text
-* https://runkit.com/dolanmiu/docx-demo2 - Advanced Paragraphs and text
-* https://runkit.com/dolanmiu/docx-demo3 - Bullet points
-* https://runkit.com/dolanmiu/docx-demo4 - Simple table
-* https://runkit.com/dolanmiu/docx-demo5 - Images
-* https://runkit.com/dolanmiu/docx-demo6 - Margins
-* https://runkit.com/dolanmiu/docx-demo7 - Landscape
-* https://runkit.com/dolanmiu/docx-demo8/1.0.1 - Header and Footer
-* https://runkit.com/dolanmiu/docx-demo10 - **My CV generated with docx**
+* https://runkit.com/dolanmiu/docx-demo1 - Simple paragraph and text
+* https://runkit.com/dolanmiu/docx-demo2 - Advanced Paragraphs and text
+* https://runkit.com/dolanmiu/docx-demo3 - Bullet points
+* https://runkit.com/dolanmiu/docx-demo4 - Simple table
+* https://runkit.com/dolanmiu/docx-demo5 - Images
+* https://runkit.com/dolanmiu/docx-demo6 - Margins
+* https://runkit.com/dolanmiu/docx-demo7 - Landscape
+* https://runkit.com/dolanmiu/docx-demo8/1.0.1 - Header and Footer
+* https://runkit.com/dolanmiu/docx-demo10 - **My CV generated with docx**
#### Run demos locally:
@@ -49,50 +49,17 @@ $ npm run demo
This command will run the demo selector app in the `demo` folder. It will prompt you to select a demo number, which will run a demo from that folder.
-## Guide
+## How to
-Please refer to [the Wiki](https://github.com/dolanmiu/docx/wiki) for details on how to use this library, examples and much more!
-
-Full documentation can be found here: [http://dolanmiu.github.io/docx/index.html](http://dolanmiu.github.io/docx/index.html)
-
-## Simple Usage
-
-```js
-// Used to create docx files
-var docx = require("docx");
-
-// Create document
-var doc = new docx.Document();
-
-// Add some content in the document
-var paragraph = new docx.Paragraph("Some cool text here.");
-// Add more text into the paragraph if you wish
-paragraph.addRun(new docx.TextRun("Lorem Ipsum Foo Bar"));
-doc.addParagraph(paragraph);
-
-// Used to export the file into a .docx file
-var exporter = new docx.LocalPacker(doc);
-
-// Or use the express packer to make the file downloadable.
-// res is express' Response object
-var exporter = new docx.ExpressPacker(doc, res);
-
-exporter.pack("My First Document");
-// If you want to export it as a .pdf file instead
-exporter.packPdf("My First Document");
-
-// done! A file called 'My First Document.docx'
-// will be in your file system if you used LocalPacker
-// Or it will start downloading if you are using Express
-```
+Please refer to [https://docx.js.org/](https://docx.js.org/) for details on how to use this library, examples and much more!
## Examples
-Check [the Wiki](https://github.com/dolanmiu/docx/wiki/Examples) and the [demo folder](https://github.com/dolanmiu/docx/tree/master/demo) for examples.
+Check the examples section in the [documentation](https://docx.js.org/#/usage/examples) and the [demo folder](https://github.com/dolanmiu/docx/tree/master/demo) for examples.
# Contributing
-Read the contribution guidelines [here](https://github.com/dolanmiu/docx/wiki/Contributing-Guidelines).
+Read the contribution guidelines [here](https://docx.js.org/#/contribution-guidelines).
# Honoured Mentions
diff --git a/docs/README.md b/docs/README.md
index 1df213c45d..2ea6ac25e3 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -3,30 +3,50 @@
- Easily generate .docx files with JS/TS.
+ Easily generate .docx files with JS/TS. :100:
---
# Welcome
-## Getting Started
-
-### Installation
+## Installation
```sh
-$ npm install --save docx
+npm install --save docx
```
+
Then you can `require` or `import` as usual:
-```
+```js
let docx = require('docx');
```
-```
+```js
import * as docx from 'docx'
```
+## Basic Usage
+
+```js
+var docx = require("docx");
+
+// Create document
+var doc = new docx.Document();
+
+// Add some content in the document
+var paragraph = new docx.Paragraph("Some cool text here.");
+// Add more text into the paragraph if you wish
+paragraph.addRun(new docx.TextRun("Lorem Ipsum Foo Bar"));
+doc.addParagraph(paragraph);
+
+// Used to export the file into a .docx file
+var exporter = new docx.LocalPacker(doc);
+
+exporter.pack("My First Document");
+
+// Done! A file called 'My First Document.docx' will be in your file system if you used LocalPacker
+```
---
diff --git a/docs/contribution-guidelines.md b/docs/contribution-guidelines.md
index cb49368c38..28cfbad954 100644
--- a/docs/contribution-guidelines.md
+++ b/docs/contribution-guidelines.md
@@ -4,7 +4,7 @@
* Include documentation reference(s) at the top of each file:
- ```ts
+ ```js
// http://officeopenxml.com/WPdocument.php
```
@@ -18,7 +18,7 @@ Please write a test of every file you make and suffix it with `.spec.ts`.
Here is a template of a test:
-```ts
+```js
import { assert } from "chai";
describe("ClassName", () => {
diff --git a/docs/index.html b/docs/index.html
index 9ff9bd26a2..4b35f622af 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -1,23 +1,30 @@
+
-
- docx - Generate .docx documents with JavaScript
-
-
-
-
+
+ docx - Generate .docx documents with JavaScript
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
diff --git a/docs/usage/headers-and-footers.md b/docs/usage/headers-and-footers.md
index 8c3803cc3f..72aa424d33 100644
--- a/docs/usage/headers-and-footers.md
+++ b/docs/usage/headers-and-footers.md
@@ -4,21 +4,21 @@
Creating Headers and footers is simple. Access the `Header` and `Footer` by doing so like this:
-```ts
+```js
doc.Header;
doc.Footer;
```
You can call the same methods as you would with a `File`:
-```ts
+```js
doc.Header.createParagraph("Header text");
doc.Footer.createParagraph("Footer text");
```
Even add images:
-```ts
+```js
doc.Header.createImage([PATH_TO_YOUR_IMAGE]);
doc.Footer.createImage([PATH_TO_YOUR_IMAGE]);
```
@@ -31,7 +31,7 @@ Also all the supported section properties are implemented according to: http://o
### Example
-```ts
+```js
const header = this.document.createHeader();
const footer = this.document.createFooter();
diff --git a/docs/usage/images.md b/docs/usage/images.md
index bbd91d31fb..2cc0339507 100644
--- a/docs/usage/images.md
+++ b/docs/usage/images.md
@@ -6,7 +6,7 @@ Adding images is very simple
Simply call the `createImage` method:
-```ts
+```js
const image = doc.createImage([PATH_TO_YOUR_IMAGE]);
```
@@ -32,7 +32,7 @@ In Word this is found in:
The `PictureRun` element support various options to define the positioning of the element in the document.
-```ts
+```js
interface DrawingOptions {
position?: PlacementPosition;
textWrapping?: TextWrapping;
@@ -42,7 +42,7 @@ interface DrawingOptions {
can be passed when creating `PictureRun()` for example:
-```ts
+```js
const imageData = document.createImageData(filename, buffer, 903, 1149);
new docx.PictureRun(imageData, {
@@ -68,7 +68,7 @@ When placement position is FLOATING then we can use two options:
for `drawingOptions.textWrapping` we can define various options. `textWrapping` has the following properties:
-```ts
+```js
interface TextWrapping {
textWrapStyle: TextWrapStyle;
wrapTextOption?: WrapTextOption;
@@ -94,7 +94,7 @@ enum WrapTextOption {
When we want to position the image relative or absolute then we need to use option `drawingOptions.floating`:
-```ts
+```js
export interface Floating {
horizontalPosition: HorizontalPositionOptions;
verticalPosition: VerticalPositionOptions;