1 | "use strict";
|
2 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
3 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
4 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
5 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
6 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
7 | };
|
8 | Object.defineProperty(exports, "__esModule", { value: true });
|
9 | const Path = require("path");
|
10 | const index_1 = require("../../models/reflections/index");
|
11 | const GroupPlugin_1 = require("../../converter/plugins/GroupPlugin");
|
12 | const components_1 = require("../components");
|
13 | const fs_1 = require("../../utils/fs");
|
14 | const events_1 = require("../events");
|
15 | let JavascriptIndexPlugin = class JavascriptIndexPlugin extends components_1.RendererComponent {
|
16 | initialize() {
|
17 | this.listenTo(this.owner, events_1.RendererEvent.BEGIN, this.onRendererBegin);
|
18 | }
|
19 | onRendererBegin(event) {
|
20 | const rows = [];
|
21 | const kinds = {};
|
22 | for (let key in event.project.reflections) {
|
23 | const reflection = event.project.reflections[key];
|
24 | if (!(reflection instanceof index_1.DeclarationReflection)) {
|
25 | continue;
|
26 | }
|
27 | if (!reflection.url ||
|
28 | !reflection.name ||
|
29 | reflection.flags.isExternal ||
|
30 | reflection.name === '') {
|
31 | continue;
|
32 | }
|
33 | let parent = reflection.parent;
|
34 | if (parent instanceof index_1.ProjectReflection) {
|
35 | parent = undefined;
|
36 | }
|
37 | const row = {
|
38 | id: rows.length,
|
39 | kind: reflection.kind,
|
40 | name: reflection.name,
|
41 | url: reflection.url,
|
42 | classes: reflection.cssClasses
|
43 | };
|
44 | if (parent) {
|
45 | row.parent = parent.getFullName();
|
46 | }
|
47 | if (!kinds[reflection.kind]) {
|
48 | kinds[reflection.kind] = GroupPlugin_1.GroupPlugin.getKindSingular(reflection.kind);
|
49 | }
|
50 | rows.push(row);
|
51 | }
|
52 | const fileName = Path.join(event.outputDirectory, 'assets', 'js', 'search.js');
|
53 | const data = `var typedoc = typedoc || {};
|
54 | typedoc.search = typedoc.search || {};
|
55 | typedoc.search.data = ${JSON.stringify({ kinds: kinds, rows: rows })};`;
|
56 | fs_1.writeFile(fileName, data, false);
|
57 | }
|
58 | };
|
59 | JavascriptIndexPlugin = __decorate([
|
60 | components_1.Component({ name: 'javascript-index' })
|
61 | ], JavascriptIndexPlugin);
|
62 | exports.JavascriptIndexPlugin = JavascriptIndexPlugin;
|
63 |
|
\ | No newline at end of file |