|
1 |
| -import { ApiClass, ApiItem, ApiModel, ApiProperty } from "@microsoft/api-extractor-model"; |
2 |
| -import path from "path"; |
3 |
| -import { IndentedWriter, writeApiItem } from "./mdWriter"; |
4 |
| - |
5 |
| -function getGuideSidebar() { |
6 |
| - return [ |
7 |
| - { |
8 |
| - text: "Introduction", |
9 |
| - children: [ |
10 |
| - { text: "Getting Started", link: "/README" } |
11 |
| - ] |
| 1 | +import { defineConfig } from "vitepress"; |
| 2 | +import { observable } from "@hpcc-js/markdown-it-plugins"; |
| 3 | +import { eclLang } from "@hpcc-js/markdown-it-plugins/ecl-lang"; |
| 4 | + |
| 5 | +// https://vitepress.dev/reference/site-config |
| 6 | +export default async () => { |
| 7 | + |
| 8 | + return defineConfig({ |
| 9 | + title: "@hpcc-js/Visualization", |
| 10 | + description: "HPCC Systems JavaScript Library", |
| 11 | + base: "/Visualization/", |
| 12 | + srcDir: ".", |
| 13 | + rewrites: { |
12 | 14 | },
|
13 |
| - { |
14 |
| - text: "Advanced", |
15 |
| - children: [{ text: "API Reference", link: "/docs/api/hpcc-js" }] |
16 |
| - } |
17 |
| - ]; |
18 |
| -} |
19 |
| - |
20 |
| -// Keep in sync with: ../components/README.md |
21 |
| - |
22 |
| -function getComponentsSidebar() { |
23 |
| - return [ |
24 |
| - { |
25 |
| - text: "Editors", |
26 |
| - children: [ |
27 |
| - { text: "CodeMirror", link: "/components/editor/src/codemirror" }, |
28 |
| - { text: "Preview", link: "/components/preview/src/preview" }, |
29 |
| - ] |
30 |
| - }, { |
31 |
| - text: "Observable HQ", |
32 |
| - children: [ |
33 |
| - { text: "Getting Started", link: "/components/observable/README" }, |
34 |
| - { text: "Observable Script", link: "/components/observable/src/observable" }, |
35 |
| - ] |
36 |
| - }, { |
37 |
| - text: "Layouts", |
38 |
| - children: [ |
39 |
| - { text: "Getting Started", link: "/components/layout/README" }, |
40 |
| - { text: "Dock Panel", link: "/components/layout/src/lumino/dockPanel" }, |
41 |
| - { text: "Drag and Zoom", link: "/components/layout/src/zoom" }, |
42 |
| - { text: "Split Panel", link: "/components/layout/src/lumino/splitPanel" }, |
43 |
| - { text: "Tab Panel", link: "/components/layout/src/lumino/tabPanel" }, |
44 |
| - ] |
45 |
| - }//, { |
46 |
| - // text: "Visualizations", |
47 |
| - // children: [ |
48 |
| - // { text: "Gauge", link: "/components/gauge/src/gauge" }, |
49 |
| - // { text: "Half Pie", link: "/components/pie/src/halfpie" }, |
50 |
| - // { text: "Observable JS", link: "/components/observable/src/observable" }, |
51 |
| - // { text: "Pie", link: "/components/pie/src/pie" }, |
52 |
| - // { text: "Quarter Pie", link: "/components/pie/src/quarterpie" }, |
53 |
| - // { text: "Sankey", link: "/components/sankey/src/sankey" }, |
54 |
| - // { text: "Treemap", link: "/components/treemap/src/treemap" }, |
55 |
| - // ] |
56 |
| - // } |
57 |
| - ]; |
58 |
| -} |
59 |
| - |
60 |
| -function getVisualizationsSidebar() { |
61 |
| - return [ |
62 |
| - { |
63 |
| - text: "Charts", |
64 |
| - children: [ |
65 |
| - { text: "Getting Started", link: "/packages/chart/README" }, |
66 |
| - { text: "Area", link: "/packages/chart/src/Area" }, |
67 |
| - { text: "Bar", link: "/packages/chart/src/Bar" }, |
68 |
| - { text: "Bubble", link: "/packages/chart/src/Bubble" }, |
69 |
| - { text: "Bullet", link: "/packages/chart/src/Bullet" }, |
70 |
| - { text: "Column", link: "/packages/chart/src/Column" }, |
71 |
| - { text: "Contour", link: "/packages/chart/src/Contour" }, |
72 |
| - { text: "Gantt", link: "/packages/chart/src/Gantt" }, |
73 |
| - { text: "Gauge", link: "/packages/chart/src/Gauge" }, |
74 |
| - { text: "Half Pie", link: "/packages/chart/src/HalfPie" }, |
75 |
| - { text: "Heat", link: "/packages/chart/src/Heat" }, |
76 |
| - { text: "Hex Bin", link: "/packages/chart/src/HexBin" }, |
77 |
| - { text: "Line", link: "/packages/chart/src/Line" }, |
78 |
| - { text: "Pie", link: "/packages/chart/src/Pie" }, |
79 |
| - { text: "Quarter Pie", link: "/packages/chart/src/QuarterPie" }, |
80 |
| - { text: "Quartile Candlestick", link: "/packages/chart/src/QuartileCandlestick" }, |
81 |
| - { text: "Radar", link: "/packages/chart/src/Radar" }, |
82 |
| - { text: "Radial Bar", link: "/packages/chart/src/RadialBar" }, |
83 |
| - { text: "Scatter", link: "/packages/chart/src/Scatter" }, |
84 |
| - { text: "Stat Chart", link: "/packages/chart/src/StatChart" }, |
85 |
| - { text: "Step", link: "/packages/chart/src/Step" }, |
86 |
| - { text: "Summary", link: "/packages/chart/src/Summary" }, |
87 |
| - { text: "Summary (Canvas)", link: "/packages/chart/src/SummaryC" }, |
88 |
| - { text: "Word Cloud", link: "/packages/chart/src/WordCloud" }, |
89 |
| - { text: "XYAxis", link: "/packages/chart/src/XYAxis" }, |
90 |
| - ] |
91 |
| - }, { |
92 |
| - text: "Editors", |
93 |
| - children: [ |
94 |
| - { text: "Getting Started", link: "/packages/codemirror/README" }, |
95 |
| - ] |
96 |
| - }, { |
97 |
| - text: "Grids", |
98 |
| - children: [ |
99 |
| - { text: "Getting Started", link: "/packages/dgrid2/README" }, |
100 |
| - { text: "Table", link: "/packages/dgrid2/src/table" }, |
101 |
| - ] |
102 |
| - }, { |
103 |
| - text: "Graphs", |
104 |
| - children: [ |
105 |
| - { text: "Getting Started", link: "/packages/graph/README" }, |
106 |
| - ] |
107 |
| - }, { |
108 |
| - text: "Layouts", |
109 |
| - children: [ |
110 |
| - { text: "Getting Started", link: "/packages/layout/README" }, |
111 |
| - ] |
112 |
| - }, { |
113 |
| - text: "Geospatial 2D", |
114 |
| - children: [ |
115 |
| - { text: "Getting Started", link: "/packages/map/README" }, |
116 |
| - ] |
117 |
| - }, { |
118 |
| - text: "Geospatial 3D", |
119 |
| - children: [ |
120 |
| - { text: "Getting Started", link: "/packages/map-deck/README" }, |
121 |
| - ] |
122 |
| - }, { |
123 |
| - text: "Observable HQ", |
124 |
| - children: [ |
125 |
| - { text: "Getting Started", link: "/packages/observablehq-compiler/README" }, |
126 |
| - { text: "Compiler", link: "/packages/observablehq-compiler/src/compiler" }, |
127 |
| - { text: "Utilities", link: "/packages/observablehq-compiler/src/util" }, |
128 |
| - ] |
129 |
| - }, { |
130 |
| - text: "Timelines", |
131 |
| - children: [ |
132 |
| - { text: "Getting Started", link: "/packages/timeline/README" }, |
133 |
| - ] |
134 |
| - }, { |
135 |
| - text: "Hierarchy", |
136 |
| - children: [ |
137 |
| - { text: "Getting Started", link: "/packages/tree/README" }, |
138 |
| - ] |
139 |
| - } |
140 |
| - ]; |
141 |
| -} |
142 |
| - |
143 |
| -module.exports = { |
144 |
| - lang: "en-US", |
145 |
| - title: "@hpcc-js/Visualization", |
146 |
| - description: "HPCC Systems JavaScript Library", |
147 |
| - base: "/Visualization/", |
148 |
| - |
149 |
| - head: [ |
150 |
| - ['link', { rel: 'icon', type: 'image/x-icon', href: '/Visualization/resources/favicon.ico' }], |
151 |
| - ], |
| 15 | + lastUpdated: true, |
| 16 | + themeConfig: { |
| 17 | + // https://vitepress.dev/reference/default-theme-config |
| 18 | + nav: [ |
| 19 | + { text: "Home", link: "/" }, |
| 20 | + { text: "Getting Started", link: "/README" }, |
| 21 | + ], |
| 22 | + |
| 23 | + sidebar: [ |
| 24 | + { text: "Getting Started", link: "/README" }, |
| 25 | + { |
| 26 | + text: "Documentation", |
| 27 | + items: [ |
| 28 | + ] |
| 29 | + } |
| 30 | + ], |
152 | 31 |
|
153 |
| - themeConfig: { |
154 |
| - repo: "hpcc-systems/Visualization", |
155 |
| - docsDir: "", |
156 |
| - docsBranch: "trunk", |
157 |
| - editLinks: true, |
158 |
| - editLinkText: "Edit this page on GitHub", |
159 |
| - lastUpdated: "Last Updated", |
| 32 | + socialLinks: [ |
| 33 | + { icon: "github", link: "https://github.com/hpcc-systems/visualization" } |
| 34 | + ], |
160 | 35 |
|
161 |
| - nav: [ |
162 |
| - { |
163 |
| - text: "Guide", |
164 |
| - link: "/README", |
165 |
| - activeMatch: "^/README" |
166 |
| - }, |
167 |
| - { |
168 |
| - text: "Web Components", |
169 |
| - link: "/components/README", |
170 |
| - activeMatch: "^/components/" |
171 |
| - }, |
172 |
| - { |
173 |
| - text: "Visualizations", |
174 |
| - link: "/packages/README", |
175 |
| - activeMatch: "^/packages/" |
| 36 | + }, |
| 37 | + markdown: { |
| 38 | + // https://github.com/vuejs/vitepress/blob/main/src/node/markdown/markdown.ts |
| 39 | + config: md => { |
| 40 | + md.use(observable, { vitePress: true }); |
176 | 41 | },
|
177 |
| - { |
178 |
| - text: "Release Notes", |
179 |
| - link: "https://github.com/hpcc-systems/Visualization/releases" |
180 |
| - } |
181 |
| - ], |
182 | 42 |
|
183 |
| - sidebar: { |
184 |
| - "/README": getGuideSidebar(), |
185 |
| - "/components": getComponentsSidebar(), |
186 |
| - "/packages": getVisualizationsSidebar() |
| 43 | + languages: [eclLang()], |
187 | 44 | }
|
188 |
| - }, |
189 | 45 |
|
190 |
| - vue: { |
191 |
| - template: { |
192 |
| - compilerOptions: { |
193 |
| - isCustomElement: (tag) => { |
194 |
| - return tag.toLowerCase().indexOf("hpcc-") === 0; |
195 |
| - } |
196 |
| - } |
197 |
| - } |
198 |
| - }, |
199 |
| - |
200 |
| - markdown: { |
201 |
| - config: (md) => { |
202 |
| - const structs: { [id: string]: ApiItem } = {}; |
203 |
| - const props: { [id: string]: ApiItem } = {}; |
204 |
| - |
205 |
| - let allMeta = {}; |
206 |
| - try { |
207 |
| - allMeta = require(path.join(__dirname, "../temp/hpcc-js.meta.json")); |
208 |
| - } catch (e) { |
209 |
| - // File might not exit yet --- |
210 |
| - } |
211 |
| - |
212 |
| - function writeAttributes(struct: ApiItem, writer: IndentedWriter, isAttribute: boolean = true): boolean { |
213 |
| - let retVal = false; |
214 |
| - const structClass = struct as ApiClass; |
215 |
| - // writer.writeLine(struct.displayName); |
216 |
| - const baseClass = structs[structClass.extendsType?.excerpt?.text?.trim()]; |
217 |
| - if (baseClass) { |
218 |
| - retVal = writeAttributes(baseClass, writer, isAttribute); |
219 |
| - } |
220 |
| - const classMeta = allMeta[struct.displayName] ?? { observed: {} }; |
221 |
| - for (const prop of struct.members) { |
222 |
| - const propMeta = classMeta.observed[prop.displayName]; |
223 |
| - if ((prop as ApiProperty).tsdocComment) { |
224 |
| - if (propMeta === undefined || propMeta.isAttribute === isAttribute) { |
225 |
| - if (writeApiItem(prop, { writer }, false)) { |
226 |
| - retVal = true; |
227 |
| - } |
228 |
| - } |
229 |
| - } |
230 |
| - } |
231 |
| - return retVal; |
232 |
| - } |
233 |
| - |
234 |
| - md.core.ruler.before("normalize", "types", function replace(state) { |
235 |
| - const apiModel = new ApiModel(); |
236 |
| - let apiPackage; |
237 |
| - try { |
238 |
| - apiPackage = apiModel.loadPackage("./temp/hpcc-js.api.json"); |
239 |
| - } catch (e) { |
240 |
| - // File might not exit yet --- |
241 |
| - } |
242 |
| - |
243 |
| - apiPackage?.members.forEach(entyrPoint => { |
244 |
| - for (const struct of entyrPoint.members) { |
245 |
| - // if (struct.displayName.indexOf("HPCC") === 0 && struct.displayName.indexOf("Element") > 0) { |
246 |
| - structs[struct.displayName] = struct; |
247 |
| - for (const prop of struct.members) { |
248 |
| - props[struct.displayName + "." + prop.displayName] = prop; |
249 |
| - } |
250 |
| - // } |
251 |
| - } |
252 |
| - }); |
253 |
| - |
254 |
| - for (const key in structs) { |
255 |
| - const struct = structs[key]; |
256 |
| - const search = `## \`${key}\``; |
257 |
| - if (state.src.indexOf(search) >= 0) { |
258 |
| - let replacement = ""; |
259 |
| - const attrWriter = new IndentedWriter(); |
260 |
| - attrWriter.writeLine(`## Attributes`); |
261 |
| - attrWriter.writeLine(); |
262 |
| - if (writeAttributes(struct, attrWriter, true)) { |
263 |
| - replacement += attrWriter.toString(); |
264 |
| - } |
265 |
| - const propWriter = new IndentedWriter(); |
266 |
| - propWriter.writeLine(`## Properties`); |
267 |
| - propWriter.writeLine(); |
268 |
| - if (writeAttributes(struct, propWriter, false)) { |
269 |
| - replacement += propWriter.toString(); |
270 |
| - } |
271 |
| - state.src = state.src.split(search).join(replacement); |
272 |
| - } |
273 |
| - } |
274 |
| - |
275 |
| - for (const key in props) { |
276 |
| - const search = `### \`${key}\``; |
277 |
| - if (state.src.indexOf(search) >= 0) { |
278 |
| - const prop = props[key]; |
279 |
| - const writer = new IndentedWriter(); |
280 |
| - writeApiItem(prop, { writer }, false); |
281 |
| - state.src = state.src.split(search).join(writer.toString()); |
282 |
| - } |
283 |
| - } |
284 |
| - }); |
285 |
| - } |
286 |
| - } |
| 46 | + }); |
287 | 47 | };
|
0 commit comments