Skip to content

Commit 8ac31ba

Browse files
authored
Add overview of the APIs exported by @webdoc/model
1 parent c616256 commit 8ac31ba

File tree

1 file changed

+52
-3
lines changed

1 file changed

+52
-3
lines changed

packages/webdoc-model/README.md

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,64 @@
11
# @webdoc/model
22

3-
This package is the API to manipulating loaded documentation tree models. [@webdoc/types](https://github.com/webdoc-js/webdoc/tree/master/packages/webdoc-types) defines the node structure.
3+
This package is the API for editing and querying in-memory documentation tree models. [@webdoc/types](/packages/webdoc-types) defines the node structure.
44

55
## Installation :package:
66

7+
This package is usually a dependency of templates and other webdoc packages.
8+
79
```bash
810
npm install @webdoc/model
911
```
1012

11-
## Usage
13+
## Usage :newspaper_roll:
14+
15+
```js
16+
import * as model from '@webdoc/model';
17+
```
18+
19+
### Constructing and editing documents
20+
21+
```js
22+
const entity = model.createDoc(
23+
"DocumentedEntity",
24+
"ClassDoc",
25+
{
26+
"description": "This is a programmatically created document!",
27+
}
28+
);
29+
30+
const entityNs = model.doc("Documentation.Entities", documentTree);
31+
32+
model.addChildDoc(entity, entityNs);
33+
```
34+
35+
@webdoc/model exports helper functions for creating and searching documents and mounting them into document trees.
36+
37+
### Data types
1238

1339
```js
14-
const Model = require('@webdoc/model');
40+
model.createFunctionType(
41+
[model.createSimpleKeywordType("Promise")], // params
42+
model.createSimpleKeywordType("boolean"), // returns
43+
);
1544
```
45+
46+
@webdoc/model exports helper functions for creating and joining data types. The `DataType` type is defined in [@webdoc/types](/packages/webdoc-types).
47+
48+
### Querying
49+
50+
```js
51+
// Gets all the methods named "generic" in DocumentedEntity. Each signature of the method has a separate document. The
52+
// # operator excludes any static "generic"-named methods.
53+
const genericSignatures = model.query("Documentation.Entities.DocumentedEntity#generic", documentTree);
54+
```
55+
56+
@webdoc/model exports a query engine for its document path language.
57+
58+
### Runtime type-checking
59+
60+
```js
61+
const isInstantiable = model.isClass(doc) || model.isInterface(doc);
62+
```
63+
64+
@webdoc/model exports helper functions for checking the types of document passed.

0 commit comments

Comments
 (0)