typedoc-theme-oxide 0.2.2 → 0.2.3
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/dist/assets/index.js +1 -31
- package/dist/assets/index.js.map +1 -1
- package/dist/plugin/index.js +0 -54
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/theme.js +56 -1
- package/dist/plugin/theme.js.map +1 -1
- package/package.json +2 -1
package/dist/plugin/index.js
CHANGED
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import * as fs from 'fs/promises';
|
|
2
|
-
import * as path from 'path';
|
|
3
|
-
import { promisify } from 'util';
|
|
4
|
-
import { deflate } from 'zlib';
|
|
5
|
-
import { Reflection } from 'typedoc';
|
|
6
|
-
import { createSearchDocument } from './lib/index.js';
|
|
7
|
-
import { itemLink } from './context/utils.js';
|
|
8
1
|
import { OxideTheme } from './theme.js';
|
|
9
|
-
import { renderTextComment } from './utils.js';
|
|
10
2
|
|
|
11
3
|
/**
|
|
12
4
|
* Called by TypeDoc when loading this theme as a plugin. Should be used to define themes which
|
|
@@ -14,52 +6,6 @@ import { renderTextComment } from './utils.js';
|
|
|
14
6
|
*/
|
|
15
7
|
function load(app) {
|
|
16
8
|
app.renderer.defineTheme('oxide', OxideTheme);
|
|
17
|
-
app.renderer.preRenderAsyncJobs.push(async (event) => {
|
|
18
|
-
const document = createSearchDocument();
|
|
19
|
-
app.renderer.router.getLinkTargets()
|
|
20
|
-
.filter((x) => x instanceof Reflection)
|
|
21
|
-
.filter((x) => x.isDeclaration() || x.isDocument())
|
|
22
|
-
.filter((x) => x.name && !x.flags.isExternal)
|
|
23
|
-
.forEach((item) => {
|
|
24
|
-
try {
|
|
25
|
-
document.add({
|
|
26
|
-
id: item.id,
|
|
27
|
-
name: item.name,
|
|
28
|
-
comment: renderTextComment(item),
|
|
29
|
-
kind: item.kind,
|
|
30
|
-
parent: item.parent?.isProject() ? '' : item.parent?.getFriendlyFullName() ?? '',
|
|
31
|
-
url: itemLink(app.renderer.router, item, false),
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
catch (e) {
|
|
35
|
-
app.logger.error(`error building search index for ${item.name}: ${e}`);
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
const parts = {};
|
|
39
|
-
document.export((key, data) => {
|
|
40
|
-
app.logger.info(`search index part: ${key}`);
|
|
41
|
-
parts[key] = JSON.parse(data);
|
|
42
|
-
});
|
|
43
|
-
const buffer = await promisify(deflate)(Buffer.from(JSON.stringify(parts)));
|
|
44
|
-
const dest = path.join(event.outputDirectory, 'assets', 'oxide');
|
|
45
|
-
await fs.mkdir(dest, { recursive: true });
|
|
46
|
-
await fs.writeFile(path.join(dest, 'search-index.deflate'), buffer);
|
|
47
|
-
});
|
|
48
|
-
app.renderer.postRenderAsyncJobs.push(async (event) => {
|
|
49
|
-
const src = path.join(import.meta.dirname, '..', 'assets');
|
|
50
|
-
const dest = path.join(event.outputDirectory, 'assets', 'oxide');
|
|
51
|
-
try {
|
|
52
|
-
await fs.access(src, fs.constants.F_OK);
|
|
53
|
-
await fs.access(path.join(src, 'rustdoc'), fs.constants.F_OK);
|
|
54
|
-
await fs.mkdir(dest, { recursive: true });
|
|
55
|
-
await fs.cp(src, dest, { recursive: true });
|
|
56
|
-
}
|
|
57
|
-
catch (e) {
|
|
58
|
-
console.log(e);
|
|
59
|
-
app.logger.error('some front-end assets are missing.');
|
|
60
|
-
app.logger.error('users of the theme should not see this, or I must have done something silly.');
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
9
|
}
|
|
64
10
|
|
|
65
11
|
export { load };
|
package/dist/plugin/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/plugin/index.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/plugin/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAkBA;;;AAGG;AACG,SAAU,IAAI,CAAC,GAAgB,EAAA;IACnC,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC,OAAO,EAAE,UAAU,CAAC;AAC/C;;;;"}
|
package/dist/plugin/theme.js
CHANGED
|
@@ -1,10 +1,65 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as fs from 'fs/promises';
|
|
2
|
+
import * as path from 'path';
|
|
3
|
+
import { promisify } from 'util';
|
|
4
|
+
import { deflate } from 'zlib';
|
|
5
|
+
import { DefaultTheme, Reflection } from 'typedoc';
|
|
6
|
+
import { createSearchDocument } from './lib/index.js';
|
|
2
7
|
import { OxideContext } from './context/index.js';
|
|
8
|
+
import { itemLink } from './context/utils.js';
|
|
9
|
+
import { renderTextComment } from './utils.js';
|
|
3
10
|
|
|
4
11
|
class OxideTheme extends DefaultTheme {
|
|
5
12
|
getRenderContext(page) {
|
|
6
13
|
return new OxideContext(this.router, this, page, this.application.options);
|
|
7
14
|
}
|
|
15
|
+
async preRender(event) {
|
|
16
|
+
super.preRender(event);
|
|
17
|
+
const document = createSearchDocument();
|
|
18
|
+
this.application.renderer.router.getLinkTargets()
|
|
19
|
+
.filter((x) => x instanceof Reflection)
|
|
20
|
+
.filter((x) => x.isDeclaration() || x.isDocument())
|
|
21
|
+
.filter((x) => x.name && !x.flags.isExternal)
|
|
22
|
+
.forEach((item) => {
|
|
23
|
+
try {
|
|
24
|
+
document.add({
|
|
25
|
+
id: item.id,
|
|
26
|
+
name: item.name,
|
|
27
|
+
comment: renderTextComment(item),
|
|
28
|
+
kind: item.kind,
|
|
29
|
+
parent: item.parent?.isProject() ? '' : item.parent?.getFriendlyFullName() ?? '',
|
|
30
|
+
url: itemLink(this.router, item, false),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
// the target do not have a url
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
const parts = {};
|
|
38
|
+
document.export((key, data) => {
|
|
39
|
+
this.application.logger.info(`search index part: ${key}`);
|
|
40
|
+
parts[key] = JSON.parse(data);
|
|
41
|
+
});
|
|
42
|
+
const buffer = await promisify(deflate)(Buffer.from(JSON.stringify(parts)));
|
|
43
|
+
const dest = path.join(event.outputDirectory, 'assets', 'oxide');
|
|
44
|
+
await fs.mkdir(dest, { recursive: true });
|
|
45
|
+
await fs.writeFile(path.join(dest, 'search-index.deflate'), buffer);
|
|
46
|
+
}
|
|
47
|
+
async postRender(event) {
|
|
48
|
+
super.postRender(event);
|
|
49
|
+
const src = path.join(import.meta.dirname, '..', 'assets');
|
|
50
|
+
const dest = path.join(event.outputDirectory, 'assets', 'oxide');
|
|
51
|
+
try {
|
|
52
|
+
await fs.access(src, fs.constants.F_OK);
|
|
53
|
+
await fs.access(path.join(src, 'rustdoc'), fs.constants.F_OK);
|
|
54
|
+
await fs.mkdir(dest, { recursive: true });
|
|
55
|
+
await fs.cp(src, dest, { recursive: true });
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
console.log(e);
|
|
59
|
+
this.application.logger.error('some front-end assets are missing.');
|
|
60
|
+
this.application.logger.error('users of the theme should not see this, or I must have done something silly.');
|
|
61
|
+
}
|
|
62
|
+
}
|
|
8
63
|
}
|
|
9
64
|
|
|
10
65
|
export { OxideTheme };
|
package/dist/plugin/theme.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.js","sources":["../../src/plugin/theme.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"theme.js","sources":["../../src/plugin/theme.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;AAYM,MAAO,UAAW,SAAQ,YAAY,CAAA;AAC1C,IAAA,gBAAgB,CAAC,IAA2B,EAAA;AAC1C,QAAA,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;IAC5E;IAEA,MAAM,SAAS,CAAC,KAAoB,EAAA;A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AAC,GAAG,CAAC,CAAC,CAAC;YACd,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,oCAAoC,CAAC;YACnE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,8EAA8E,CAAC;QAC/G;IACF;AACD;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typedoc-theme-oxide",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "A TypeDoc theme looks just like rustdoc.",
|
|
5
5
|
"repository": "github:balthild/typedoc-theme-oxide",
|
|
6
6
|
"author": "Balthild <ibalthild@gmail.com>",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"postcss-nested": "^7.0.2",
|
|
50
50
|
"release-it": "^19.2.4",
|
|
51
51
|
"rollup": "^4.55.3",
|
|
52
|
+
"rollup-plugin-minify-html-literals": "^1.2.6",
|
|
52
53
|
"rollup-plugin-postcss": "^4.0.2",
|
|
53
54
|
"terser": "^5.46.0",
|
|
54
55
|
"tslib": "^2.8.1",
|