@ts-for-gir/generator-html-doc 4.0.0-beta.9 → 4.0.0-rc.1
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 +15 -2
- package/package.json +22 -24
- package/src/html-doc-generator.ts +105 -0
- package/src/index.ts +1 -0
- package/lib/html-doc-generator.d.ts +0 -14
- package/lib/html-doc-generator.js +0 -23
- package/lib/html-doc-generator.js.map +0 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -2
- package/lib/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -16,5 +16,18 @@
|
|
|
16
16
|
<img src="https://raw.githubusercontent.com/gjsify/ts-for-gir/main/.github/feeling.gif" />
|
|
17
17
|
</p>
|
|
18
18
|
|
|
19
|
-
# Generator
|
|
20
|
-
|
|
19
|
+
# HTML Documentation Generator
|
|
20
|
+
|
|
21
|
+
## Status: Not Yet Implemented
|
|
22
|
+
|
|
23
|
+
This package currently serves as a placeholder and basic framework for implementing an HTML documentation generator based on GIR types. It does not contain actual functionality yet.
|
|
24
|
+
|
|
25
|
+
## Purpose
|
|
26
|
+
|
|
27
|
+
The intended purpose of this package is to provide a way to generate HTML documentation from GObject introspection data, similar to how the `generator-typescript` package generates TypeScript definitions. When implemented, it would allow for generating human-readable API documentation websites.
|
|
28
|
+
|
|
29
|
+
## Implementation
|
|
30
|
+
|
|
31
|
+
This package implements the `Generator` interface from `@ts-for-gir/generator-base` but its methods currently throw "Not implemented" errors. It provides the basic structure needed for anyone who wants to implement a full HTML documentation generator for GObject introspection types.
|
|
32
|
+
|
|
33
|
+
If you're interested in implementing this feature, contributions are welcome! Feel free to use this package as a starting point for building a complete HTML documentation generator.
|
package/package.json
CHANGED
|
@@ -1,29 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ts-for-gir/generator-html-doc",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-rc.1",
|
|
4
4
|
"description": "HTML Documentation generator for ts-for-gir",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
5
|
+
"main": "src/index.ts",
|
|
6
|
+
"module": "src/index.ts",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"engines": {
|
|
9
9
|
"node": ">=18"
|
|
10
10
|
},
|
|
11
11
|
"scripts": {
|
|
12
|
-
"
|
|
13
|
-
"build:ts": "tsc",
|
|
14
|
-
"clear": "yarn clear:build",
|
|
15
|
-
"clear:build": "rimraf ./lib",
|
|
16
|
-
"watch": "yarn build:ts --watch",
|
|
17
|
-
"lint": "eslint . --ext .ts,.tsx --fix"
|
|
12
|
+
"check": "tsc --noEmit"
|
|
18
13
|
},
|
|
19
14
|
"repository": {
|
|
20
15
|
"type": "git",
|
|
21
16
|
"url": "git+https://github.com/gjsify/ts-for-gir.git"
|
|
22
17
|
},
|
|
23
|
-
"author": "Pascal Garber <pascal@
|
|
18
|
+
"author": "Pascal Garber <pascal@mailfreun.de>",
|
|
24
19
|
"files": [
|
|
25
|
-
"
|
|
26
|
-
"templates"
|
|
20
|
+
"src"
|
|
27
21
|
],
|
|
28
22
|
"license": "Apache-2.0",
|
|
29
23
|
"bugs": {
|
|
@@ -31,21 +25,25 @@
|
|
|
31
25
|
},
|
|
32
26
|
"homepage": "https://github.com/gjsify/ts-for-gir#readme",
|
|
33
27
|
"keywords": [
|
|
34
|
-
"generator"
|
|
28
|
+
"generator",
|
|
29
|
+
"html",
|
|
30
|
+
"documentation",
|
|
31
|
+
"gir"
|
|
35
32
|
],
|
|
33
|
+
"exports": {
|
|
34
|
+
".": "./src/index.ts"
|
|
35
|
+
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"@
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"eslint-config-prettier": "^9.1.0",
|
|
42
|
-
"eslint-plugin-prettier": "^5.2.1",
|
|
43
|
-
"prettier": "^3.3.3",
|
|
44
|
-
"rimraf": "^6.0.1",
|
|
45
|
-
"typescript": "^5.5.3"
|
|
37
|
+
"@ts-for-gir/tsconfig": "^4.0.0-rc.1",
|
|
38
|
+
"@types/node": "^24.12.2",
|
|
39
|
+
"rimraf": "^6.1.3",
|
|
40
|
+
"typescript": "^6.0.2"
|
|
46
41
|
},
|
|
47
42
|
"dependencies": {
|
|
48
|
-
"@ts-for-gir/generator-base": "^4.0.0-
|
|
49
|
-
"@ts-for-gir/
|
|
43
|
+
"@ts-for-gir/generator-base": "^4.0.0-rc.1",
|
|
44
|
+
"@ts-for-gir/generator-json": "^4.0.0-rc.1",
|
|
45
|
+
"@ts-for-gir/lib": "^4.0.0-rc.1",
|
|
46
|
+
"@ts-for-gir/typedoc-theme": "^4.0.0-rc.1",
|
|
47
|
+
"typedoc": "^0.28.18"
|
|
50
48
|
}
|
|
51
49
|
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { mkdir } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
|
|
4
|
+
import { type TypeDocAppResult, TypeDocPipeline } from "@ts-for-gir/generator-json";
|
|
5
|
+
import { type GirModule, type NSRegistry, type OptionsGeneration, Reporter, ReporterService } from "@ts-for-gir/lib";
|
|
6
|
+
import { load as loadGiDocgenTheme } from "@ts-for-gir/typedoc-theme";
|
|
7
|
+
import type { Application } from "typedoc";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Generator that produces HTML documentation from GIR modules using TypeDoc.
|
|
11
|
+
*
|
|
12
|
+
* Uses {@link TypeDocPipeline} for the shared .d.ts → TypeDoc conversion,
|
|
13
|
+
* then generates HTML documentation via TypeDoc's built-in renderer.
|
|
14
|
+
*/
|
|
15
|
+
export class HtmlDocGenerator {
|
|
16
|
+
readonly log: Reporter;
|
|
17
|
+
readonly config: OptionsGeneration;
|
|
18
|
+
readonly registry: NSRegistry;
|
|
19
|
+
|
|
20
|
+
private readonly pipeline: TypeDocPipeline;
|
|
21
|
+
|
|
22
|
+
constructor(config: OptionsGeneration, registry: NSRegistry) {
|
|
23
|
+
this.config = config;
|
|
24
|
+
this.registry = registry;
|
|
25
|
+
this.pipeline = new TypeDocPipeline(config, registry);
|
|
26
|
+
this.log = new Reporter(
|
|
27
|
+
this.config.verbose,
|
|
28
|
+
HtmlDocGenerator.name,
|
|
29
|
+
this.config.reporter,
|
|
30
|
+
this.config.reporterOutput,
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
if (this.config.reporter) {
|
|
34
|
+
ReporterService.getInstance().registerReporter(HtmlDocGenerator.name, this.log);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
public async start(): Promise<void> {
|
|
39
|
+
this.log.info("Starting HTML documentation generation via TypeDoc...");
|
|
40
|
+
await this.pipeline.start();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public async generate(module: GirModule): Promise<void> {
|
|
44
|
+
await this.pipeline.generate(module);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public async finish(girModules: GirModule[]): Promise<void> {
|
|
48
|
+
await this.pipeline.finishTypescriptGeneration(girModules);
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
const outdir = this.requireOutdir();
|
|
52
|
+
await mkdir(outdir, { recursive: true });
|
|
53
|
+
|
|
54
|
+
if (this.config.combined) {
|
|
55
|
+
const result = await this.pipeline.createCombinedTypeDocApp();
|
|
56
|
+
await this.generateDocsWithTheme(result, outdir);
|
|
57
|
+
} else {
|
|
58
|
+
for (const module of this.pipeline.modules) {
|
|
59
|
+
const result = await this.pipeline.createTypeDocApp(module);
|
|
60
|
+
await this.generateDocsWithTheme(result, join(outdir, module.packageName));
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
this.log.success(`HTML documentation generated for ${this.pipeline.modules.length} modules in ${outdir}`);
|
|
65
|
+
} finally {
|
|
66
|
+
await this.pipeline.cleanup();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Generate combined HTML documentation from pre-generated TypeDoc JSON files.
|
|
72
|
+
* This bypasses the normal .d.ts generation pipeline entirely, using TypeDoc's merge mode.
|
|
73
|
+
*/
|
|
74
|
+
public async generateFromJson(jsonDir: string): Promise<void> {
|
|
75
|
+
const outdir = this.requireOutdir();
|
|
76
|
+
await mkdir(outdir, { recursive: true });
|
|
77
|
+
|
|
78
|
+
this.log.info(`Generating HTML documentation from JSON files in ${jsonDir}...`);
|
|
79
|
+
const result = await this.pipeline.createMergedTypeDocApp(jsonDir);
|
|
80
|
+
await this.generateDocsWithTheme(result, outdir);
|
|
81
|
+
this.log.success(`Generated merged HTML docs from JSON in ${outdir}`);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Apply the configured theme and generate HTML docs into the given directory. */
|
|
85
|
+
private async generateDocsWithTheme({ app, project }: TypeDocAppResult, outdir: string): Promise<void> {
|
|
86
|
+
this.applyTheme(app);
|
|
87
|
+
await app.generateDocs(project, outdir);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private applyTheme(app: Application): void {
|
|
91
|
+
const themeName = this.config.theme || "gi-docgen";
|
|
92
|
+
if (themeName === "gi-docgen") {
|
|
93
|
+
loadGiDocgenTheme(app);
|
|
94
|
+
}
|
|
95
|
+
app.options.setValue("theme", themeName);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Returns outdir or throws if not configured. */
|
|
99
|
+
private requireOutdir(): string {
|
|
100
|
+
if (!this.config.outdir) {
|
|
101
|
+
throw new Error("HTML documentation requires --outdir to be specified");
|
|
102
|
+
}
|
|
103
|
+
return this.config.outdir;
|
|
104
|
+
}
|
|
105
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./html-doc-generator.ts";
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@ts-for-gir/lib';
|
|
2
|
-
import { Generator } from '@ts-for-gir/generator-base';
|
|
3
|
-
import type { OptionsGeneration, GirModule, NSRegistry } from '@ts-for-gir/lib';
|
|
4
|
-
/**
|
|
5
|
-
* A template that can be used to implement an HTML Documentation Generator
|
|
6
|
-
*/
|
|
7
|
-
export declare class HtmlDocGenerator implements Generator {
|
|
8
|
-
protected readonly config: OptionsGeneration;
|
|
9
|
-
protected log: Logger;
|
|
10
|
-
constructor(config: OptionsGeneration);
|
|
11
|
-
start(_registry: NSRegistry): Promise<void>;
|
|
12
|
-
generate(_registry: NSRegistry, _module: GirModule): Promise<void>;
|
|
13
|
-
finish(_registry: NSRegistry, _girModules: GirModule[]): Promise<void>;
|
|
14
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
|
-
import { Logger, DANGER_HTML_DOC_GENERATOR_NOT_IMPLEMENTED } from '@ts-for-gir/lib';
|
|
3
|
-
/**
|
|
4
|
-
* A template that can be used to implement an HTML Documentation Generator
|
|
5
|
-
*/
|
|
6
|
-
export class HtmlDocGenerator {
|
|
7
|
-
config;
|
|
8
|
-
log;
|
|
9
|
-
constructor(config) {
|
|
10
|
-
this.config = config;
|
|
11
|
-
this.log = new Logger(config.verbose, HtmlDocGenerator.name);
|
|
12
|
-
}
|
|
13
|
-
async start(_registry) {
|
|
14
|
-
return Promise.resolve(this.log.danger(DANGER_HTML_DOC_GENERATOR_NOT_IMPLEMENTED));
|
|
15
|
-
}
|
|
16
|
-
generate(_registry, _module) {
|
|
17
|
-
throw new Error('Method not implemented.');
|
|
18
|
-
}
|
|
19
|
-
finish(_registry, _girModules) {
|
|
20
|
-
throw new Error('Method not implemented.');
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=html-doc-generator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"html-doc-generator.js","sourceRoot":"","sources":["../src/html-doc-generator.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,EAAE,MAAM,EAAE,yCAAyC,EAAE,MAAM,iBAAiB,CAAA;AAKnF;;GAEG;AACH,MAAM,OAAO,gBAAgB;IAEM;IADrB,GAAG,CAAQ;IACrB,YAA+B,MAAyB;QAAzB,WAAM,GAAN,MAAM,CAAmB;QACpD,IAAI,CAAC,GAAG,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,gBAAgB,CAAC,IAAI,CAAC,CAAA;IAChE,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,SAAqB;QAC7B,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,yCAAyC,CAAC,CAAC,CAAA;IACtF,CAAC;IAED,QAAQ,CAAC,SAAqB,EAAE,OAAkB;QAC9C,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC9C,CAAC;IAED,MAAM,CAAC,SAAqB,EAAE,WAAwB;QAClD,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAA;IAC9C,CAAC;CACJ"}
|
package/lib/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './html-doc-generator.js';
|
package/lib/index.js
DELETED
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA"}
|