Skip to content

Commit cdafe27

Browse files
committed
More updates to documentation
1 parent fa26e0f commit cdafe27

File tree

7 files changed

+110
-23
lines changed

7 files changed

+110
-23
lines changed

README.md

+16-15
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,16 @@ You could use `docxml` to:
1111
- Parse content from an existing DOCX file
1212
- Extract style definitions from a DOTX/DOCX file
1313

14-
### For Deno or for NodeJS
14+
This documentation for this lib is available at various locations:
15+
16+
[👉 Documentation site](https://wvbe.github.io/docxml)<br />
17+
[👉 GitHub source](http://github.com/wvbe/docxml)<br />
18+
[👉 Deno mirror](http://deno.land/x/docxml)<br />
19+
[👉 npm mirror](http://npmjs.org/package/docxml)
20+
21+
#### For Deno or for NodeJS
22+
23+
[👉 Main article](./docs/setup/deno-or-node.md)
1524

1625
`docxml` can be used in [NodeJS](https://nodejs.org/) and [Deno](https://deno.land) according to the traditions in those
1726
ecosystems. For Node users, simply `npm install docxml` and then `require()` or `import` as you wish. For Deno users,
@@ -28,9 +37,9 @@ import Docxml, { Paragraph } from 'docxml';
2837
import Docxml, { Paragraph } from 'https://deno.land/x/docxml/mod.ts';
2938
```
3039

31-
[Read all about `docxml` in Deno or Node](./docs/setup/deno-or-node.md)
40+
#### For JSX or for vanilla
3241

33-
### For JSX or for vanilla
42+
[👉 Main article](./docs/setup/jsx-or-not.md)
3443

3544
`docxml` is designed to be used in vanilla JavaScript using class component instances, or using JSX if you're on Deno or
3645
want to use NodeJS and a transpiler like Babel:
@@ -48,11 +57,7 @@ const para = (
4857
);
4958
```
5059

51-
[👉 More on using class components](https://github.com/wvbe/docxml/wiki/Get-started#components)
52-
53-
[👉 More on using JSX](https://github.com/wvbe/docxml/wiki/Get-started#using-jsx)
54-
55-
### For XML or for anything
60+
#### For XML or for anything
5661

5762
`docxml` is also designed to be used from scratch/entirely programmatically, or using a more ergonomic API
5863
to transform from an XML document. Both modes work equally well with vanilla JS or JSX.
@@ -75,11 +80,7 @@ await Docx.fromNothing()
7580
.toFile('example-2.docx');
7681
```
7782

78-
[👉 More on XML rendering rules](https://github.com/wvbe/docxml/wiki/Get-started#rendering-xml)
79-
80-
[👉 Go to the API docs that Deno generates for docxml](https://deno.land/x/docxml@5.2.0/mod.ts)
81-
82-
# Features
83+
#### Features
8384

8485
To great or small extend, the following features work in the current version of `docxml`. Some items are not ticked off
8586
yet -- they are not available, but hopefully soon.
@@ -140,7 +141,7 @@ yet -- they are not available, but hopefully soon.
140141
- [x] Style changes
141142
- [x] Table row additions and deletions
142143

143-
# Differences with actual MS Word DOCX
144+
#### Differences with actual MS Word DOCX
144145

145146
Obviously `docxml` is a TypeScript project, which is already very different from how you would normally interact
146147
with a DOCX document. More meaningfully however, `docxml` is meant to make writing DOCX _easier_ than going straight
@@ -159,7 +160,7 @@ to OOXML. For example;
159160
- Especially in tables and images, a lot of formatting details are automatically applied. In a lot of cases there
160161
is no API _yet_ to change them.
161162

162-
# For contributors
163+
#### For contributors
163164

164165
This project uses unit tests and linting for quality control. To lint, both Deno's own linting as well as ESLint are used.
165166
Please run both of the following commands to ensure that a GitHub Action does not fail later.

docs/examples/bookmarks.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
To cross-reference other parts of the document you need to use the `<Hyperlink>` component, and point it to either an `anchor` or a `bookmark`.
22

3-
### Reference specific content through bookmarks
3+
[👉 Read more about hyperlinking external content instead](hyperlinks.md)
4+
5+
### Bookmark ranges
46

57
For referencing specific content, you'll need to create a custom bookmark;
68

@@ -52,3 +54,12 @@ docx.toFile('hyperlinks.docx');
5254
There are a few anchors pre-defined:
5355

5456
- `"_top"`
57+
- More???
58+
59+
These anchor(s) can be referenced with the `anchor` prop:
60+
61+
```tsx
62+
<Hyperlink anchor="_top">
63+
<Text>Go to top</Text>
64+
</Hyperlink>
65+
```

docs/examples/hyperlinks.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ The `<Hyperlink>` component can be used to create clickable references to extern
77
</Text>
88
</Hyperlink>
99
```
10+
11+
[👉 Read more about cross-referencing to another part of the document](bookmarks.md)

docs/examples/paragraphs.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
Paragraphs are the bread and butter of text processors like MS Word and Google Docs. Paragraphs are
2+
the most common top-level building block of an OOXML/DOCX document.
3+
4+
For example, headings and list items are both paragraphs, but with different style properties.
5+
6+
[👉 Read more about styling paragraphs as lists and list items](./lists.md)
7+
8+
You'll probably use the `Paragraph` component all over the place, and get acquinted with its
9+
formatting options.
10+
11+
```tsx
12+
<Paragraph
13+
alignment="center"
14+
spacing={{
15+
before: cm(1),
16+
after: cm(1),
17+
}}
18+
indentation={{
19+
firstLine: cm(2),
20+
}}
21+
shading={{
22+
background: 'yellow',
23+
foreground: 'orange',
24+
pattern: 'diagStripe',
25+
}}
26+
>
27+
28+
</Paragraph>
29+
```
30+
31+
[👉 Jump to the type definition of paragraph properties](https://github.com/wvbe/docxml/blob/develop/src/properties/paragraph-properties.ts#L20)

docs/setup/instantiation.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
### Starting from nothing
2+
3+
To create a document from _nothing_ is the most straight-forward way to use `docxml`. This creates
4+
a new document entirely devoid of content, styles, relationships, headers/footers, bookmarks and so
5+
on.
6+
7+
```tsx
8+
/** @jsx Docx.jsx */
9+
import Docx, { Paragraph, Text } from 'docxml';
10+
11+
const docx = Docx.fromNothing();
12+
```
13+
14+
Or, if you already know what should go in your document;
15+
16+
```tsx
17+
const docx = Docx.fromJsx(<Paragraph>Hello world!</Paragraph>);
18+
```
19+
20+
The `docx` instance from the example above provides access to some interesting helper classes that
21+
are roughly organised in the way that a DOCX archive is itself;
22+
23+
- `docx.bookmarks` to add bookmarks that can be shared between ranges and links. [Read more about cross-referencing to bookmarks](../examples/bookmarks.md).
24+
- `docx.document` to control the document contents, and relationships directly to `word/document.xml`
25+
- `docx.document.styles` to read/write custom style definitions
26+
- `docx.document.numbering` to read/write list numbering schemes. [Read more about creating lists and numbering](../examples/lists.md).
27+
- `docx.document.settings` to read or write `settings.xml`
28+
- `docx.document.headers` and `docx.document.headers` to add those things. [Read more about setting page headers and footers](../examples/headers-and-footers.md).
29+
30+
### Starting from a file
31+
32+
For all intents and purposes a `.dotx` template file is the same as the `.docx` document instance. You can instantiate
33+
`docxml` from them:
34+
35+
```tsx
36+
const docx = Docx.fromArchive('my-template.dotx');
37+
```
38+
39+
The `docx` instance that returns can be used in all the same ways as if you were to instantiate `docxml` in another way,
40+
but it'll be prepopulated with all the styles, numberings, headers/footers, settings, document contents, etc. that already
41+
were in your file.

docs/site/_sidebar.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
- [Introduction](/)
12
- **Setup**
2-
33
- [Deno, or Node](../setup/deno-or-node.md)
44
- [JSX, or not](../setup/jsx-or-not.md)
5-
5+
- [Instantiation](../setup/instantiation.md)
66
- **Examples**
7-
- [Tables](../examples/tables.md)
8-
- [Images](../examples/images.md)
7+
- [Paragraphs](../examples/paragraphs.md)
98
- [Lists](../examples/lists.md)
10-
- [Sections](../examples/sections.md)
11-
- [Headers/footers](../examples/headers-and-footers.md)
129
- [Hyperlinks](../examples/hyperlinks.md)
1310
- [Bookmarks](../examples/bookmarks.md)
11+
- [Images](../examples/images.md)
12+
- [Tables](../examples/tables.md)
13+
- [Sections](../examples/sections.md)
14+
- [Headers/footers](../examples/headers-and-footers.md)

index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
nativeEmoji: true,
4242
relativePath: true,
4343
maxLevel: 4,
44-
subMaxLevel: 2,
44+
subMaxLevel: 3,
4545
name: 'docxml',
4646
nameLink: {
4747
'/': '#/',

0 commit comments

Comments
 (0)