@ts-for-gir/cli 4.0.0-beta.40 → 4.0.0-beta.41
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 +217 -114
- package/bin/ts-for-gir +6719 -3461
- package/package.json +16 -14
- package/src/commands/copy.ts +1 -1
- package/src/commands/doc.ts +30 -45
- package/src/commands/generate.ts +10 -75
- package/src/commands/json.ts +11 -72
- package/src/commands/list.ts +1 -1
- package/src/commands/run-generation-command.ts +70 -0
- package/src/config/config-loader.ts +59 -72
- package/src/config/defaults.ts +5 -0
- package/src/config/options.ts +33 -10
- package/src/generation-handler.ts +9 -9
- package/src/types/command-args.ts +13 -5
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
# CLI
|
|
20
20
|
|
|
21
|
-
CLI tool to generate TypeScript type definitions for GObject Introspection Repository (GIR) files, primarily for GJS applications.
|
|
21
|
+
CLI tool to generate TypeScript type definitions and HTML documentation for GObject Introspection Repository (GIR) files, primarily for GJS applications.
|
|
22
22
|
|
|
23
23
|
## Getting started
|
|
24
24
|
|
|
@@ -37,17 +37,16 @@ npx @ts-for-gir/cli --help
|
|
|
37
37
|
> ts-for-gir --help
|
|
38
38
|
> ```
|
|
39
39
|
|
|
40
|
-
```
|
|
41
|
-
$ npx @ts-for-gir/cli --help
|
|
42
|
-
|
|
40
|
+
```
|
|
43
41
|
TypeScript type definition generator for GObject introspection GIR files
|
|
44
42
|
|
|
45
43
|
Commands:
|
|
46
44
|
ts-for-gir generate [modules..] Generates .d.ts files from GIR for GJS
|
|
45
|
+
ts-for-gir json [modules..] Generates JSON representation from GIR files for analysis and tooling
|
|
46
|
+
ts-for-gir doc [modules..] Generates HTML documentation from GIR files using TypeDoc
|
|
47
47
|
ts-for-gir list [modules..] Lists all available GIR modules
|
|
48
|
-
ts-for-gir analyze Analyze report files generated by ts-for-gir reporter
|
|
49
48
|
ts-for-gir copy [modules..] Scan for *.gir files and copy them to a new directory
|
|
50
|
-
ts-for-gir
|
|
49
|
+
ts-for-gir analyze Analyze report files generated by ts-for-gir reporter
|
|
51
50
|
|
|
52
51
|
Options:
|
|
53
52
|
--version Show version number [boolean]
|
|
@@ -66,9 +65,7 @@ You can also look at the [examples](https://github.com/gjsify/ts-for-gir/tree/ma
|
|
|
66
65
|
|
|
67
66
|
## Generate .d.ts files
|
|
68
67
|
|
|
69
|
-
```
|
|
70
|
-
$ npx @ts-for-gir/cli generate --help
|
|
71
|
-
|
|
68
|
+
```
|
|
72
69
|
ts-for-gir generate [modules..]
|
|
73
70
|
|
|
74
71
|
Generates .d.ts files from GIR for GJS
|
|
@@ -76,11 +73,10 @@ Generates .d.ts files from GIR for GJS
|
|
|
76
73
|
Options:
|
|
77
74
|
--version Show version number [boolean]
|
|
78
75
|
--help Show help [boolean]
|
|
79
|
-
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
--root Root directory of your project
|
|
83
|
-
[string] [default: "/home/jumplink/Projekte/gjsify/ts-for-gir"]
|
|
76
|
+
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts
|
|
77
|
+
multiple modules [array] [default: ["*"]]
|
|
78
|
+
-g, --girDirectories GIR directories [array]
|
|
79
|
+
--root Root directory of your project [string]
|
|
84
80
|
-o, --outdir Directory to output to
|
|
85
81
|
[string] [default: "./@types"]
|
|
86
82
|
-i, --ignore Modules that should be ignored
|
|
@@ -94,50 +90,152 @@ Options:
|
|
|
94
90
|
[boolean] [default: false]
|
|
95
91
|
--configName Specify a custom name for the configuration file
|
|
96
92
|
[string] [default: ".ts-for-girrc.js"]
|
|
97
|
-
-d, --noNamespace Do not export all symbols for each module as a
|
|
98
|
-
|
|
93
|
+
-d, --noNamespace Do not export all symbols for each module as a
|
|
94
|
+
namespace [boolean] [default: false]
|
|
99
95
|
-n, --noComments Do not generate documentation comments
|
|
100
96
|
[boolean] [default: false]
|
|
101
97
|
--promisify Generate promisified functions for async/finish
|
|
102
98
|
calls [boolean] [default: true]
|
|
103
99
|
--npmScope Scope of the generated NPM packages
|
|
104
100
|
[string] [default: "@girs"]
|
|
105
|
-
--workspace Uses the workspace protocol for the generated
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
exports. This is useful if you want to use different
|
|
110
|
-
library versions of the same library in your project.
|
|
111
|
-
[boolean] [default: false]
|
|
101
|
+
--workspace Uses the workspace protocol for the generated
|
|
102
|
+
packages [boolean] [default: false]
|
|
103
|
+
--onlyVersionPrefix Only use the version prefix for the ambient
|
|
104
|
+
module exports [boolean] [default: false]
|
|
112
105
|
--noPrettyPrint Do not prettify the generated types
|
|
113
106
|
[boolean] [default: false]
|
|
114
107
|
--noAdvancedVariants Disable GLib.Variant class with string parsing
|
|
115
|
-
|
|
108
|
+
[boolean] [default: false]
|
|
116
109
|
--package Generate the typescript types with package.json
|
|
117
110
|
support [boolean] [default: false]
|
|
118
111
|
--reporter Enable generation problem reporter and create a
|
|
119
|
-
detailed report file
|
|
120
|
-
--reporterOutput Output file path for the reporter
|
|
121
|
-
|
|
122
|
-
[string] [default: "ts-for-gir-report.json"]
|
|
112
|
+
detailed report file [boolean] [default: false]
|
|
113
|
+
--reporterOutput Output file path for the reporter
|
|
114
|
+
[string] [default: "ts-for-gir-report.json"]
|
|
123
115
|
|
|
124
116
|
Examples:
|
|
125
|
-
ts-for-gir generate
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
ts-for-gir generate 'Gtk*'
|
|
129
|
-
ts-for-gir generate '*'
|
|
130
|
-
|
|
131
|
-
ts-for-gir generate --configName='.
|
|
132
|
-
ts-for-gir generate --ignore=Gtk-4.0 xrandr-1.3
|
|
133
|
-
|
|
117
|
+
ts-for-gir generate Run 'ts-for-gir generate'
|
|
118
|
+
in your gjs project to
|
|
119
|
+
generate typings
|
|
120
|
+
ts-for-gir generate 'Gtk*' You can also use wild cards
|
|
121
|
+
ts-for-gir generate '*' Parse all locally installed
|
|
122
|
+
gir modules
|
|
123
|
+
ts-for-gir generate --configName='.rc.js' Use a special config file
|
|
124
|
+
ts-for-gir generate --ignore=Gtk-4.0 xrandr-1.3 Generate .d.ts files but
|
|
125
|
+
not for Gtk-4.0 and
|
|
126
|
+
xrandr-1.3
|
|
134
127
|
```
|
|
135
128
|
|
|
136
|
-
##
|
|
129
|
+
## Generate TypeDoc JSON
|
|
130
|
+
|
|
131
|
+
Generates TypeDoc JSON output enriched with GIR-specific metadata. This is useful as an intermediate step before generating HTML documentation (see `doc --merge`), or for custom tooling.
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
ts-for-gir json [modules..]
|
|
135
|
+
|
|
136
|
+
Generates JSON representation from GIR files for analysis and tooling
|
|
137
|
+
|
|
138
|
+
Options:
|
|
139
|
+
--version Show version number [boolean]
|
|
140
|
+
--help Show help [boolean]
|
|
141
|
+
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts
|
|
142
|
+
multiple modules [array] [default: ["*"]]
|
|
143
|
+
-g, --girDirectories GIR directories [array]
|
|
144
|
+
--root Root directory of your project [string]
|
|
145
|
+
-o, --outdir Directory to output to
|
|
146
|
+
[string] [default: "./@types"]
|
|
147
|
+
-i, --ignore Modules that should be ignored
|
|
148
|
+
[array] [default: []]
|
|
149
|
+
-v, --verbose Switch on/off the verbose mode
|
|
150
|
+
[boolean] [default: false]
|
|
151
|
+
--ignoreVersionConflicts Skip prompts for library version selection when
|
|
152
|
+
multiple versions are detected
|
|
153
|
+
[boolean] [default: false]
|
|
154
|
+
--configName Specify a custom name for the configuration file
|
|
155
|
+
[string] [default: ".ts-for-girrc.js"]
|
|
156
|
+
|
|
157
|
+
Examples:
|
|
158
|
+
ts-for-gir json Generate JSON for all modules
|
|
159
|
+
ts-for-gir json Gtk-4.0 --outdir ./json Generate JSON for Gtk-4.0 into ./json
|
|
160
|
+
ts-for-gir json '*' --outdir ./json Generate JSON for all modules
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## Generate HTML documentation
|
|
164
|
+
|
|
165
|
+
Generates a browsable HTML API reference using TypeDoc. Supports two modes:
|
|
166
|
+
|
|
167
|
+
- **Direct mode**: Generates `.d.ts` files from GIR, then converts to HTML in one step.
|
|
168
|
+
- **Merge mode** (`--merge`): Reads pre-generated JSON files (from `ts-for-gir json`) and produces HTML. This uses less memory and is suitable for large module sets.
|
|
169
|
+
|
|
170
|
+
The generated documentation uses a custom theme inspired by [gi-docgen](https://gnome.pages.gitlab.gnome.org/gi-docgen/) with a 3-column layout, GIR metadata badges, and categorized module listings.
|
|
171
|
+
|
|
172
|
+
See the live documentation at [gjsify.github.io/docs](https://gjsify.github.io/docs).
|
|
173
|
+
|
|
174
|
+
```
|
|
175
|
+
ts-for-gir doc [modules..]
|
|
176
|
+
|
|
177
|
+
Generates HTML documentation from GIR files using TypeDoc
|
|
178
|
+
|
|
179
|
+
Options:
|
|
180
|
+
--version Show version number [boolean]
|
|
181
|
+
--help Show help [boolean]
|
|
182
|
+
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts
|
|
183
|
+
multiple modules [array] [default: ["*"]]
|
|
184
|
+
-g, --girDirectories GIR directories [array]
|
|
185
|
+
--root Root directory of your project [string]
|
|
186
|
+
-o, --outdir Directory to output to
|
|
187
|
+
[string] [default: "./docs"]
|
|
188
|
+
-i, --ignore Modules that should be ignored
|
|
189
|
+
[array] [default: []]
|
|
190
|
+
-v, --verbose Switch on/off the verbose mode
|
|
191
|
+
[boolean] [default: false]
|
|
192
|
+
--ignoreVersionConflicts Skip prompts for library version selection when
|
|
193
|
+
multiple versions are detected
|
|
194
|
+
[boolean] [default: false]
|
|
195
|
+
--configName Specify a custom name for the configuration file
|
|
196
|
+
[string] [default: ".ts-for-girrc.js"]
|
|
197
|
+
--combined Generate a single unified documentation for all
|
|
198
|
+
modules (use --no-combined for separate
|
|
199
|
+
per-module docs) [boolean] [default: true]
|
|
200
|
+
--sourceLinkTemplate URL template for source links in generated
|
|
201
|
+
documentation. Supports {path}, {line},
|
|
202
|
+
{gitRevision} placeholders [string]
|
|
203
|
+
--theme Theme for HTML documentation generation.
|
|
204
|
+
Use "default" for TypeDoc's built-in theme.
|
|
205
|
+
[string] [default: "gi-docgen"]
|
|
206
|
+
--readme Path to a README file for the documentation
|
|
207
|
+
index page. Use "none" to disable. [string]
|
|
208
|
+
--merge Use TypeDoc merge mode to generate HTML from
|
|
209
|
+
pre-generated JSON files (requires --jsonDir)
|
|
210
|
+
[boolean] [default: false]
|
|
211
|
+
--jsonDir Directory containing pre-generated TypeDoc JSON
|
|
212
|
+
files for merge mode (from 'ts-for-gir json')
|
|
213
|
+
[string]
|
|
214
|
+
|
|
215
|
+
Examples:
|
|
216
|
+
ts-for-gir doc Gtk-4.0 --outdir ./docs Generate HTML documentation
|
|
217
|
+
for Gtk-4.0
|
|
218
|
+
ts-for-gir doc '*' --outdir ./docs Generate documentation for all
|
|
219
|
+
locally installed GIR modules
|
|
220
|
+
ts-for-gir doc --merge --jsonDir ./json Generate HTML from pre-generated
|
|
221
|
+
--outdir ./docs JSON files (low memory)
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Two-phase workflow
|
|
225
|
+
|
|
226
|
+
For large module sets, you can split documentation generation into two phases to reduce peak memory usage:
|
|
137
227
|
|
|
138
228
|
```bash
|
|
139
|
-
|
|
140
|
-
|
|
229
|
+
# Phase 1: Generate JSON files (one per module)
|
|
230
|
+
ts-for-gir json '*' --outdir ./json
|
|
231
|
+
|
|
232
|
+
# Phase 2: Merge JSON files into HTML documentation
|
|
233
|
+
ts-for-gir doc --merge --jsonDir ./json --outdir ./docs
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## List available GIR modules
|
|
237
|
+
|
|
238
|
+
```
|
|
141
239
|
ts-for-gir list [modules..]
|
|
142
240
|
|
|
143
241
|
Lists all available GIR modules
|
|
@@ -145,27 +243,55 @@ Lists all available GIR modules
|
|
|
145
243
|
Options:
|
|
146
244
|
--version Show version number [boolean]
|
|
147
245
|
--help Show help [boolean]
|
|
148
|
-
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts
|
|
149
|
-
|
|
150
|
-
-g, --girDirectories GIR directories
|
|
151
|
-
|
|
152
|
-
--root Root directory of your project
|
|
153
|
-
[string] [default: "/home/jumplink/Projekte/gjsify/ts-for-gir"]
|
|
246
|
+
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts
|
|
247
|
+
multiple modules [array] [default: ["*"]]
|
|
248
|
+
-g, --girDirectories GIR directories [array]
|
|
249
|
+
--root Root directory of your project [string]
|
|
154
250
|
-i, --ignore Modules that should be ignored [array] [default: []]
|
|
155
251
|
--configName Specify a custom name for the configuration file
|
|
156
252
|
[string] [default: ".ts-for-girrc.js"]
|
|
157
253
|
-v, --verbose Switch on/off the verbose mode [boolean] [default: false]
|
|
158
254
|
|
|
159
255
|
Examples:
|
|
160
|
-
ts-for-gir list -g ./vala-girs/gir-1.0
|
|
161
|
-
|
|
256
|
+
ts-for-gir list -g ./vala-girs/gir-1.0 Lists all available GIR
|
|
257
|
+
modules in
|
|
258
|
+
./vala-girs/gir-1.0
|
|
259
|
+
ts-for-gir list --ignore=Gtk-3.0 xrandr-1.3 Lists all available GIR
|
|
260
|
+
modules but not Gtk-3.0
|
|
261
|
+
and xrandr-1.3
|
|
162
262
|
```
|
|
163
263
|
|
|
164
|
-
##
|
|
264
|
+
## Copy GIR files
|
|
165
265
|
|
|
166
|
-
```
|
|
167
|
-
|
|
266
|
+
```
|
|
267
|
+
ts-for-gir copy [modules..]
|
|
268
|
+
|
|
269
|
+
Scan for *.gir files and copy them to a new directory
|
|
168
270
|
|
|
271
|
+
Options:
|
|
272
|
+
--version Show version number [boolean]
|
|
273
|
+
--help Show help [boolean]
|
|
274
|
+
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts
|
|
275
|
+
multiple modules [array] [default: ["*"]]
|
|
276
|
+
-g, --girDirectories GIR directories [array]
|
|
277
|
+
--root Root directory of your project [string]
|
|
278
|
+
-o, --outdir Directory to output to [string] [default: "./@types"]
|
|
279
|
+
-i, --ignore Modules that should be ignored [array] [default: []]
|
|
280
|
+
--configName Specify a custom name for the configuration file
|
|
281
|
+
[string] [default: ".ts-for-girrc.js"]
|
|
282
|
+
-v, --verbose Switch on/off the verbose mode [boolean] [default: false]
|
|
283
|
+
|
|
284
|
+
Examples:
|
|
285
|
+
ts-for-gir copy -o ./gir Copy found *.gir files to
|
|
286
|
+
./gir
|
|
287
|
+
ts-for-gir copy -g /usr/share/gir-1.0 Copy all found *.gir files
|
|
288
|
+
--ignore=Gtk-3.0 xrandr-1.3 -o ./gir excluding Gtk-3.0 and
|
|
289
|
+
xrandr-1.3 to ./gir
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
## Analyze report files
|
|
293
|
+
|
|
294
|
+
```
|
|
169
295
|
ts-for-gir analyze [options]
|
|
170
296
|
|
|
171
297
|
Analyze report files generated by ts-for-gir reporter
|
|
@@ -174,20 +300,22 @@ Options:
|
|
|
174
300
|
--version Show version number [boolean]
|
|
175
301
|
--help Show help [boolean]
|
|
176
302
|
-f, --reportFile Path to the report file to analyze [string] [required]
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
303
|
+
-s, --severity Filter by problem severity
|
|
304
|
+
(debug, info, warning, error, critical) [array]
|
|
305
|
+
-c, --category Filter by problem category [array]
|
|
306
|
+
-n, --namespace Filter by namespace/module [array]
|
|
307
|
+
-t, --type Filter by specific type name [array]
|
|
182
308
|
--search Search for text in messages, details, or type names
|
|
183
309
|
[string]
|
|
184
|
-
--since Filter problems since date/time (ISO format)
|
|
185
|
-
--until Filter problems until date/time (ISO format)
|
|
186
|
-
--top Show top N most problematic items
|
|
187
|
-
--format Output format (table, json,
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
310
|
+
--since Filter problems since date/time (ISO format) [string]
|
|
311
|
+
--until Filter problems until date/time (ISO format) [string]
|
|
312
|
+
--top Show top N most problematic items [number] [default: 10]
|
|
313
|
+
--format Output format (table, json, csv)
|
|
314
|
+
[string] [default: "table"]
|
|
315
|
+
-e, --export Export filtered results to file [string]
|
|
316
|
+
-d, --detailed Show detailed problem information [boolean] [default: false]
|
|
317
|
+
--summary Show summary statistics only [boolean] [default: false]
|
|
318
|
+
-v, --verbose Enable verbose output [boolean] [default: false]
|
|
191
319
|
|
|
192
320
|
Examples:
|
|
193
321
|
ts-for-gir analyze -f ./ts-for-gir-report.json
|
|
@@ -195,62 +323,21 @@ Examples:
|
|
|
195
323
|
ts-for-gir analyze -f ./report.json --severity error critical
|
|
196
324
|
Show only critical and error problems
|
|
197
325
|
ts-for-gir analyze -f ./report.json --category type_resolution --format table
|
|
198
|
-
Show type resolution problems
|
|
326
|
+
Show type resolution problems
|
|
199
327
|
ts-for-gir analyze -f ./report.json --namespace Gtk --top 10
|
|
200
328
|
Show top 10 problems in Gtk namespace
|
|
201
329
|
ts-for-gir analyze -f ./report.json --search "Unable to resolve" --export errors.json
|
|
202
330
|
Export unresolved type errors to file
|
|
203
|
-
ts-for-gir analyze -f ./report.json --type time_t --format json
|
|
204
|
-
Analyze specific type problems in JSON format
|
|
205
331
|
```
|
|
206
332
|
|
|
207
|
-
The `analyze` command
|
|
333
|
+
The `analyze` command helps debug type generation issues by providing powerful filtering and analysis capabilities for ts-for-gir report files.
|
|
208
334
|
|
|
209
335
|
**Key Features:**
|
|
210
336
|
- **Comprehensive Filtering**: Filter by severity, category, namespace, type name, or search text
|
|
211
|
-
- **Multiple Output Formats**: Table, JSON, or
|
|
337
|
+
- **Multiple Output Formats**: Table, JSON, or CSV format for different use cases
|
|
212
338
|
- **Statistical Analysis**: Show most problematic types, namespaces, and categories
|
|
213
339
|
- **Export Capabilities**: Save filtered results for further analysis
|
|
214
340
|
- **Time-based Filtering**: Analyze problems within specific time ranges
|
|
215
|
-
- **AI-Friendly**: Structured output perfect for automated analysis and debugging
|
|
216
|
-
|
|
217
|
-
**Common Use Cases:**
|
|
218
|
-
- Debug type resolution failures for specific libraries
|
|
219
|
-
- Identify patterns in generation problems across modules
|
|
220
|
-
- Export specific error categories for detailed analysis
|
|
221
|
-
- Monitor type generation quality over time
|
|
222
|
-
- Automated problem detection in CI/CD pipelines
|
|
223
|
-
|
|
224
|
-
## Generate HTML documentation
|
|
225
|
-
|
|
226
|
-
```bash
|
|
227
|
-
$ npx @ts-for-gir/cli doc --help
|
|
228
|
-
|
|
229
|
-
ts-for-gir doc [modules..]
|
|
230
|
-
|
|
231
|
-
The HTML documentation generator is not yet implemented, but feel free to implement it 🤗
|
|
232
|
-
|
|
233
|
-
Options:
|
|
234
|
-
--version Show version number [boolean]
|
|
235
|
-
--help Show help [boolean]
|
|
236
|
-
--modules GIR modules to load, e.g. 'Gio-2.0'. Accepts multiple modules
|
|
237
|
-
[array] [default: ["*"]]
|
|
238
|
-
-g, --girDirectories GIR directories
|
|
239
|
-
[array] [default: ["/usr/local/share/gir-1.0","/usr/share/gir-1.0","/usr/share/*/gir-1.0","/usr/share/gnome-shell","/usr/share/gnome-shell/gir-1.0","/usr/lib64/mutter-*","/usr/lib/mutter-*","/usr/lib/x86_64-linux-gnu/mutter-*"]]
|
|
240
|
-
--root Root directory of your project
|
|
241
|
-
[string] [default: "/home/jumplink/Projekte/gjsify/ts-for-gir"]
|
|
242
|
-
-o, --outdir Directory to output to
|
|
243
|
-
[string] [default: "./@types"]
|
|
244
|
-
-i, --ignore Modules that should be ignored
|
|
245
|
-
[array] [default: []]
|
|
246
|
-
-v, --verbose Switch on/off the verbose mode
|
|
247
|
-
[boolean] [default: false]
|
|
248
|
-
--ignoreVersionConflicts Skip prompts for library version selection when
|
|
249
|
-
multiple versions are detected
|
|
250
|
-
[boolean] [default: false]
|
|
251
|
-
--configName Specify a custom name for the configuration file
|
|
252
|
-
[string] [default: ".ts-for-girrc.js"]
|
|
253
|
-
```
|
|
254
341
|
|
|
255
342
|
## Config
|
|
256
343
|
|
|
@@ -270,12 +357,28 @@ export default {
|
|
|
270
357
|
|
|
271
358
|
The javascript config files must also be in ESM format if you are inside a ESM Package, this is the case if `"type": "module"` is defined in your package.json. Alternatively, the file can be saved in json format, then it works in both cases.
|
|
272
359
|
|
|
273
|
-
You can pass the config file name to the CLI using [configName](#
|
|
360
|
+
You can pass the config file name to the CLI using [configName](#configname).
|
|
361
|
+
|
|
362
|
+
### Doc-specific config
|
|
363
|
+
|
|
364
|
+
For documentation generation, you can configure doc-specific options in the config file:
|
|
365
|
+
|
|
366
|
+
```js
|
|
367
|
+
export default {
|
|
368
|
+
modules: ['Gtk-4.0', 'Gdk-4.0', 'Gio-2.0', 'GLib-2.0', 'GObject-2.0'],
|
|
369
|
+
outdir: './docs',
|
|
370
|
+
merge: true,
|
|
371
|
+
jsonDir: './json',
|
|
372
|
+
readme: './DOC.md',
|
|
373
|
+
verbose: true,
|
|
374
|
+
sourceLinkTemplate: 'https://github.com/user/repo/blob/main/{path}#L{line}',
|
|
375
|
+
}
|
|
376
|
+
```
|
|
274
377
|
|
|
275
378
|
## Options
|
|
276
379
|
|
|
277
380
|
### girDirectories
|
|
278
|
-
Directories in which `*.gir` files are to be searched for. Default is `["/usr/share/gir-1.0"]`. More than one can be specified. If you want to generate the types for the GNOME Shell you have to search in several folders for the corresponding types:
|
|
381
|
+
Directories in which `*.gir` files are to be searched for. Default is `["/usr/share/gir-1.0"]`. More than one can be specified. If you want to generate the types for the GNOME Shell you have to search in several folders for the corresponding types:
|
|
279
382
|
```js
|
|
280
383
|
girDirectories: [
|
|
281
384
|
// General gir files
|
|
@@ -294,7 +397,7 @@ girDirectories: [
|
|
|
294
397
|
```
|
|
295
398
|
|
|
296
399
|
### outdir
|
|
297
|
-
The `outdir` option is used to specify the name of the directory where the generated TypeScript types should be saved. The default value of the `outdir` option is `"./@types"`.
|
|
400
|
+
The `outdir` option is used to specify the name of the directory where the generated TypeScript types should be saved. The default value of the `outdir` option is `"./@types"` for `generate` and `"./docs"` for `doc`.
|
|
298
401
|
|
|
299
402
|
Here is an example of how you can use the outdir option in the CLI of `ts-for-gir`:
|
|
300
403
|
|
|
@@ -331,7 +434,7 @@ The `ignoreVersionConflicts` CLI option allows you to disable the prompt to choo
|
|
|
331
434
|
|
|
332
435
|
This option can be useful in certain scenarios where you want to generate types for all versions of a library, even if there are conflicts between the versions. Note that this may result in type conflicts and other issues, so it should be used with caution.
|
|
333
436
|
|
|
334
|
-
Another way to disable the prompt and ignore conflicting versions of `.gir` files is to use the [ignore CLI option](#ignore).
|
|
437
|
+
Another way to disable the prompt and ignore conflicting versions of `.gir` files is to use the [ignore CLI option](#ignore).
|
|
335
438
|
|
|
336
439
|
### print
|
|
337
440
|
The `print` CLI option allows you to output the generated TypeScript definitions to the console, instead of saving them to files on disk. This is useful if you want to quickly inspect the generated types without having to save them to disk and open them in an editor.
|
|
@@ -341,7 +444,7 @@ By default, the print option is disabled and the generated types will be saved t
|
|
|
341
444
|
### configName
|
|
342
445
|
The `configName` CLI option allows you to specify the name of the configuration file to be used when generating the TypeScript definitions. This option is useful if you want to use a custom configuration file instead of the default one.
|
|
343
446
|
|
|
344
|
-
By default
|
|
447
|
+
By default, `ts-for-gir` looks for a configuration file named `.ts-for-girrc.js` in the current directory. If a different configuration file name is required, the `configName` option can be used to specify the name of the configuration file.
|
|
345
448
|
|
|
346
449
|
For example, if you have a configuration file named `custom-config.js`, you can use the following command to generate TypeScript definitions using this configuration file:
|
|
347
450
|
|
|
@@ -440,7 +543,7 @@ To use ambient modules, the `ambient.d.ts` file must be imported either in the c
|
|
|
440
543
|
```json
|
|
441
544
|
// tsconfig.json
|
|
442
545
|
{
|
|
443
|
-
"compilerOptions": {
|
|
546
|
+
"compilerOptions": {
|
|
444
547
|
"lib": ["ESNext"],
|
|
445
548
|
"types": [],
|
|
446
549
|
"target": "ESNext",
|
|
@@ -484,4 +587,4 @@ The `--reporterOutput` option specifies the output file path for the reporter. T
|
|
|
484
587
|
|
|
485
588
|
```bash
|
|
486
589
|
ts-for-gir generate * --reporterOutput custom-report.json
|
|
487
|
-
```
|
|
590
|
+
```
|