embedoc 0.14.9 → 0.14.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -1
- package/cli-contract.yaml +3 -3
- package/dist/cli.js +4 -5
- package/dist/cli.js.map +1 -1
- package/dist/core/dependency.d.ts.map +1 -1
- package/dist/core/dependency.js +2 -5
- package/dist/core/dependency.js.map +1 -1
- package/dist/core/generator.d.ts.map +1 -1
- package/dist/core/generator.js +32 -2
- package/dist/core/generator.js.map +1 -1
- package/dist/core/inline-datasource.d.ts +11 -2
- package/dist/core/inline-datasource.d.ts.map +1 -1
- package/dist/core/inline-datasource.js +11 -2
- package/dist/core/inline-datasource.js.map +1 -1
- package/dist/core/processor.d.ts +5 -0
- package/dist/core/processor.d.ts.map +1 -1
- package/dist/core/processor.js +11 -10
- package/dist/core/processor.js.map +1 -1
- package/dist/datasources/csv.d.ts.map +1 -1
- package/dist/datasources/csv.js +2 -11
- package/dist/datasources/csv.js.map +1 -1
- package/dist/datasources/filter.d.ts +12 -0
- package/dist/datasources/filter.d.ts.map +1 -0
- package/dist/datasources/filter.js +19 -0
- package/dist/datasources/filter.js.map +1 -0
- package/dist/datasources/glob.d.ts.map +1 -1
- package/dist/datasources/glob.js +2 -14
- package/dist/datasources/glob.js.map +1 -1
- package/dist/datasources/index.d.ts +1 -0
- package/dist/datasources/index.d.ts.map +1 -1
- package/dist/datasources/index.js +4 -0
- package/dist/datasources/index.js.map +1 -1
- package/dist/datasources/json.d.ts.map +1 -1
- package/dist/datasources/json.js +2 -14
- package/dist/datasources/json.js.map +1 -1
- package/dist/datasources/typescript.d.ts +40 -0
- package/dist/datasources/typescript.d.ts.map +1 -0
- package/dist/datasources/typescript.js +901 -0
- package/dist/datasources/typescript.js.map +1 -0
- package/dist/datasources/yaml.d.ts.map +1 -1
- package/dist/datasources/yaml.js +2 -14
- package/dist/datasources/yaml.js.map +1 -1
- package/dist/embed-api.d.ts +13 -1
- package/dist/embed-api.d.ts.map +1 -1
- package/dist/embed-api.js +4 -0
- package/dist/embed-api.js.map +1 -1
- package/dist/embedoc.bundle.mjs +123 -100
- package/dist/embedoc.bundle.mjs.map +4 -4
- package/dist/generated/contract.d.ts.map +1 -1
- package/dist/generated/contract.js +2 -2
- package/dist/generated/contract.js.map +1 -1
- package/dist/generated/program.d.ts.map +1 -1
- package/dist/generated/program.js +4 -2
- package/dist/generated/program.js.map +1 -1
- package/dist/helpers/api-markdown.d.ts +47 -0
- package/dist/helpers/api-markdown.d.ts.map +1 -0
- package/dist/helpers/api-markdown.js +381 -0
- package/dist/helpers/api-markdown.js.map +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +164 -4
- package/dist/types/index.d.ts.map +1 -1
- package/docs/api/README.md +1080 -401
- package/docs/cli-reference.md +2 -2
- package/package.json +31 -16
package/docs/api/README.md
CHANGED
|
@@ -1,28 +1,268 @@
|
|
|
1
1
|
# Embed API Reference
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Types and functions for writing embeds, custom datasources and API references with embedoc.
|
|
4
|
+
Everything below is generated from [`src/embed-api.ts`](../../src/embed-api.ts) by the
|
|
5
|
+
`typescript` datasource (`npm run docs`).
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
<!--@embedoc:api_reference datasource="embed_api"-->
|
|
8
|
+
## Classes
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
### InlineDatasource
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
import { defineEmbed, type EmbedContext, type EmbedResult } from 'embedoc';
|
|
12
|
+
Defined in: [core/inline-datasource.ts:333](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L333)
|
|
11
13
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
Datasource for document-local data defined with `@embedoc-data` markers.
|
|
15
|
+
|
|
16
|
+
Embeds receive it in `ctx.datasources` like any other [`Datasource`](#datasource),
|
|
17
|
+
and can read where each property was defined with [`InlineDatasource.getMeta`](#inlinedatasource).
|
|
18
|
+
|
|
19
|
+
#### Implements
|
|
20
|
+
|
|
21
|
+
- `Datasource`
|
|
22
|
+
|
|
23
|
+
#### Properties
|
|
24
|
+
|
|
25
|
+
| Property | Type | Description | Defined in |
|
|
26
|
+
| ------ | ------ | ------ | ------ |
|
|
27
|
+
| <a id="type"></a> `type` (readonly) | `"inline"` | | [core/inline-datasource.ts:334](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L334) |
|
|
28
|
+
| <a id="format"></a> `format` (readonly) | `string` | | [core/inline-datasource.ts:335](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L335) |
|
|
29
|
+
| <a id="documentpath"></a> `documentPath` (readonly) | `string` | | [core/inline-datasource.ts:336](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L336) |
|
|
30
|
+
| <a id="startline"></a> `startLine` (readonly) | `number` | | [core/inline-datasource.ts:337](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L337) |
|
|
31
|
+
| <a id="endline"></a> `endLine` (readonly) | `number` | | [core/inline-datasource.ts:338](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L338) |
|
|
32
|
+
| <a id="bytesize"></a> `byteSize` (readonly) | `number` | | [core/inline-datasource.ts:339](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L339) |
|
|
33
|
+
|
|
34
|
+
#### Methods
|
|
35
|
+
|
|
36
|
+
##### query()
|
|
37
|
+
|
|
38
|
+
```ts
|
|
39
|
+
query(_sql: string, _params?: unknown[]): Promise<QueryResult>;
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Defined in: [core/inline-datasource.ts:380](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L380)
|
|
43
|
+
|
|
44
|
+
Query is not fully supported for inline datasources
|
|
45
|
+
Returns all data or filters by simple conditions
|
|
46
|
+
|
|
47
|
+
###### Parameters
|
|
48
|
+
|
|
49
|
+
| Parameter | Type |
|
|
50
|
+
| ------ | ------ |
|
|
51
|
+
| `_sql` | `string` |
|
|
52
|
+
| `_params?` | `unknown[]` |
|
|
53
|
+
|
|
54
|
+
###### Returns
|
|
55
|
+
|
|
56
|
+
`Promise<QueryResult>`
|
|
57
|
+
|
|
58
|
+
***
|
|
59
|
+
|
|
60
|
+
##### getAll()
|
|
61
|
+
|
|
62
|
+
```ts
|
|
63
|
+
getAll(): Promise<QueryResult>;
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Defined in: [core/inline-datasource.ts:392](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L392)
|
|
67
|
+
|
|
68
|
+
Get all data - returns array for Datasource interface compatibility
|
|
69
|
+
|
|
70
|
+
###### Returns
|
|
71
|
+
|
|
72
|
+
`Promise<QueryResult>`
|
|
73
|
+
|
|
74
|
+
***
|
|
75
|
+
|
|
76
|
+
##### getRawData()
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
getRawData(): unknown;
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Defined in: [core/inline-datasource.ts:403](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L403)
|
|
83
|
+
|
|
84
|
+
Get raw data (object or array)
|
|
85
|
+
|
|
86
|
+
###### Returns
|
|
87
|
+
|
|
88
|
+
`unknown`
|
|
89
|
+
|
|
90
|
+
***
|
|
91
|
+
|
|
92
|
+
##### get()
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
get(dotPath: string): Promise<unknown>;
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Defined in: [core/inline-datasource.ts:410](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L410)
|
|
99
|
+
|
|
100
|
+
Get value at dot-path
|
|
101
|
+
|
|
102
|
+
###### Parameters
|
|
103
|
+
|
|
104
|
+
| Parameter | Type |
|
|
105
|
+
| ------ | ------ |
|
|
106
|
+
| `dotPath` | `string` |
|
|
107
|
+
|
|
108
|
+
###### Returns
|
|
109
|
+
|
|
110
|
+
`Promise<unknown>`
|
|
111
|
+
|
|
112
|
+
***
|
|
113
|
+
|
|
114
|
+
##### isObjectType()
|
|
115
|
+
|
|
116
|
+
```ts
|
|
117
|
+
isObjectType(): boolean;
|
|
19
118
|
```
|
|
20
119
|
|
|
120
|
+
Defined in: [core/inline-datasource.ts:417](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L417)
|
|
121
|
+
|
|
122
|
+
Check if datasource is object type (vs array)
|
|
123
|
+
|
|
124
|
+
###### Returns
|
|
125
|
+
|
|
126
|
+
`boolean`
|
|
127
|
+
|
|
128
|
+
***
|
|
129
|
+
|
|
130
|
+
##### close()
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
close(): Promise<void>;
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Defined in: [core/inline-datasource.ts:424](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L424)
|
|
137
|
+
|
|
138
|
+
Close (no-op for inline)
|
|
139
|
+
|
|
140
|
+
###### Returns
|
|
141
|
+
|
|
142
|
+
`Promise<void>`
|
|
143
|
+
|
|
144
|
+
***
|
|
145
|
+
|
|
146
|
+
##### getMeta()
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
getMeta(propertyPath?: string, targetDocPath?: string): InlineDefinitionLocation | null;
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
Defined in: [core/inline-datasource.ts:445](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L445)
|
|
153
|
+
|
|
154
|
+
Get location metadata for a specific property definition
|
|
155
|
+
|
|
156
|
+
###### Parameters
|
|
157
|
+
|
|
158
|
+
| Parameter | Type | Description |
|
|
159
|
+
| ------ | ------ | ------ |
|
|
160
|
+
| `propertyPath?` | `string` | Property path to look up (default: '' for root) **Default** `''` |
|
|
161
|
+
| `targetDocPath?` | `string` | Base path for relative path calculation |
|
|
162
|
+
|
|
163
|
+
###### Returns
|
|
164
|
+
|
|
165
|
+
`InlineDefinitionLocation | null`
|
|
166
|
+
|
|
167
|
+
Location metadata or null if not found
|
|
168
|
+
|
|
169
|
+
***
|
|
170
|
+
|
|
171
|
+
##### getAllMeta()
|
|
172
|
+
|
|
173
|
+
```ts
|
|
174
|
+
getAllMeta(targetDocPath?: string): InlineDefinitionLocation[];
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
Defined in: [core/inline-datasource.ts:457](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L457)
|
|
178
|
+
|
|
179
|
+
Get all definition locations with relative paths calculated
|
|
180
|
+
|
|
181
|
+
###### Parameters
|
|
182
|
+
|
|
183
|
+
| Parameter | Type | Description |
|
|
184
|
+
| ------ | ------ | ------ |
|
|
185
|
+
| `targetDocPath?` | `string` | Base path for relative path calculation |
|
|
186
|
+
|
|
187
|
+
###### Returns
|
|
188
|
+
|
|
189
|
+
`InlineDefinitionLocation[]`
|
|
190
|
+
|
|
191
|
+
Array of all definition locations (sorted by propertyPath)
|
|
192
|
+
|
|
21
193
|
## Interfaces
|
|
22
194
|
|
|
195
|
+
### InlineDefinitionLocation
|
|
196
|
+
|
|
197
|
+
Defined in: [core/inline-datasource.ts:31](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L31)
|
|
198
|
+
|
|
199
|
+
Location metadata for an inline definition
|
|
200
|
+
|
|
201
|
+
#### Properties
|
|
202
|
+
|
|
203
|
+
| Property | Type | Description | Defined in |
|
|
204
|
+
| ------ | ------ | ------ | ------ |
|
|
205
|
+
| <a id="propertypath"></a> `propertyPath` | `string` | Property path ('' for root definition) | [core/inline-datasource.ts:33](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L33) |
|
|
206
|
+
| <a id="absolutepath"></a> `absolutePath` | `string` | Absolute file path | [core/inline-datasource.ts:35](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L35) |
|
|
207
|
+
| <a id="relativepath"></a> `relativePath` | `string` | Relative path from target document (calculated on access) | [core/inline-datasource.ts:37](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L37) |
|
|
208
|
+
| <a id="startline"></a> `startLine` | `number` | Marker start line (1-indexed) | [core/inline-datasource.ts:39](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L39) |
|
|
209
|
+
| <a id="endline"></a> `endLine` | `number` | Marker end line | [core/inline-datasource.ts:41](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L41) |
|
|
210
|
+
| <a id="contentstartline"></a> `contentStartLine` | `number` | Content start line (excluding marker) | [core/inline-datasource.ts:43](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L43) |
|
|
211
|
+
| <a id="contentendline"></a> `contentEndLine` | `number` | Content end line (excluding marker) | [core/inline-datasource.ts:45](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L45) |
|
|
212
|
+
| <a id="format"></a> `format` | `string` | Data format | [core/inline-datasource.ts:47](https://github.com/foo-ogawa/embedoc/blob/main/src/core/inline-datasource.ts#L47) |
|
|
213
|
+
|
|
214
|
+
***
|
|
215
|
+
|
|
216
|
+
### ApiMarkdownOptions
|
|
217
|
+
|
|
218
|
+
Defined in: [helpers/api-markdown.ts:21](https://github.com/foo-ogawa/embedoc/blob/main/src/helpers/api-markdown.ts#L21)
|
|
219
|
+
|
|
220
|
+
Options for [`renderApiIndex`](#renderapiindex) and [`renderApiPage`](#renderapipage).
|
|
221
|
+
|
|
222
|
+
#### Properties
|
|
223
|
+
|
|
224
|
+
| Property | Type | Description | Defined in |
|
|
225
|
+
| ------ | ------ | ------ | ------ |
|
|
226
|
+
| <a id="ownfilekinds"></a> `ownFileKinds?` | `ApiSymbolKind[]` | Kinds whose symbols get a page of their own at `<kindDir>/<name>.md` (e.g. `['class', 'interface', 'function']`). Symbols of the other kinds are written in full on the index page. Default: none, so everything is on the index. | [helpers/api-markdown.ts:27](https://github.com/foo-ogawa/embedoc/blob/main/src/helpers/api-markdown.ts#L27) |
|
|
227
|
+
| <a id="categoryorder"></a> `categoryOrder?` | `string[]` | Order of category headings. `*` marks where the categories that are not listed go (alphabetically); without `*` they go last. Symbols without a `@category` tag are in the category `Other`. Category headings appear only in kind groups where at least one symbol has a category. | [helpers/api-markdown.ts:34](https://github.com/foo-ogawa/embedoc/blob/main/src/helpers/api-markdown.ts#L34) |
|
|
228
|
+
| <a id="indexfile"></a> `indexFile?` | `string` | File name of the index page, for links from symbol pages (default: `README.md`). | [helpers/api-markdown.ts:36](https://github.com/foo-ogawa/embedoc/blob/main/src/helpers/api-markdown.ts#L36) |
|
|
229
|
+
| <a id="headinglevel"></a> `headingLevel?` | `number` | Heading level of the kind groups on the index page (default: 2). | [helpers/api-markdown.ts:38](https://github.com/foo-ogawa/embedoc/blob/main/src/helpers/api-markdown.ts#L38) |
|
|
230
|
+
|
|
231
|
+
***
|
|
232
|
+
|
|
233
|
+
### DatasourceConfig
|
|
234
|
+
|
|
235
|
+
Defined in: [types/index.ts:54](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L54)
|
|
236
|
+
|
|
237
|
+
Datasource configuration.
|
|
238
|
+
|
|
239
|
+
The `type` field accepts built-in types ('sqlite', 'csv', 'json', 'yaml', 'glob', 'typescript')
|
|
240
|
+
or any custom type name registered via `datasources_dir`.
|
|
241
|
+
Custom types receive the entire config object (including arbitrary properties)
|
|
242
|
+
in their `create()` method.
|
|
243
|
+
|
|
244
|
+
#### Indexable
|
|
245
|
+
|
|
246
|
+
| Index | Type | Description | Defined in |
|
|
247
|
+
| ------ | ------ | ------ | ------ |
|
|
248
|
+
| <a id="key-string"></a> `[key: string]` | `unknown` | | [types/index.ts:61](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L61) |
|
|
249
|
+
|
|
250
|
+
#### Properties
|
|
251
|
+
|
|
252
|
+
| Property | Type | Description | Defined in |
|
|
253
|
+
| ------ | ------ | ------ | ------ |
|
|
254
|
+
| <a id="type"></a> `type` | `string` | | [types/index.ts:55](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L55) |
|
|
255
|
+
| <a id="path"></a> `path?` | `string` | | [types/index.ts:56](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L56) |
|
|
256
|
+
| <a id="pattern"></a> `pattern?` | `string` | | [types/index.ts:57](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L57) |
|
|
257
|
+
| <a id="query"></a> `query?` | `string` | | [types/index.ts:58](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L58) |
|
|
258
|
+
| <a id="encoding"></a> `encoding?` | `string` | | [types/index.ts:59](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L59) |
|
|
259
|
+
| <a id="generators"></a> `generators?` | `GeneratorConfig[]` | | [types/index.ts:60](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L60) |
|
|
260
|
+
|
|
261
|
+
***
|
|
262
|
+
|
|
23
263
|
### Datasource
|
|
24
264
|
|
|
25
|
-
Defined in: types/index.ts:
|
|
265
|
+
Defined in: [types/index.ts:211](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L211)
|
|
26
266
|
|
|
27
267
|
Datasource interface for accessing external data.
|
|
28
268
|
|
|
@@ -39,6 +279,7 @@ Supported datasource types:
|
|
|
39
279
|
- `json` - JSON files (use `getAll()`)
|
|
40
280
|
- `yaml` - YAML files (use `getAll()`)
|
|
41
281
|
- `glob` - File listings (use `getAll()`)
|
|
282
|
+
- `typescript` - Public API of TypeScript entry points (use `getAll()`)
|
|
42
283
|
|
|
43
284
|
#### Example
|
|
44
285
|
|
|
@@ -59,179 +300,474 @@ const allData = await ds.getAll();
|
|
|
59
300
|
|
|
60
301
|
#### Properties
|
|
61
302
|
|
|
62
|
-
| Property |
|
|
63
|
-
| ------ | ------ | ------ | ------ |
|
|
64
|
-
| <a id="type"></a> `type`
|
|
303
|
+
| Property | Type | Description | Defined in |
|
|
304
|
+
| ------ | ------ | ------ | ------ |
|
|
305
|
+
| <a id="type"></a> `type` (readonly) | `string` | Datasource type identifier. One of: 'sqlite', 'csv', 'json', 'yaml', 'glob', 'typescript', 'inline' | [types/index.ts:216](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L216) |
|
|
65
306
|
|
|
66
307
|
#### Methods
|
|
67
308
|
|
|
309
|
+
##### query()
|
|
310
|
+
|
|
311
|
+
```ts
|
|
312
|
+
query(sql: string, params?: unknown[]): Promise<QueryResult>;
|
|
313
|
+
```
|
|
314
|
+
|
|
315
|
+
Defined in: [types/index.ts:248](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L248)
|
|
316
|
+
|
|
317
|
+
Execute a parameterized query on the datasource.
|
|
318
|
+
|
|
319
|
+
**SQLite**: Execute SQL with parameters from marker attributes or frontmatter.
|
|
320
|
+
This allows dynamic filtering based on the document context.
|
|
321
|
+
|
|
322
|
+
**CSV/JSON/YAML/Glob/TypeScript**: Only `WHERE column = ?` is understood
|
|
323
|
+
(the value is `params[0]`, compared as a string); any other query returns
|
|
324
|
+
every record. Use `getAll()` for everything.
|
|
325
|
+
|
|
326
|
+
###### Example
|
|
327
|
+
|
|
328
|
+
```typescript
|
|
329
|
+
// Dynamic query using marker parameter
|
|
330
|
+
const { id } = ctx.params; // From: <!--@embedoc:table_columns id="users"-->
|
|
331
|
+
const columns = await ds.query(
|
|
332
|
+
'SELECT * FROM columns WHERE table_name = ? ORDER BY ordinal_position',
|
|
333
|
+
[id]
|
|
334
|
+
);
|
|
335
|
+
|
|
336
|
+
// Multiple parameters
|
|
337
|
+
const filtered = await ds.query(
|
|
338
|
+
'SELECT * FROM users WHERE status = ? AND role = ?',
|
|
339
|
+
[ctx.params['status'], ctx.params['role']]
|
|
340
|
+
);
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
###### Parameters
|
|
344
|
+
|
|
345
|
+
| Parameter | Type | Description |
|
|
346
|
+
| ------ | ------ | ------ |
|
|
347
|
+
| `sql` | `string` | SQL query string with `?` placeholders for parameters |
|
|
348
|
+
| `params?` | `unknown[]` | Values to bind to the placeholders (prevents SQL injection) |
|
|
349
|
+
|
|
350
|
+
###### Returns
|
|
351
|
+
|
|
352
|
+
`Promise<QueryResult>`
|
|
353
|
+
|
|
354
|
+
Promise resolving to an array of records
|
|
355
|
+
|
|
356
|
+
***
|
|
357
|
+
|
|
68
358
|
##### getAll()
|
|
69
359
|
|
|
70
360
|
```ts
|
|
71
361
|
getAll(): Promise<QueryResult>;
|
|
72
362
|
```
|
|
73
363
|
|
|
74
|
-
Defined in: types/index.ts:
|
|
75
|
-
|
|
76
|
-
Get all data from the datasource.
|
|
364
|
+
Defined in: [types/index.ts:267](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L267)
|
|
365
|
+
|
|
366
|
+
Get all data from the datasource.
|
|
367
|
+
|
|
368
|
+
Returns all records without filtering. Recommended for
|
|
369
|
+
CSV, JSON, YAML, and Glob datasources.
|
|
370
|
+
|
|
371
|
+
###### Example
|
|
372
|
+
|
|
373
|
+
```typescript
|
|
374
|
+
// CSV datasource
|
|
375
|
+
const endpoints = await ctx.datasources['api_endpoints'].getAll();
|
|
376
|
+
|
|
377
|
+
// JSON datasource
|
|
378
|
+
const config = await ctx.datasources['config'].getAll();
|
|
379
|
+
```
|
|
380
|
+
|
|
381
|
+
###### Returns
|
|
382
|
+
|
|
383
|
+
`Promise<QueryResult>`
|
|
384
|
+
|
|
385
|
+
Promise resolving to an array of all records
|
|
386
|
+
|
|
387
|
+
***
|
|
388
|
+
|
|
389
|
+
### CustomDatasourceDefinition
|
|
390
|
+
|
|
391
|
+
Defined in: [types/index.ts:293](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L293)
|
|
392
|
+
|
|
393
|
+
Definition for a custom datasource type.
|
|
394
|
+
|
|
395
|
+
Register custom datasource types by exporting a `datasourceTypes` object
|
|
396
|
+
from `.embedoc/datasources/index.ts`. Each value should be created with
|
|
397
|
+
[`defineDatasource`](#definedatasource).
|
|
398
|
+
|
|
399
|
+
The `create()` method receives the full datasource config from
|
|
400
|
+
`embedoc.config.yaml` (including any arbitrary properties) and must
|
|
401
|
+
return a [`Datasource`](#datasource) instance.
|
|
402
|
+
|
|
403
|
+
#### Methods
|
|
404
|
+
|
|
405
|
+
##### create()
|
|
406
|
+
|
|
407
|
+
```ts
|
|
408
|
+
create(config: DatasourceConfig): Promise<Datasource>;
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
Defined in: [types/index.ts:294](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L294)
|
|
412
|
+
|
|
413
|
+
###### Parameters
|
|
414
|
+
|
|
415
|
+
| Parameter | Type |
|
|
416
|
+
| ------ | ------ |
|
|
417
|
+
| `config` | `DatasourceConfig` |
|
|
418
|
+
|
|
419
|
+
###### Returns
|
|
420
|
+
|
|
421
|
+
`Promise<Datasource>`
|
|
422
|
+
|
|
423
|
+
***
|
|
424
|
+
|
|
425
|
+
### TypeScriptDatasourceConfig
|
|
426
|
+
|
|
427
|
+
Defined in: [types/index.ts:323](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L323)
|
|
428
|
+
|
|
429
|
+
Configuration of the built-in `typescript` datasource.
|
|
430
|
+
|
|
431
|
+
The datasource reads the public API of TypeScript entry points with the
|
|
432
|
+
TypeScript compiler API and returns one [`ApiSymbol`](#apisymbol) record per exported
|
|
433
|
+
symbol. It needs the `typescript` package (>=5.0.0 <7.0.0) installed in the
|
|
434
|
+
project; it is an optional peer dependency of embedoc.
|
|
435
|
+
|
|
436
|
+
Paths are resolved against the current working directory, like the other
|
|
437
|
+
datasources.
|
|
438
|
+
|
|
439
|
+
#### Extends
|
|
440
|
+
|
|
441
|
+
- `DatasourceConfig`
|
|
442
|
+
|
|
443
|
+
#### Properties
|
|
444
|
+
|
|
445
|
+
| Property | Type | Description | Defined in |
|
|
446
|
+
| ------ | ------ | ------ | ------ |
|
|
447
|
+
| <a id="type"></a> `type` | `'typescript'` | | [types/index.ts:324](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L324) |
|
|
448
|
+
| <a id="entry_points"></a> `entry_points` | `string[]` | Entry point files whose exports form the public API. | [types/index.ts:326](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L326) |
|
|
449
|
+
| <a id="tsconfig"></a> `tsconfig?` | `string` | tsconfig.json to compile with (default: the nearest one above the first entry point). | [types/index.ts:328](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L328) |
|
|
450
|
+
| <a id="exclude_internal"></a> `exclude_internal?` | `boolean` | Leave out symbols and members tagged `@internal` (default: true). | [types/index.ts:330](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L330) |
|
|
451
|
+
| <a id="exclude_private"></a> `exclude_private?` | `boolean` | Leave out `private` and `#private` class members (default: true). | [types/index.ts:332](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L332) |
|
|
452
|
+
| <a id="exclude_externals"></a> `exclude_externals?` | `boolean` | Leave out symbols declared in external libraries such as node_modules (default: true). | [types/index.ts:334](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L334) |
|
|
453
|
+
| <a id="source_link_template"></a> `source_link_template?` | `string` | Source link URL with the placeholders `{path}` (relative to the working directory), `{line}` and `{gitRevision}`. No link is produced without it. | [types/index.ts:339](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L339) |
|
|
454
|
+
| <a id="git_revision"></a> `git_revision?` | `string` | Value of `{gitRevision}`. Required when the template uses `{gitRevision}`. | [types/index.ts:341](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L341) |
|
|
455
|
+
| <a id="sort"></a> `sort?` | `'source-order' | 'alphabetical'` | Record order: `source-order` (file path, then position) or `alphabetical` (default: source-order). | [types/index.ts:343](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L343) |
|
|
456
|
+
|
|
457
|
+
***
|
|
458
|
+
|
|
459
|
+
### MarkdownHelper
|
|
460
|
+
|
|
461
|
+
Defined in: [types/index.ts:516](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L516)
|
|
462
|
+
|
|
463
|
+
Helper interface for generating Markdown content.
|
|
464
|
+
|
|
465
|
+
Always available via `ctx.markdown` in embed render functions.
|
|
466
|
+
Provides methods for creating common Markdown elements:
|
|
467
|
+
|
|
468
|
+
#### Example
|
|
469
|
+
|
|
470
|
+
```typescript
|
|
471
|
+
export default defineEmbed({
|
|
472
|
+
async render(ctx) {
|
|
473
|
+
const { markdown } = ctx;
|
|
474
|
+
|
|
475
|
+
// Create a table
|
|
476
|
+
const table = markdown.table(
|
|
477
|
+
['Name', 'Age'],
|
|
478
|
+
[['Alice', 25], ['Bob', 30]]
|
|
479
|
+
);
|
|
480
|
+
|
|
481
|
+
// Create a list
|
|
482
|
+
const list = markdown.list(['Item 1', 'Item 2'], false);
|
|
483
|
+
|
|
484
|
+
return { content: table + '\n\n' + list };
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
#### Methods
|
|
490
|
+
|
|
491
|
+
##### table()
|
|
492
|
+
|
|
493
|
+
```ts
|
|
494
|
+
table(headers: string[], rows: (string | number | boolean | null | undefined)[][]): string;
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
Defined in: [types/index.ts:540](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L540)
|
|
498
|
+
|
|
499
|
+
Generate a Markdown table.
|
|
500
|
+
|
|
501
|
+
###### Example
|
|
502
|
+
|
|
503
|
+
```typescript
|
|
504
|
+
ctx.markdown.table(
|
|
505
|
+
['Column', 'Type', 'Description'],
|
|
506
|
+
[
|
|
507
|
+
['id', 'integer', 'Primary key'],
|
|
508
|
+
['name', 'varchar', 'User name'],
|
|
509
|
+
]
|
|
510
|
+
);
|
|
511
|
+
// Output:
|
|
512
|
+
// | Column | Type | Description |
|
|
513
|
+
// | --- | --- | --- |
|
|
514
|
+
// | id | integer | Primary key |
|
|
515
|
+
// | name | varchar | User name |
|
|
516
|
+
```
|
|
517
|
+
|
|
518
|
+
###### Parameters
|
|
519
|
+
|
|
520
|
+
| Parameter | Type | Description |
|
|
521
|
+
| ------ | ------ | ------ |
|
|
522
|
+
| `headers` | `string[]` | Array of column header strings |
|
|
523
|
+
| `rows` | `(string | number | boolean | null | undefined)[][]` | 2D array of cell values (each inner array is a row) |
|
|
524
|
+
|
|
525
|
+
###### Returns
|
|
526
|
+
|
|
527
|
+
`string`
|
|
528
|
+
|
|
529
|
+
Formatted Markdown table string
|
|
530
|
+
|
|
531
|
+
***
|
|
532
|
+
|
|
533
|
+
##### list()
|
|
534
|
+
|
|
535
|
+
```ts
|
|
536
|
+
list(items: string[], ordered?: boolean): string;
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
Defined in: [types/index.ts:566](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L566)
|
|
540
|
+
|
|
541
|
+
Generate a Markdown list.
|
|
542
|
+
|
|
543
|
+
###### Example
|
|
544
|
+
|
|
545
|
+
```typescript
|
|
546
|
+
// Unordered list
|
|
547
|
+
ctx.markdown.list(['Apple', 'Banana', 'Cherry'], false);
|
|
548
|
+
// Output:
|
|
549
|
+
// - Apple
|
|
550
|
+
// - Banana
|
|
551
|
+
// - Cherry
|
|
552
|
+
|
|
553
|
+
// Ordered list
|
|
554
|
+
ctx.markdown.list(['First', 'Second', 'Third'], true);
|
|
555
|
+
// Output:
|
|
556
|
+
// 1. First
|
|
557
|
+
// 2. Second
|
|
558
|
+
// 3. Third
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
###### Parameters
|
|
562
|
+
|
|
563
|
+
| Parameter | Type | Description |
|
|
564
|
+
| ------ | ------ | ------ |
|
|
565
|
+
| `items` | `string[]` | Array of list item strings |
|
|
566
|
+
| `ordered?` | `boolean` | If true, creates numbered list; if false, creates bullet list |
|
|
567
|
+
|
|
568
|
+
###### Returns
|
|
569
|
+
|
|
570
|
+
`string`
|
|
571
|
+
|
|
572
|
+
Formatted Markdown list string
|
|
573
|
+
|
|
574
|
+
***
|
|
575
|
+
|
|
576
|
+
##### codeBlock()
|
|
577
|
+
|
|
578
|
+
```ts
|
|
579
|
+
codeBlock(code: string, language?: string): string;
|
|
580
|
+
```
|
|
581
|
+
|
|
582
|
+
Defined in: [types/index.ts:584](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L584)
|
|
583
|
+
|
|
584
|
+
Generate a fenced code block.
|
|
585
|
+
|
|
586
|
+
###### Example
|
|
587
|
+
|
|
588
|
+
```typescript
|
|
589
|
+
ctx.markdown.codeBlock('const x = 1;', 'typescript');
|
|
590
|
+
// Output:
|
|
591
|
+
// ```typescript
|
|
592
|
+
// const x = 1;
|
|
593
|
+
// ```
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
###### Parameters
|
|
597
|
+
|
|
598
|
+
| Parameter | Type | Description |
|
|
599
|
+
| ------ | ------ | ------ |
|
|
600
|
+
| `code` | `string` | The code content |
|
|
601
|
+
| `language?` | `string` | Optional language identifier for syntax highlighting |
|
|
602
|
+
|
|
603
|
+
###### Returns
|
|
604
|
+
|
|
605
|
+
`string`
|
|
606
|
+
|
|
607
|
+
Formatted Markdown code block string
|
|
608
|
+
|
|
609
|
+
***
|
|
610
|
+
|
|
611
|
+
##### link()
|
|
612
|
+
|
|
613
|
+
```ts
|
|
614
|
+
link(text: string, url: string): string;
|
|
615
|
+
```
|
|
616
|
+
|
|
617
|
+
Defined in: [types/index.ts:599](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L599)
|
|
618
|
+
|
|
619
|
+
Generate a Markdown link.
|
|
620
|
+
|
|
621
|
+
###### Example
|
|
622
|
+
|
|
623
|
+
```typescript
|
|
624
|
+
ctx.markdown.link('Visit Google', 'https://google.com');
|
|
625
|
+
// Output: [Visit Google](https://google.com)
|
|
626
|
+
```
|
|
627
|
+
|
|
628
|
+
###### Parameters
|
|
629
|
+
|
|
630
|
+
| Parameter | Type | Description |
|
|
631
|
+
| ------ | ------ | ------ |
|
|
632
|
+
| `text` | `string` | Link display text |
|
|
633
|
+
| `url` | `string` | Link URL |
|
|
634
|
+
|
|
635
|
+
###### Returns
|
|
636
|
+
|
|
637
|
+
`string`
|
|
638
|
+
|
|
639
|
+
Formatted Markdown link string
|
|
640
|
+
|
|
641
|
+
***
|
|
642
|
+
|
|
643
|
+
##### heading()
|
|
644
|
+
|
|
645
|
+
```ts
|
|
646
|
+
heading(text: string, level?: number): string;
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
Defined in: [types/index.ts:614](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L614)
|
|
650
|
+
|
|
651
|
+
Generate a Markdown heading.
|
|
652
|
+
|
|
653
|
+
###### Example
|
|
654
|
+
|
|
655
|
+
```typescript
|
|
656
|
+
ctx.markdown.heading('Section Title', 2);
|
|
657
|
+
// Output: ## Section Title
|
|
658
|
+
```
|
|
659
|
+
|
|
660
|
+
###### Parameters
|
|
77
661
|
|
|
78
|
-
|
|
79
|
-
|
|
662
|
+
| Parameter | Type | Description |
|
|
663
|
+
| ------ | ------ | ------ |
|
|
664
|
+
| `text` | `string` | Heading text |
|
|
665
|
+
| `level?` | `number` | Heading level (1-6), defaults to 1 |
|
|
80
666
|
|
|
81
667
|
###### Returns
|
|
82
668
|
|
|
83
|
-
`
|
|
84
|
-
|
|
85
|
-
Promise resolving to an array of all records
|
|
86
|
-
|
|
87
|
-
###### Example
|
|
669
|
+
`string`
|
|
88
670
|
|
|
89
|
-
|
|
90
|
-
// CSV datasource
|
|
91
|
-
const endpoints = await ctx.datasources['api_endpoints'].getAll();
|
|
671
|
+
Formatted Markdown heading string
|
|
92
672
|
|
|
93
|
-
|
|
94
|
-
const config = await ctx.datasources['config'].getAll();
|
|
95
|
-
```
|
|
673
|
+
***
|
|
96
674
|
|
|
97
|
-
#####
|
|
675
|
+
##### bold()
|
|
98
676
|
|
|
99
677
|
```ts
|
|
100
|
-
|
|
678
|
+
bold(text: string): string;
|
|
101
679
|
```
|
|
102
680
|
|
|
103
|
-
Defined in: types/index.ts:
|
|
681
|
+
Defined in: [types/index.ts:628](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L628)
|
|
104
682
|
|
|
105
|
-
|
|
683
|
+
Wrap text in bold formatting.
|
|
106
684
|
|
|
107
|
-
|
|
108
|
-
This allows dynamic filtering based on the document context.
|
|
685
|
+
###### Example
|
|
109
686
|
|
|
110
|
-
|
|
687
|
+
```typescript
|
|
688
|
+
ctx.markdown.bold('Important');
|
|
689
|
+
// Output: **Important**
|
|
690
|
+
```
|
|
111
691
|
|
|
112
692
|
###### Parameters
|
|
113
693
|
|
|
114
694
|
| Parameter | Type | Description |
|
|
115
695
|
| ------ | ------ | ------ |
|
|
116
|
-
| `
|
|
117
|
-
| `params?` | `unknown`[] | Values to bind to the placeholders (prevents SQL injection) |
|
|
696
|
+
| `text` | `string` | Text to make bold |
|
|
118
697
|
|
|
119
698
|
###### Returns
|
|
120
699
|
|
|
121
|
-
`
|
|
700
|
+
`string`
|
|
122
701
|
|
|
123
|
-
|
|
702
|
+
Bold formatted string
|
|
124
703
|
|
|
125
|
-
|
|
704
|
+
***
|
|
126
705
|
|
|
127
|
-
|
|
128
|
-
// Dynamic query using marker parameter
|
|
129
|
-
const { id } = ctx.params; // From: <!--@embedoc:table_columns id="users"-->
|
|
130
|
-
const columns = await ds.query(
|
|
131
|
-
'SELECT * FROM columns WHERE table_name = ? ORDER BY ordinal_position',
|
|
132
|
-
[id]
|
|
133
|
-
);
|
|
706
|
+
##### italic()
|
|
134
707
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
'SELECT * FROM users WHERE status = ? AND role = ?',
|
|
138
|
-
[ctx.params['status'], ctx.params['role']]
|
|
139
|
-
);
|
|
708
|
+
```ts
|
|
709
|
+
italic(text: string): string;
|
|
140
710
|
```
|
|
141
711
|
|
|
142
|
-
|
|
712
|
+
Defined in: [types/index.ts:642](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L642)
|
|
143
713
|
|
|
144
|
-
|
|
714
|
+
Wrap text in italic formatting.
|
|
145
715
|
|
|
146
|
-
|
|
716
|
+
###### Example
|
|
147
717
|
|
|
148
|
-
|
|
149
|
-
|
|
718
|
+
```typescript
|
|
719
|
+
ctx.markdown.italic('Emphasis');
|
|
720
|
+
// Output: *Emphasis*
|
|
721
|
+
```
|
|
150
722
|
|
|
151
|
-
|
|
723
|
+
###### Parameters
|
|
152
724
|
|
|
153
|
-
|
|
|
725
|
+
| Parameter | Type | Description |
|
|
154
726
|
| ------ | ------ | ------ |
|
|
155
|
-
| `
|
|
156
|
-
| `format` | `string` | Data format: `'yaml'`, `'json'`, `'csv'`, `'table'`, or `'text'` |
|
|
157
|
-
| `locations` | `InlineDefinitionLocation[]` | All definition locations (sorted by property path) |
|
|
158
|
-
|
|
159
|
-
#### Methods
|
|
160
|
-
|
|
161
|
-
##### getMeta()
|
|
727
|
+
| `text` | `string` | Text to make italic |
|
|
162
728
|
|
|
163
|
-
|
|
164
|
-
getMeta(propertyPath?: string, targetDocPath?: string): InlineDefinitionLocation | null;
|
|
165
|
-
```
|
|
729
|
+
###### Returns
|
|
166
730
|
|
|
167
|
-
|
|
731
|
+
`string`
|
|
168
732
|
|
|
169
|
-
|
|
170
|
-
| ------ | ------ | ------ |
|
|
171
|
-
| `propertyPath` | `string` | Property path to look up (default: `''` for root) |
|
|
172
|
-
| `targetDocPath` | `string` | Base path for relative path calculation |
|
|
733
|
+
Italic formatted string
|
|
173
734
|
|
|
174
|
-
|
|
735
|
+
***
|
|
175
736
|
|
|
176
|
-
#####
|
|
737
|
+
##### checkbox()
|
|
177
738
|
|
|
178
739
|
```ts
|
|
179
|
-
|
|
740
|
+
checkbox(checked: boolean): string;
|
|
180
741
|
```
|
|
181
742
|
|
|
182
|
-
|
|
743
|
+
Defined in: [types/index.ts:656](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L656)
|
|
183
744
|
|
|
184
|
-
|
|
745
|
+
Generate a checkbox character.
|
|
185
746
|
|
|
186
|
-
|
|
187
|
-
get(path: string): Promise<unknown>;
|
|
188
|
-
```
|
|
747
|
+
###### Example
|
|
189
748
|
|
|
190
|
-
|
|
749
|
+
```typescript
|
|
750
|
+
ctx.markdown.checkbox(true); // Output: ✔
|
|
751
|
+
ctx.markdown.checkbox(false); // Output: (empty string)
|
|
752
|
+
```
|
|
191
753
|
|
|
192
|
-
|
|
754
|
+
###### Parameters
|
|
193
755
|
|
|
194
|
-
|
|
|
756
|
+
| Parameter | Type | Description |
|
|
195
757
|
| ------ | ------ | ------ |
|
|
196
|
-
| `
|
|
197
|
-
| `absolutePath` | `string` | Absolute file path |
|
|
198
|
-
| `relativePath` | `string` | Relative path from target document |
|
|
199
|
-
| `startLine` | `number` | Marker start line (1-indexed) |
|
|
200
|
-
| `endLine` | `number` | Marker end line |
|
|
201
|
-
| `contentStartLine` | `number` | Content start line (excluding marker) |
|
|
202
|
-
| `contentEndLine` | `number` | Content end line (excluding marker) |
|
|
203
|
-
| `format` | `string` | Data format |
|
|
758
|
+
| `checked` | `boolean` | Whether the checkbox is checked |
|
|
204
759
|
|
|
205
|
-
|
|
760
|
+
###### Returns
|
|
206
761
|
|
|
207
|
-
|
|
208
|
-
import { defineEmbed, InlineDatasource } from 'embedoc';
|
|
762
|
+
`string`
|
|
209
763
|
|
|
210
|
-
|
|
211
|
-
async render(ctx) {
|
|
212
|
-
const ds = ctx.datasources['project'] as InlineDatasource;
|
|
213
|
-
|
|
214
|
-
// Root definition location
|
|
215
|
-
const root = ds.getMeta('', ctx.filePath);
|
|
216
|
-
|
|
217
|
-
// Specific property location (for distributed definitions)
|
|
218
|
-
const author = ds.getMeta('author.name', ctx.filePath);
|
|
219
|
-
|
|
220
|
-
if (root) {
|
|
221
|
-
return {
|
|
222
|
-
content: `Defined in ${root.relativePath}:${root.contentStartLine}`
|
|
223
|
-
};
|
|
224
|
-
}
|
|
225
|
-
return { content: 'No root definition' };
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
```
|
|
764
|
+
Checkbox character ('✔' if checked, '' if not)
|
|
229
765
|
|
|
230
766
|
***
|
|
231
767
|
|
|
232
768
|
### EmbedContext
|
|
233
769
|
|
|
234
|
-
Defined in: types/index.ts:
|
|
770
|
+
Defined in: [types/index.ts:692](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L692)
|
|
235
771
|
|
|
236
772
|
Context object passed to an embed's render function.
|
|
237
773
|
|
|
@@ -270,21 +806,46 @@ export default defineEmbed({
|
|
|
270
806
|
|
|
271
807
|
| Property | Type | Description | Defined in |
|
|
272
808
|
| ------ | ------ | ------ | ------ |
|
|
273
|
-
| <a id="
|
|
274
|
-
| <a id="
|
|
275
|
-
| <a id="
|
|
276
|
-
| <a id="markdown"></a> `markdown` |
|
|
277
|
-
| <a id="
|
|
809
|
+
| <a id="params"></a> `params` | `Record<string, string>` | Parameters from the marker attributes.<br><br>Parsed from the marker syntax: `<!--@embedoc:embed_name param1="value1" param2="value2"-->`<br><br>Variable references (`${...}`) are resolved before passing to the embed. | [types/index.ts:708](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L708) |
|
|
810
|
+
| <a id="frontmatter"></a> `frontmatter` | `Record<string, unknown>` | Frontmatter data from the document.<br><br>Parsed from YAML frontmatter at the top of the document. | [types/index.ts:726](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L726) |
|
|
811
|
+
| <a id="datasources"></a> `datasources` | `Record<string, Datasource>` | Map of configured datasources.<br><br>Keys are datasource names from `embedoc.config.yaml`. Includes both external datasources and inline datasources defined in the document. | [types/index.ts:746](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L746) |
|
|
812
|
+
| <a id="markdown"></a> `markdown` | `MarkdownHelper` | Markdown generation helper.<br><br>Always available. Provides methods for creating tables, lists, code blocks, links, and other Markdown elements. | [types/index.ts:756](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L756) |
|
|
813
|
+
| <a id="filepath"></a> `filePath` | `string` | Absolute path to the current file being processed.<br><br>Useful for generating relative links or file references. | [types/index.ts:769](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L769) |
|
|
814
|
+
| <a id="existingcontent"></a> `existingContent?` | `string` | Existing content between the markers (before replacement).<br><br>Useful for error recovery - return `existingContent` when data sources are unavailable to preserve the previous state. | [types/index.ts:788](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L788) |
|
|
815
|
+
|
|
816
|
+
***
|
|
817
|
+
|
|
818
|
+
### EmbedResult
|
|
819
|
+
|
|
820
|
+
Defined in: [types/index.ts:803](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L803)
|
|
821
|
+
|
|
822
|
+
Result object returned from an embed's render function.
|
|
823
|
+
|
|
824
|
+
#### Example
|
|
825
|
+
|
|
826
|
+
```typescript
|
|
827
|
+
export default defineEmbed({
|
|
828
|
+
async render(ctx): Promise<EmbedResult> {
|
|
829
|
+
return { content: '# Generated Content\n\nHello, World!' };
|
|
830
|
+
}
|
|
831
|
+
});
|
|
832
|
+
```
|
|
833
|
+
|
|
834
|
+
#### Properties
|
|
835
|
+
|
|
836
|
+
| Property | Type | Description | Defined in |
|
|
837
|
+
| ------ | ------ | ------ | ------ |
|
|
838
|
+
| <a id="content"></a> `content` | `string | null | undefined` | Generated content to insert between the markers.<br><br>This string replaces the existing content between the start and end markers in the document.<br><br>Return `null` or `undefined` to keep the existing content (useful for error recovery when data sources are unavailable). | [types/index.ts:813](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L813) |
|
|
278
839
|
|
|
279
840
|
***
|
|
280
841
|
|
|
281
842
|
### EmbedDefinition
|
|
282
843
|
|
|
283
|
-
Defined in: types/index.ts:
|
|
844
|
+
Defined in: [types/index.ts:845](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L845)
|
|
284
845
|
|
|
285
846
|
Embed definition interface.
|
|
286
847
|
|
|
287
|
-
Use with [defineEmbed](#defineembed) to create custom embeds.
|
|
848
|
+
Use with [`defineEmbed`](#defineembed) to create custom embeds.
|
|
288
849
|
Embeds are TypeScript modules that generate content
|
|
289
850
|
for markers in your documents.
|
|
290
851
|
|
|
@@ -315,7 +876,7 @@ export default defineEmbed({
|
|
|
315
876
|
|
|
316
877
|
| Property | Type | Description | Defined in |
|
|
317
878
|
| ------ | ------ | ------ | ------ |
|
|
318
|
-
| <a id="dependson"></a> `dependsOn?` | `string
|
|
879
|
+
| <a id="dependson"></a> `dependsOn?` | `string[]` | List of datasource names this embed depends on.<br><br>Used for dependency tracking in incremental builds. When a datasource changes, all documents using embeds that depend on it will be rebuilt. | [types/index.ts:858](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L858) |
|
|
319
880
|
|
|
320
881
|
#### Methods
|
|
321
882
|
|
|
@@ -325,7 +886,7 @@ export default defineEmbed({
|
|
|
325
886
|
render(ctx: EmbedContext): Promise<EmbedResult>;
|
|
326
887
|
```
|
|
327
888
|
|
|
328
|
-
Defined in: types/index.ts:
|
|
889
|
+
Defined in: [types/index.ts:869](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L869)
|
|
329
890
|
|
|
330
891
|
Render function that generates the embed content.
|
|
331
892
|
|
|
@@ -336,357 +897,376 @@ Receives the context object with parameters, datasources, and helpers.
|
|
|
336
897
|
|
|
337
898
|
| Parameter | Type | Description |
|
|
338
899
|
| ------ | ------ | ------ |
|
|
339
|
-
| `ctx` |
|
|
900
|
+
| `ctx` | `EmbedContext` | The embed context |
|
|
340
901
|
|
|
341
902
|
###### Returns
|
|
342
903
|
|
|
343
|
-
`Promise
|
|
904
|
+
`Promise<EmbedResult>`
|
|
344
905
|
|
|
345
906
|
Promise resolving to the embed result with generated content
|
|
346
907
|
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
### EmbedResult
|
|
350
|
-
|
|
351
|
-
Defined in: types/index.ts:551
|
|
352
|
-
|
|
353
|
-
Result object returned from an embed's render function.
|
|
354
|
-
|
|
355
|
-
#### Example
|
|
356
|
-
|
|
357
|
-
```typescript
|
|
358
|
-
export default defineEmbed({
|
|
359
|
-
async render(ctx): Promise<EmbedResult> {
|
|
360
|
-
return { content: '# Generated Content\n\nHello, World!' };
|
|
361
|
-
}
|
|
362
|
-
});
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
#### Properties
|
|
366
|
-
|
|
367
|
-
| Property | Type | Description | Defined in |
|
|
368
|
-
| ------ | ------ | ------ | ------ |
|
|
369
|
-
| <a id="content"></a> `content` | `string` | Generated content to insert between the markers. This string replaces the existing content between the start and end markers in the document. | types/index.ts:558 |
|
|
370
|
-
|
|
371
|
-
***
|
|
372
|
-
|
|
373
|
-
### MarkdownHelper
|
|
374
|
-
|
|
375
|
-
Defined in: types/index.ts:283
|
|
376
|
-
|
|
377
|
-
Helper interface for generating Markdown content.
|
|
378
|
-
|
|
379
|
-
Always available via `ctx.markdown` in embed render functions.
|
|
380
|
-
Provides methods for creating common Markdown elements:
|
|
381
|
-
|
|
382
|
-
#### Example
|
|
383
|
-
|
|
384
|
-
```typescript
|
|
385
|
-
export default defineEmbed({
|
|
386
|
-
async render(ctx) {
|
|
387
|
-
const { markdown } = ctx;
|
|
388
|
-
|
|
389
|
-
// Create a table
|
|
390
|
-
const table = markdown.table(
|
|
391
|
-
['Name', 'Age'],
|
|
392
|
-
[['Alice', 25], ['Bob', 30]]
|
|
393
|
-
);
|
|
394
|
-
|
|
395
|
-
// Create a list
|
|
396
|
-
const list = markdown.list(['Item 1', 'Item 2'], false);
|
|
397
|
-
|
|
398
|
-
return { content: table + '\n\n' + list };
|
|
399
|
-
}
|
|
400
|
-
});
|
|
401
|
-
```
|
|
402
|
-
|
|
403
|
-
#### Methods
|
|
404
|
-
|
|
405
|
-
##### bold()
|
|
406
|
-
|
|
407
|
-
```ts
|
|
408
|
-
bold(text: string): string;
|
|
409
|
-
```
|
|
410
|
-
|
|
411
|
-
Defined in: types/index.ts:395
|
|
412
|
-
|
|
413
|
-
Wrap text in bold formatting.
|
|
414
|
-
|
|
415
|
-
###### Parameters
|
|
416
|
-
|
|
417
|
-
| Parameter | Type | Description |
|
|
418
|
-
| ------ | ------ | ------ |
|
|
419
|
-
| `text` | `string` | Text to make bold |
|
|
420
|
-
|
|
421
|
-
###### Returns
|
|
422
|
-
|
|
423
|
-
`string`
|
|
424
|
-
|
|
425
|
-
Bold formatted string
|
|
426
|
-
|
|
427
|
-
###### Example
|
|
428
|
-
|
|
429
|
-
```typescript
|
|
430
|
-
ctx.markdown.bold('Important');
|
|
431
|
-
// Output: **Important**
|
|
432
|
-
```
|
|
433
|
-
|
|
434
|
-
##### checkbox()
|
|
435
|
-
|
|
436
|
-
```ts
|
|
437
|
-
checkbox(checked: boolean): string;
|
|
438
|
-
```
|
|
439
|
-
|
|
440
|
-
Defined in: types/index.ts:423
|
|
441
|
-
|
|
442
|
-
Generate a checkbox character.
|
|
443
|
-
|
|
444
|
-
###### Parameters
|
|
445
|
-
|
|
446
|
-
| Parameter | Type | Description |
|
|
447
|
-
| ------ | ------ | ------ |
|
|
448
|
-
| `checked` | `boolean` | Whether the checkbox is checked |
|
|
449
|
-
|
|
450
|
-
###### Returns
|
|
451
|
-
|
|
452
|
-
`string`
|
|
453
|
-
|
|
454
|
-
Checkbox character ('✔' if checked, '' if not)
|
|
455
|
-
|
|
456
|
-
###### Example
|
|
457
|
-
|
|
458
|
-
```typescript
|
|
459
|
-
ctx.markdown.checkbox(true); // Output: ✔
|
|
460
|
-
ctx.markdown.checkbox(false); // Output: (empty string)
|
|
461
|
-
```
|
|
462
|
-
|
|
463
|
-
##### codeBlock()
|
|
464
|
-
|
|
465
|
-
```ts
|
|
466
|
-
codeBlock(code: string, language?: string): string;
|
|
467
|
-
```
|
|
468
|
-
|
|
469
|
-
Defined in: types/index.ts:351
|
|
470
|
-
|
|
471
|
-
Generate a fenced code block.
|
|
908
|
+
## Type Aliases
|
|
472
909
|
|
|
473
|
-
|
|
910
|
+
### QueryResult
|
|
474
911
|
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
| `language?` | `string` | Optional language identifier for syntax highlighting |
|
|
912
|
+
```ts
|
|
913
|
+
type QueryResult = Record<string, unknown>[];
|
|
914
|
+
```
|
|
479
915
|
|
|
480
|
-
|
|
916
|
+
Defined in: [types/index.ts:175](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L175)
|
|
481
917
|
|
|
482
|
-
|
|
918
|
+
Query result returned from datasource operations.
|
|
483
919
|
|
|
484
|
-
|
|
920
|
+
An array of records, where each record is an object with string keys
|
|
921
|
+
and unknown values. Use type assertions when accessing specific fields.
|
|
485
922
|
|
|
486
|
-
|
|
923
|
+
#### Example
|
|
487
924
|
|
|
488
925
|
```typescript
|
|
489
|
-
ctx.
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
926
|
+
const users = await ctx.datasources.db.query('SELECT * FROM users');
|
|
927
|
+
users.forEach(user => {
|
|
928
|
+
console.log(user['name'] as string);
|
|
929
|
+
console.log(user['age'] as number);
|
|
930
|
+
});
|
|
494
931
|
```
|
|
495
932
|
|
|
496
|
-
|
|
933
|
+
***
|
|
934
|
+
|
|
935
|
+
### InlineFormatParser
|
|
497
936
|
|
|
498
937
|
```ts
|
|
499
|
-
|
|
938
|
+
type InlineFormatParser = (content: string) => unknown;
|
|
500
939
|
```
|
|
501
940
|
|
|
502
|
-
Defined in: types/index.ts:
|
|
941
|
+
Defined in: [types/index.ts:306](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L306)
|
|
503
942
|
|
|
504
|
-
|
|
943
|
+
Parser function for a custom inline datasource format.
|
|
505
944
|
|
|
506
|
-
|
|
945
|
+
Receives the raw text content from an `@embedoc-data` marker block
|
|
946
|
+
and returns the parsed data (object, array, or primitive).
|
|
507
947
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
| `text` | `string` | Heading text |
|
|
511
|
-
| `level?` | `number` | Heading level (1-6), defaults to 1 |
|
|
948
|
+
Register custom formats by exporting an `inlineFormats` object
|
|
949
|
+
from `.embedoc/datasources/index.ts`.
|
|
512
950
|
|
|
513
|
-
|
|
951
|
+
***
|
|
514
952
|
|
|
515
|
-
|
|
953
|
+
### ApiSymbolKind
|
|
516
954
|
|
|
517
|
-
|
|
955
|
+
```ts
|
|
956
|
+
type ApiSymbolKind = | 'namespace'
|
|
957
|
+
| 'enum'
|
|
958
|
+
| 'class'
|
|
959
|
+
| 'interface'
|
|
960
|
+
| 'type'
|
|
961
|
+
| 'variable'
|
|
962
|
+
| 'function'
|
|
963
|
+
| 'reference';
|
|
964
|
+
```
|
|
518
965
|
|
|
519
|
-
|
|
966
|
+
Defined in: [types/index.ts:347](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L347)
|
|
520
967
|
|
|
521
|
-
|
|
522
|
-
ctx.markdown.heading('Section Title', 2);
|
|
523
|
-
// Output: ## Section Title
|
|
524
|
-
```
|
|
968
|
+
Kind of an exported API symbol. A `reference` is a second exported name of a symbol.
|
|
525
969
|
|
|
526
|
-
|
|
970
|
+
***
|
|
971
|
+
|
|
972
|
+
### ApiMemberKind
|
|
527
973
|
|
|
528
974
|
```ts
|
|
529
|
-
|
|
975
|
+
type ApiMemberKind = | 'constructor'
|
|
976
|
+
| 'property'
|
|
977
|
+
| 'accessor'
|
|
978
|
+
| 'method'
|
|
979
|
+
| 'call-signature'
|
|
980
|
+
| 'index-signature'
|
|
981
|
+
| 'enum-member';
|
|
530
982
|
```
|
|
531
983
|
|
|
532
|
-
Defined in: types/index.ts:
|
|
984
|
+
Defined in: [types/index.ts:358](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L358)
|
|
533
985
|
|
|
534
|
-
|
|
986
|
+
Kind of a member of a class, interface, object type or enum.
|
|
535
987
|
|
|
536
|
-
|
|
988
|
+
***
|
|
537
989
|
|
|
538
|
-
|
|
539
|
-
| ------ | ------ | ------ |
|
|
540
|
-
| `text` | `string` | Text to make italic |
|
|
990
|
+
### ApiSource
|
|
541
991
|
|
|
542
|
-
|
|
992
|
+
```ts
|
|
993
|
+
type ApiSource = {
|
|
994
|
+
/** Path relative to the common directory of the entry points (for display). */
|
|
995
|
+
file: string;
|
|
996
|
+
/** Path relative to the working directory (the `{path}` of the link template). */
|
|
997
|
+
path: string;
|
|
998
|
+
/** 1-based line of the declaration name. */
|
|
999
|
+
line: number;
|
|
1000
|
+
/** Link built from `source_link_template`, or null without a template. */
|
|
1001
|
+
url: string | null;
|
|
1002
|
+
};
|
|
1003
|
+
```
|
|
543
1004
|
|
|
544
|
-
|
|
1005
|
+
Defined in: [types/index.ts:368](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L368)
|
|
545
1006
|
|
|
546
|
-
|
|
1007
|
+
Where a declaration is in the source.
|
|
547
1008
|
|
|
548
|
-
|
|
1009
|
+
#### Properties
|
|
549
1010
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
1011
|
+
| Property | Type | Description | Defined in |
|
|
1012
|
+
| ------ | ------ | ------ | ------ |
|
|
1013
|
+
| <a id="file"></a> `file` | `string` | Path relative to the common directory of the entry points (for display). | [types/index.ts:370](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L370) |
|
|
1014
|
+
| <a id="path"></a> `path` | `string` | Path relative to the working directory (the `{path}` of the link template). | [types/index.ts:372](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L372) |
|
|
1015
|
+
| <a id="line"></a> `line` | `number` | 1-based line of the declaration name. | [types/index.ts:374](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L374) |
|
|
1016
|
+
| <a id="url"></a> `url` | `string | null` | Link built from `source_link_template`, or null without a template. | [types/index.ts:376](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L376) |
|
|
554
1017
|
|
|
555
|
-
|
|
1018
|
+
***
|
|
1019
|
+
|
|
1020
|
+
### ApiTag
|
|
556
1021
|
|
|
557
1022
|
```ts
|
|
558
|
-
|
|
1023
|
+
type ApiTag = {
|
|
1024
|
+
/** Tag name without `@`. */
|
|
1025
|
+
tag: string;
|
|
1026
|
+
/** Tag text. `{@link ...}` inline tags are kept as written. */
|
|
1027
|
+
text: string;
|
|
1028
|
+
};
|
|
559
1029
|
```
|
|
560
1030
|
|
|
561
|
-
Defined in: types/index.ts:
|
|
1031
|
+
Defined in: [types/index.ts:380](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L380)
|
|
562
1032
|
|
|
563
|
-
|
|
1033
|
+
A JSDoc block tag such as `@example`, `@deprecated` or `@see`.
|
|
564
1034
|
|
|
565
|
-
|
|
1035
|
+
#### Properties
|
|
566
1036
|
|
|
567
|
-
|
|
|
568
|
-
| ------ | ------ | ------ |
|
|
569
|
-
| `
|
|
570
|
-
| `
|
|
1037
|
+
| Property | Type | Description | Defined in |
|
|
1038
|
+
| ------ | ------ | ------ | ------ |
|
|
1039
|
+
| <a id="tag"></a> `tag` | `string` | Tag name without `@`. | [types/index.ts:382](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L382) |
|
|
1040
|
+
| <a id="text"></a> `text` | `string` | Tag text. ``...`` inline tags are kept as written. | [types/index.ts:384](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L384) |
|
|
571
1041
|
|
|
572
|
-
|
|
1042
|
+
***
|
|
573
1043
|
|
|
574
|
-
|
|
1044
|
+
### ApiTypeParameter
|
|
575
1045
|
|
|
576
|
-
|
|
1046
|
+
```ts
|
|
1047
|
+
type ApiTypeParameter = {
|
|
1048
|
+
name: string;
|
|
1049
|
+
constraint: string | null;
|
|
1050
|
+
default: string | null;
|
|
1051
|
+
description: string;
|
|
1052
|
+
};
|
|
1053
|
+
```
|
|
577
1054
|
|
|
578
|
-
|
|
1055
|
+
Defined in: [types/index.ts:388](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L388)
|
|
579
1056
|
|
|
580
|
-
|
|
581
|
-
ctx.markdown.link('Visit Google', 'https://google.com');
|
|
582
|
-
// Output: [Visit Google](https://google.com)
|
|
583
|
-
```
|
|
1057
|
+
A type parameter of a declaration or signature.
|
|
584
1058
|
|
|
585
|
-
|
|
1059
|
+
#### Properties
|
|
1060
|
+
|
|
1061
|
+
| Property | Type | Description | Defined in |
|
|
1062
|
+
| ------ | ------ | ------ | ------ |
|
|
1063
|
+
| <a id="name"></a> `name` | `string` | | [types/index.ts:389](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L389) |
|
|
1064
|
+
| <a id="constraint"></a> `constraint` | `string | null` | | [types/index.ts:390](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L390) |
|
|
1065
|
+
| <a id="default"></a> `default` | `string | null` | | [types/index.ts:391](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L391) |
|
|
1066
|
+
| <a id="description"></a> `description` | `string` | | [types/index.ts:392](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L392) |
|
|
1067
|
+
|
|
1068
|
+
***
|
|
1069
|
+
|
|
1070
|
+
### ApiParameter
|
|
586
1071
|
|
|
587
1072
|
```ts
|
|
588
|
-
|
|
1073
|
+
type ApiParameter = {
|
|
1074
|
+
name: string;
|
|
1075
|
+
type: string;
|
|
1076
|
+
optional: boolean;
|
|
1077
|
+
rest: boolean;
|
|
1078
|
+
defaultValue: string | null;
|
|
1079
|
+
description: string;
|
|
1080
|
+
};
|
|
589
1081
|
```
|
|
590
1082
|
|
|
591
|
-
Defined in: types/index.ts:
|
|
1083
|
+
Defined in: [types/index.ts:396](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L396)
|
|
592
1084
|
|
|
593
|
-
|
|
1085
|
+
A parameter of a signature.
|
|
594
1086
|
|
|
595
|
-
|
|
1087
|
+
#### Properties
|
|
596
1088
|
|
|
597
|
-
|
|
|
598
|
-
| ------ | ------ | ------ |
|
|
599
|
-
| `
|
|
600
|
-
| `
|
|
1089
|
+
| Property | Type | Description | Defined in |
|
|
1090
|
+
| ------ | ------ | ------ | ------ |
|
|
1091
|
+
| <a id="name"></a> `name` | `string` | | [types/index.ts:397](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L397) |
|
|
1092
|
+
| <a id="type"></a> `type` | `string` | | [types/index.ts:398](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L398) |
|
|
1093
|
+
| <a id="optional"></a> `optional` | `boolean` | | [types/index.ts:399](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L399) |
|
|
1094
|
+
| <a id="rest"></a> `rest` | `boolean` | | [types/index.ts:400](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L400) |
|
|
1095
|
+
| <a id="defaultvalue"></a> `defaultValue` | `string | null` | | [types/index.ts:401](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L401) |
|
|
1096
|
+
| <a id="description"></a> `description` | `string` | | [types/index.ts:402](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L402) |
|
|
601
1097
|
|
|
602
|
-
|
|
1098
|
+
***
|
|
603
1099
|
|
|
604
|
-
|
|
1100
|
+
### ApiSignature
|
|
605
1101
|
|
|
606
|
-
|
|
1102
|
+
```ts
|
|
1103
|
+
type ApiSignature = {
|
|
1104
|
+
/** Declaration as code, e.g. `function f(a: string): void;`. */
|
|
1105
|
+
code: string;
|
|
1106
|
+
summary: string;
|
|
1107
|
+
tags: ApiTag[];
|
|
1108
|
+
typeParameters: ApiTypeParameter[];
|
|
1109
|
+
parameters: ApiParameter[];
|
|
1110
|
+
/** Return type and `@returns` text; null for constructors and setters. */
|
|
1111
|
+
returns: { type: string; description: string } | null;
|
|
1112
|
+
source: ApiSource;
|
|
1113
|
+
};
|
|
1114
|
+
```
|
|
607
1115
|
|
|
608
|
-
|
|
1116
|
+
Defined in: [types/index.ts:406](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L406)
|
|
609
1117
|
|
|
610
|
-
|
|
611
|
-
// Unordered list
|
|
612
|
-
ctx.markdown.list(['Apple', 'Banana', 'Cherry'], false);
|
|
613
|
-
// Output:
|
|
614
|
-
// - Apple
|
|
615
|
-
// - Banana
|
|
616
|
-
// - Cherry
|
|
1118
|
+
A call, construct, method or accessor signature.
|
|
617
1119
|
|
|
618
|
-
|
|
619
|
-
ctx.markdown.list(['First', 'Second', 'Third'], true);
|
|
620
|
-
// Output:
|
|
621
|
-
// 1. First
|
|
622
|
-
// 2. Second
|
|
623
|
-
// 3. Third
|
|
624
|
-
```
|
|
1120
|
+
#### Properties
|
|
625
1121
|
|
|
626
|
-
|
|
1122
|
+
| Property | Type | Description | Defined in |
|
|
1123
|
+
| ------ | ------ | ------ | ------ |
|
|
1124
|
+
| <a id="code"></a> `code` | `string` | Declaration as code, e.g. `function f(a: string): void;`. | [types/index.ts:408](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L408) |
|
|
1125
|
+
| <a id="summary"></a> `summary` | `string` | | [types/index.ts:409](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L409) |
|
|
1126
|
+
| <a id="tags"></a> `tags` | `ApiTag[]` | | [types/index.ts:410](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L410) |
|
|
1127
|
+
| <a id="typeparameters"></a> `typeParameters` | `ApiTypeParameter[]` | | [types/index.ts:411](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L411) |
|
|
1128
|
+
| <a id="parameters"></a> `parameters` | `ApiParameter[]` | | [types/index.ts:412](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L412) |
|
|
1129
|
+
| <a id="returns"></a> `returns` | `{ type: string; description: string } | null` | Return type and `@returns` text; null for constructors and setters. | [types/index.ts:414](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L414) |
|
|
1130
|
+
| <a id="source"></a> `source` | `ApiSource` | | [types/index.ts:415](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L415) |
|
|
1131
|
+
|
|
1132
|
+
***
|
|
1133
|
+
|
|
1134
|
+
### ApiMember
|
|
627
1135
|
|
|
628
1136
|
```ts
|
|
629
|
-
|
|
1137
|
+
type ApiMember = {
|
|
1138
|
+
name: string;
|
|
1139
|
+
kind: ApiMemberKind;
|
|
1140
|
+
static: boolean;
|
|
1141
|
+
readonly: boolean;
|
|
1142
|
+
optional: boolean;
|
|
1143
|
+
protected: boolean;
|
|
1144
|
+
abstract: boolean;
|
|
1145
|
+
/** Type of a property, index signature or enum member value; null otherwise. */
|
|
1146
|
+
type: string | null;
|
|
1147
|
+
summary: string;
|
|
1148
|
+
tags: ApiTag[];
|
|
1149
|
+
/** Signatures of constructors, methods, accessors (get then set) and call signatures. */
|
|
1150
|
+
signatures: ApiSignature[];
|
|
1151
|
+
source: ApiSource;
|
|
1152
|
+
};
|
|
630
1153
|
```
|
|
631
1154
|
|
|
632
|
-
Defined in: types/index.ts:
|
|
1155
|
+
Defined in: [types/index.ts:419](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L419)
|
|
633
1156
|
|
|
634
|
-
|
|
1157
|
+
A member of a class, interface, object type alias or enum.
|
|
635
1158
|
|
|
636
|
-
|
|
1159
|
+
#### Properties
|
|
637
1160
|
|
|
638
|
-
|
|
|
639
|
-
| ------ | ------ | ------ |
|
|
640
|
-
| `
|
|
641
|
-
|
|
|
1161
|
+
| Property | Type | Description | Defined in |
|
|
1162
|
+
| ------ | ------ | ------ | ------ |
|
|
1163
|
+
| <a id="name"></a> `name` | `string` | | [types/index.ts:420](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L420) |
|
|
1164
|
+
| <a id="kind"></a> `kind` | `ApiMemberKind` | | [types/index.ts:421](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L421) |
|
|
1165
|
+
| <a id="static"></a> `static` | `boolean` | | [types/index.ts:422](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L422) |
|
|
1166
|
+
| <a id="readonly"></a> `readonly` | `boolean` | | [types/index.ts:423](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L423) |
|
|
1167
|
+
| <a id="optional"></a> `optional` | `boolean` | | [types/index.ts:424](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L424) |
|
|
1168
|
+
| <a id="protected"></a> `protected` | `boolean` | | [types/index.ts:425](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L425) |
|
|
1169
|
+
| <a id="abstract"></a> `abstract` | `boolean` | | [types/index.ts:426](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L426) |
|
|
1170
|
+
| <a id="type"></a> `type` | `string | null` | Type of a property, index signature or enum member value; null otherwise. | [types/index.ts:428](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L428) |
|
|
1171
|
+
| <a id="summary"></a> `summary` | `string` | | [types/index.ts:429](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L429) |
|
|
1172
|
+
| <a id="tags"></a> `tags` | `ApiTag[]` | | [types/index.ts:430](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L430) |
|
|
1173
|
+
| <a id="signatures"></a> `signatures` | `ApiSignature[]` | Signatures of constructors, methods, accessors (get then set) and call signatures. | [types/index.ts:432](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L432) |
|
|
1174
|
+
| <a id="source"></a> `source` | `ApiSource` | | [types/index.ts:433](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L433) |
|
|
642
1175
|
|
|
643
|
-
|
|
1176
|
+
***
|
|
644
1177
|
|
|
645
|
-
|
|
1178
|
+
### ApiLinkTarget
|
|
646
1179
|
|
|
647
|
-
|
|
1180
|
+
```ts
|
|
1181
|
+
type ApiLinkTarget = {
|
|
1182
|
+
/** Target as written in the comment, e.g. `DBModel.use`. */
|
|
1183
|
+
target: string;
|
|
1184
|
+
/** Exported symbol the target names. */
|
|
1185
|
+
name: string;
|
|
1186
|
+
kind: ApiSymbolKind;
|
|
1187
|
+
kindDir: string;
|
|
1188
|
+
/** Member part of the target (`use` in `DBModel.use`), or null. */
|
|
1189
|
+
member: string | null;
|
|
1190
|
+
};
|
|
1191
|
+
```
|
|
648
1192
|
|
|
649
|
-
|
|
1193
|
+
Defined in: [types/index.ts:440](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L440)
|
|
650
1194
|
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
['Column', 'Type', 'Description'],
|
|
654
|
-
[
|
|
655
|
-
['id', 'integer', 'Primary key'],
|
|
656
|
-
['name', 'varchar', 'User name'],
|
|
657
|
-
]
|
|
658
|
-
);
|
|
659
|
-
// Output:
|
|
660
|
-
// | Column | Type | Description |
|
|
661
|
-
// | --- | --- | --- |
|
|
662
|
-
// | id | integer | Primary key |
|
|
663
|
-
// | name | varchar | User name |
|
|
664
|
-
```
|
|
1195
|
+
A ``...`` target in a symbol's documentation that resolves to an
|
|
1196
|
+
exported symbol (or a member of one) of the same datasource.
|
|
665
1197
|
|
|
666
|
-
|
|
1198
|
+
#### Properties
|
|
667
1199
|
|
|
668
|
-
|
|
1200
|
+
| Property | Type | Description | Defined in |
|
|
1201
|
+
| ------ | ------ | ------ | ------ |
|
|
1202
|
+
| <a id="target"></a> `target` | `string` | Target as written in the comment, e.g. `DBModel.use`. | [types/index.ts:442](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L442) |
|
|
1203
|
+
| <a id="name"></a> `name` | `string` | Exported symbol the target names. | [types/index.ts:444](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L444) |
|
|
1204
|
+
| <a id="kind"></a> `kind` | `ApiSymbolKind` | | [types/index.ts:445](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L445) |
|
|
1205
|
+
| <a id="kinddir"></a> `kindDir` | `string` | | [types/index.ts:446](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L446) |
|
|
1206
|
+
| <a id="member"></a> `member` | `string | null` | Member part of the target (`use` in `DBModel.use`), or null. | [types/index.ts:448](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L448) |
|
|
1207
|
+
|
|
1208
|
+
***
|
|
1209
|
+
|
|
1210
|
+
### ApiSymbol
|
|
669
1211
|
|
|
670
1212
|
```ts
|
|
671
|
-
type
|
|
1213
|
+
type ApiSymbol = {
|
|
1214
|
+
/** Exported name. */
|
|
1215
|
+
name: string;
|
|
1216
|
+
kind: ApiSymbolKind;
|
|
1217
|
+
/** Display name of the kind, e.g. `Class`, `Type Alias`. */
|
|
1218
|
+
kindLabel: string;
|
|
1219
|
+
/** Directory name for the kind, e.g. `classes`, `type-aliases`. */
|
|
1220
|
+
kindDir: string;
|
|
1221
|
+
/** Text of the `@category` tag (also kept in `tags`), or null. */
|
|
1222
|
+
category: string | null;
|
|
1223
|
+
summary: string;
|
|
1224
|
+
tags: ApiTag[];
|
|
1225
|
+
/** Declaration as code for type aliases and variables; null otherwise. */
|
|
1226
|
+
code: string | null;
|
|
1227
|
+
typeParameters: ApiTypeParameter[];
|
|
1228
|
+
extends: string[];
|
|
1229
|
+
implements: string[];
|
|
1230
|
+
/** Overload signatures of a function. */
|
|
1231
|
+
signatures: ApiSignature[];
|
|
1232
|
+
/** Members of a class, interface, enum, or object type alias. */
|
|
1233
|
+
members: ApiMember[];
|
|
1234
|
+
source: ApiSource;
|
|
1235
|
+
/** For a `reference` (`export { A as B }`): the name `A` is documented under; null otherwise. */
|
|
1236
|
+
referenceOf: string | null;
|
|
1237
|
+
/** `{@link ...}` targets (and `referenceOf`) that resolve to exported symbols of the datasource. */
|
|
1238
|
+
links: ApiLinkTarget[];
|
|
1239
|
+
};
|
|
672
1240
|
```
|
|
673
1241
|
|
|
674
|
-
Defined in: types/index.ts:
|
|
1242
|
+
Defined in: [types/index.ts:458](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L458)
|
|
675
1243
|
|
|
676
|
-
|
|
1244
|
+
One record of the `typescript` datasource: an exported symbol.
|
|
677
1245
|
|
|
678
|
-
|
|
679
|
-
|
|
1246
|
+
`name`, `kind`, `kindDir` and `category` are flat so they can be used in
|
|
1247
|
+
`WHERE column = ?` queries and in generator `output_path` placeholders,
|
|
1248
|
+
e.g. `./docs/api/{kindDir}/{name}.md`.
|
|
680
1249
|
|
|
681
|
-
####
|
|
1250
|
+
#### Properties
|
|
682
1251
|
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
1252
|
+
| Property | Type | Description | Defined in |
|
|
1253
|
+
| ------ | ------ | ------ | ------ |
|
|
1254
|
+
| <a id="name"></a> `name` | `string` | Exported name. | [types/index.ts:460](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L460) |
|
|
1255
|
+
| <a id="kind"></a> `kind` | `ApiSymbolKind` | | [types/index.ts:461](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L461) |
|
|
1256
|
+
| <a id="kindlabel"></a> `kindLabel` | `string` | Display name of the kind, e.g. `Class`, `Type Alias`. | [types/index.ts:463](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L463) |
|
|
1257
|
+
| <a id="kinddir"></a> `kindDir` | `string` | Directory name for the kind, e.g. `classes`, `type-aliases`. | [types/index.ts:465](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L465) |
|
|
1258
|
+
| <a id="category"></a> `category` | `string | null` | Text of the `@category` tag (also kept in `tags`), or null. | [types/index.ts:467](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L467) |
|
|
1259
|
+
| <a id="summary"></a> `summary` | `string` | | [types/index.ts:468](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L468) |
|
|
1260
|
+
| <a id="tags"></a> `tags` | `ApiTag[]` | | [types/index.ts:469](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L469) |
|
|
1261
|
+
| <a id="code"></a> `code` | `string | null` | Declaration as code for type aliases and variables; null otherwise. | [types/index.ts:471](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L471) |
|
|
1262
|
+
| <a id="typeparameters"></a> `typeParameters` | `ApiTypeParameter[]` | | [types/index.ts:472](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L472) |
|
|
1263
|
+
| <a id="extends"></a> `extends` | `string[]` | | [types/index.ts:473](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L473) |
|
|
1264
|
+
| <a id="implements"></a> `implements` | `string[]` | | [types/index.ts:474](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L474) |
|
|
1265
|
+
| <a id="signatures"></a> `signatures` | `ApiSignature[]` | Overload signatures of a function. | [types/index.ts:476](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L476) |
|
|
1266
|
+
| <a id="members"></a> `members` | `ApiMember[]` | Members of a class, interface, enum, or object type alias. | [types/index.ts:478](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L478) |
|
|
1267
|
+
| <a id="source"></a> `source` | `ApiSource` | | [types/index.ts:479](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L479) |
|
|
1268
|
+
| <a id="referenceof"></a> `referenceOf` | `string | null` | For a `reference` (`export { A as B }`): the name `A` is documented under; null otherwise. | [types/index.ts:481](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L481) |
|
|
1269
|
+
| <a id="links"></a> `links` | `ApiLinkTarget[]` | ``...`` targets (and `referenceOf`) that resolve to exported symbols of the datasource. | [types/index.ts:483](https://github.com/foo-ogawa/embedoc/blob/main/src/types/index.ts#L483) |
|
|
690
1270
|
|
|
691
1271
|
## Variables
|
|
692
1272
|
|
|
@@ -696,23 +1276,17 @@ users.forEach(user => {
|
|
|
696
1276
|
const defineEmbed: DefineEmbedFn;
|
|
697
1277
|
```
|
|
698
1278
|
|
|
699
|
-
Defined in: index.ts:
|
|
1279
|
+
Defined in: [index.ts:185](https://github.com/foo-ogawa/embedoc/blob/main/src/index.ts#L185)
|
|
700
1280
|
|
|
701
1281
|
Define a custom embed for generating content in documents.
|
|
702
1282
|
|
|
703
1283
|
Embeds are TypeScript modules that generate content for markers
|
|
704
1284
|
in your documents. Use this function to create type-safe embed definitions.
|
|
705
1285
|
|
|
706
|
-
#### Param
|
|
707
|
-
|
|
708
|
-
The embed definition object
|
|
709
|
-
|
|
710
|
-
#### Returns
|
|
711
|
-
|
|
712
|
-
The same definition object (for type inference)
|
|
713
|
-
|
|
714
1286
|
#### Examples
|
|
715
1287
|
|
|
1288
|
+
##### Basic embed
|
|
1289
|
+
|
|
716
1290
|
```typescript
|
|
717
1291
|
import { defineEmbed } from 'embedoc';
|
|
718
1292
|
|
|
@@ -729,6 +1303,8 @@ export default defineEmbed({
|
|
|
729
1303
|
});
|
|
730
1304
|
```
|
|
731
1305
|
|
|
1306
|
+
##### Embed with multiple datasources
|
|
1307
|
+
|
|
732
1308
|
```typescript
|
|
733
1309
|
import { defineEmbed } from 'embedoc';
|
|
734
1310
|
|
|
@@ -748,6 +1324,8 @@ export default defineEmbed({
|
|
|
748
1324
|
});
|
|
749
1325
|
```
|
|
750
1326
|
|
|
1327
|
+
##### Embed using frontmatter and parameters
|
|
1328
|
+
|
|
751
1329
|
```typescript
|
|
752
1330
|
import { defineEmbed } from 'embedoc';
|
|
753
1331
|
|
|
@@ -768,6 +1346,107 @@ export default defineEmbed({
|
|
|
768
1346
|
|
|
769
1347
|
#### See
|
|
770
1348
|
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
1349
|
+
- [`EmbedDefinition`](#embeddefinition) for the definition interface
|
|
1350
|
+
- [`EmbedContext`](#embedcontext) for the context object passed to render
|
|
1351
|
+
- [`MarkdownHelper`](#markdownhelper) for markdown generation utilities
|
|
1352
|
+
|
|
1353
|
+
## Functions
|
|
1354
|
+
|
|
1355
|
+
### renderApiIndex()
|
|
1356
|
+
|
|
1357
|
+
```ts
|
|
1358
|
+
function renderApiIndex(records: QueryResult, options?: ApiMarkdownOptions): string;
|
|
1359
|
+
```
|
|
1360
|
+
|
|
1361
|
+
Defined in: [helpers/api-markdown.ts:388](https://github.com/foo-ogawa/embedoc/blob/main/src/helpers/api-markdown.ts#L388)
|
|
1362
|
+
|
|
1363
|
+
Render the index page of an API: symbols grouped by kind (and by `@category`).
|
|
1364
|
+
|
|
1365
|
+
Symbols of `ownFileKinds` are listed as links to `<kindDir>/<name>.md`;
|
|
1366
|
+
the others are written in full. Records keep the order of the datasource.
|
|
1367
|
+
|
|
1368
|
+
#### Parameters
|
|
1369
|
+
|
|
1370
|
+
| Parameter | Type | Description |
|
|
1371
|
+
| ------ | ------ | ------ |
|
|
1372
|
+
| `records` | `QueryResult` | Records of a `typescript` datasource |
|
|
1373
|
+
| `options?` | `ApiMarkdownOptions` | Rendering options **Default** `{}` |
|
|
1374
|
+
|
|
1375
|
+
#### Returns
|
|
1376
|
+
|
|
1377
|
+
`string`
|
|
1378
|
+
|
|
1379
|
+
Markdown
|
|
1380
|
+
|
|
1381
|
+
***
|
|
1382
|
+
|
|
1383
|
+
### renderApiPage()
|
|
1384
|
+
|
|
1385
|
+
```ts
|
|
1386
|
+
function renderApiPage(record: Record<string, unknown>, options?: ApiMarkdownOptions): string;
|
|
1387
|
+
```
|
|
1388
|
+
|
|
1389
|
+
Defined in: [helpers/api-markdown.ts:429](https://github.com/foo-ogawa/embedoc/blob/main/src/helpers/api-markdown.ts#L429)
|
|
1390
|
+
|
|
1391
|
+
Render the page of one symbol (for `<kindDir>/<name>.md`).
|
|
1392
|
+
|
|
1393
|
+
#### Parameters
|
|
1394
|
+
|
|
1395
|
+
| Parameter | Type | Description |
|
|
1396
|
+
| ------ | ------ | ------ |
|
|
1397
|
+
| `record` | `Record<string, unknown>` | One record of a `typescript` datasource |
|
|
1398
|
+
| `options?` | `ApiMarkdownOptions` | Rendering options; `ownFileKinds` and `indexFile` decide the links to other symbols **Default** `{}` |
|
|
1399
|
+
|
|
1400
|
+
#### Returns
|
|
1401
|
+
|
|
1402
|
+
`string`
|
|
1403
|
+
|
|
1404
|
+
Markdown
|
|
1405
|
+
|
|
1406
|
+
***
|
|
1407
|
+
|
|
1408
|
+
### defineDatasource()
|
|
1409
|
+
|
|
1410
|
+
```ts
|
|
1411
|
+
function defineDatasource(definition: CustomDatasourceDefinition): CustomDatasourceDefinition;
|
|
1412
|
+
```
|
|
1413
|
+
|
|
1414
|
+
Defined in: [index.ts:223](https://github.com/foo-ogawa/embedoc/blob/main/src/index.ts#L223)
|
|
1415
|
+
|
|
1416
|
+
Define a custom datasource type for use in `embedoc.config.yaml`.
|
|
1417
|
+
|
|
1418
|
+
Custom datasource types are registered by exporting a `datasourceTypes`
|
|
1419
|
+
object from `.embedoc/datasources/index.ts`. Each value should be
|
|
1420
|
+
created with this function.
|
|
1421
|
+
|
|
1422
|
+
#### Example
|
|
1423
|
+
|
|
1424
|
+
```typescript
|
|
1425
|
+
import { defineDatasource } from 'embedoc';
|
|
1426
|
+
|
|
1427
|
+
export default defineDatasource({
|
|
1428
|
+
async create(config) {
|
|
1429
|
+
const endpoint = config['endpoint'] as string;
|
|
1430
|
+
const data = await fetch(endpoint).then(r => r.json());
|
|
1431
|
+
return {
|
|
1432
|
+
async query() { return data; },
|
|
1433
|
+
async getAll() { return data; },
|
|
1434
|
+
async close() {},
|
|
1435
|
+
};
|
|
1436
|
+
}
|
|
1437
|
+
});
|
|
1438
|
+
```
|
|
1439
|
+
|
|
1440
|
+
#### Parameters
|
|
1441
|
+
|
|
1442
|
+
| Parameter | Type | Description |
|
|
1443
|
+
| ------ | ------ | ------ |
|
|
1444
|
+
| `definition` | `CustomDatasourceDefinition` | The custom datasource definition |
|
|
1445
|
+
|
|
1446
|
+
#### Returns
|
|
1447
|
+
|
|
1448
|
+
`CustomDatasourceDefinition`
|
|
1449
|
+
|
|
1450
|
+
The same definition (for type inference)
|
|
1451
|
+
|
|
1452
|
+
<!--@embedoc:end-->
|