starlight-fsharp-oracle 0.1.0

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.
Files changed (89) hide show
  1. package/Directory.Build.props +25 -0
  2. package/Directory.Packages.props +18 -0
  3. package/README.md +80 -0
  4. package/dist/Extensions/StringBuilder.js +28 -0
  5. package/dist/Extensions/TextNode.js +115 -0
  6. package/dist/FSharp.Oracle.Schema/Schema.js +674 -0
  7. package/dist/Generate.js +254 -0
  8. package/dist/Helpers.js +69 -0
  9. package/dist/Plugin.js +139 -0
  10. package/dist/Render/Documentation.js +87 -0
  11. package/dist/Render/Entries.js +148 -0
  12. package/dist/Render/Pages.js +292 -0
  13. package/dist/Render/Primitives.js +114 -0
  14. package/dist/Render/Types.js +30 -0
  15. package/dist/Render.js +12 -0
  16. package/dist/Themes.js +78 -0
  17. package/oracle-bin/FSharp.Compiler.Service.dll +0 -0
  18. package/oracle-bin/FSharp.Core.dll +0 -0
  19. package/oracle-bin/FSharp.DependencyManager.Nuget.dll +0 -0
  20. package/oracle-bin/FSharp.Oracle.Schema.dll +0 -0
  21. package/oracle-bin/FSharp.Oracle.Schema.pdb +0 -0
  22. package/oracle-bin/FSharp.Oracle.Schema.xml +219 -0
  23. package/oracle-bin/Fable.Core.dll +0 -0
  24. package/oracle-bin/Oracle +0 -0
  25. package/oracle-bin/Oracle.deps.json +280 -0
  26. package/oracle-bin/Oracle.dll +0 -0
  27. package/oracle-bin/Oracle.pdb +0 -0
  28. package/oracle-bin/Oracle.runtimeconfig.json +13 -0
  29. package/oracle-bin/Oracle.xml +111 -0
  30. package/oracle-bin/Thoth.Json.Core.Auto.dll +0 -0
  31. package/oracle-bin/Thoth.Json.Core.dll +0 -0
  32. package/oracle-bin/Thoth.Json.System.Text.Json.dll +0 -0
  33. package/oracle-bin/cs/FSharp.Compiler.Service.resources.dll +0 -0
  34. package/oracle-bin/cs/FSharp.Core.resources.dll +0 -0
  35. package/oracle-bin/cs/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  36. package/oracle-bin/de/FSharp.Compiler.Service.resources.dll +0 -0
  37. package/oracle-bin/de/FSharp.Core.resources.dll +0 -0
  38. package/oracle-bin/de/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  39. package/oracle-bin/es/FSharp.Compiler.Service.resources.dll +0 -0
  40. package/oracle-bin/es/FSharp.Core.resources.dll +0 -0
  41. package/oracle-bin/es/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  42. package/oracle-bin/fr/FSharp.Compiler.Service.resources.dll +0 -0
  43. package/oracle-bin/fr/FSharp.Core.resources.dll +0 -0
  44. package/oracle-bin/fr/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  45. package/oracle-bin/it/FSharp.Compiler.Service.resources.dll +0 -0
  46. package/oracle-bin/it/FSharp.Core.resources.dll +0 -0
  47. package/oracle-bin/it/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  48. package/oracle-bin/ja/FSharp.Compiler.Service.resources.dll +0 -0
  49. package/oracle-bin/ja/FSharp.Core.resources.dll +0 -0
  50. package/oracle-bin/ja/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  51. package/oracle-bin/ko/FSharp.Compiler.Service.resources.dll +0 -0
  52. package/oracle-bin/ko/FSharp.Core.resources.dll +0 -0
  53. package/oracle-bin/ko/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  54. package/oracle-bin/pl/FSharp.Compiler.Service.resources.dll +0 -0
  55. package/oracle-bin/pl/FSharp.Core.resources.dll +0 -0
  56. package/oracle-bin/pl/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  57. package/oracle-bin/pt-BR/FSharp.Compiler.Service.resources.dll +0 -0
  58. package/oracle-bin/pt-BR/FSharp.Core.resources.dll +0 -0
  59. package/oracle-bin/pt-BR/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  60. package/oracle-bin/ru/FSharp.Compiler.Service.resources.dll +0 -0
  61. package/oracle-bin/ru/FSharp.Core.resources.dll +0 -0
  62. package/oracle-bin/ru/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  63. package/oracle-bin/tr/FSharp.Compiler.Service.resources.dll +0 -0
  64. package/oracle-bin/tr/FSharp.Core.resources.dll +0 -0
  65. package/oracle-bin/tr/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  66. package/oracle-bin/zh-Hans/FSharp.Compiler.Service.resources.dll +0 -0
  67. package/oracle-bin/zh-Hans/FSharp.Core.resources.dll +0 -0
  68. package/oracle-bin/zh-Hans/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  69. package/oracle-bin/zh-Hant/FSharp.Compiler.Service.resources.dll +0 -0
  70. package/oracle-bin/zh-Hant/FSharp.Core.resources.dll +0 -0
  71. package/oracle-bin/zh-Hant/FSharp.DependencyManager.Nuget.resources.dll +0 -0
  72. package/package.json +38 -0
  73. package/packages/FSharp.Oracle/Extractor/Assembly.fs +160 -0
  74. package/packages/FSharp.Oracle/Extractor/EntityExtractor.fs +608 -0
  75. package/packages/FSharp.Oracle/Extractor/Helpers.fs +150 -0
  76. package/packages/FSharp.Oracle/Extractor/MemberExtractor.fs +172 -0
  77. package/packages/FSharp.Oracle/Extractor/ModuleExtractor.fs +45 -0
  78. package/packages/FSharp.Oracle/Extractor/ParameterExtractor.fs +47 -0
  79. package/packages/FSharp.Oracle/Extractor/SignatureRendering.fs +464 -0
  80. package/packages/FSharp.Oracle/Extractor/ValueExtractor.fs +171 -0
  81. package/packages/FSharp.Oracle/FSharp.Oracle.fsproj +36 -0
  82. package/packages/FSharp.Oracle/Program.fs +66 -0
  83. package/packages/FSharp.Oracle/XmlDoc.fs +463 -0
  84. package/packages/FSharp.Oracle.Schema/FSharp.Oracle.Schema.fsproj +16 -0
  85. package/packages/FSharp.Oracle.Schema/Schema.fs +454 -0
  86. package/packages/Starlight.FSharp.Oracle/components/DocEntry.astro +256 -0
  87. package/packages/Starlight.FSharp.Oracle/components/FSharpDocPage.astro +121 -0
  88. package/packages/Starlight.FSharp.Oracle/components/fsharp-doc.css +58 -0
  89. package/packages/Starlight.FSharp.Oracle/layouts/FSharpDocLayout.astro +27 -0
@@ -0,0 +1,254 @@
1
+
2
+ import { join, concat, split, substring, replace } from "./fable_modules/fable-library-js.5.0.0-rc.7/String.js";
3
+ import { cons, append, toArray, exists, isEmpty, map, filter, ofArray, collect, sort } from "./fable_modules/fable-library-js.5.0.0-rc.7/List.js";
4
+ import { List_distinct } from "./fable_modules/fable-library-js.5.0.0-rc.7/Seq2.js";
5
+ import { scan, tail } from "./fable_modules/fable-library-js.5.0.0-rc.7/Array.js";
6
+ import { curry2, comparePrimitives, stringHash } from "./fable_modules/fable-library-js.5.0.0-rc.7/Util.js";
7
+ import { renderRootIndexPage, renderEntityPage, renderModulePage, renderNamespacePage } from "./Render.js";
8
+ import { singleton, append as append_1, map as map_1, collect as collect_1, delay, toList } from "./fable_modules/fable-library-js.5.0.0-rc.7/Seq.js";
9
+ import { Entity__get_Name, Entity__get_FullName } from "./FSharp.Oracle.Schema/Schema.js";
10
+
11
+ function toSlug(name) {
12
+ const sanitized = replace(name.toLowerCase(), ".", "-");
13
+ const backtickIdx = sanitized.lastIndexOf("`") | 0;
14
+ if (backtickIdx >= 0) {
15
+ return substring(sanitized, 0, backtickIdx);
16
+ }
17
+ else {
18
+ return sanitized;
19
+ }
20
+ }
21
+
22
+ function expandNamespaces(namespaces) {
23
+ return sort(List_distinct(collect((ns) => {
24
+ const parts = split(ns, ["."], undefined, 0);
25
+ return ofArray(tail(scan((acc, part) => {
26
+ if (acc === "") {
27
+ return part;
28
+ }
29
+ else {
30
+ return concat(acc, ".", ...part);
31
+ }
32
+ }, "", parts)));
33
+ }, namespaces), {
34
+ Equals: (x, y) => (x === y),
35
+ GetHashCode: (x) => (stringHash(x) | 0),
36
+ }), {
37
+ Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
38
+ });
39
+ }
40
+
41
+ function namespacesOf(modules) {
42
+ return expandNamespaces(List_distinct(filter((ns) => (ns !== ""), map((m_1) => m_1.Namespace, filter((m) => !m.IsSynthetic, modules))), {
43
+ Equals: (x, y) => (x === y),
44
+ GetHashCode: (x) => (stringHash(x) | 0),
45
+ }));
46
+ }
47
+
48
+ function escapeYaml(s) {
49
+ return replace(replace(replace(replace(s, "\\", "\\\\"), "\"", "\\\""), "\n", "\\n"), "\r", "");
50
+ }
51
+
52
+ function toMdxPage(page) {
53
+ let headingsSection;
54
+ if (isEmpty(page.TocEntries)) {
55
+ headingsSection = "headings: []";
56
+ }
57
+ else {
58
+ const entries = join("\n", map((e) => (` - depth: ${e.Depth}
59
+ slug: "${escapeYaml(e.Slug)}"
60
+ text: "${escapeYaml(e.Text)}"`), page.TocEntries));
61
+ headingsSection = ("headings:\n" + entries);
62
+ }
63
+ return `---
64
+ layout: 'starlight-fsharp-oracle/layouts/FSharpDocLayout.astro'
65
+ title: "${escapeYaml(page.Title)}"
66
+ ${headingsSection}
67
+ ---
68
+
69
+ import DocEntry from 'starlight-fsharp-oracle/components/DocEntry.astro';
70
+ import { Aside } from '@astrojs/starlight/components';
71
+
72
+ ${page.TemplateBody}`;
73
+ }
74
+
75
+ export function namespacePages(outputBase, modules) {
76
+ const realModules = filter((m) => !m.IsSynthetic, modules);
77
+ const allNamespaces = namespacesOf(modules);
78
+ const htmlLinkGen = (name, fullName) => (`<a href="/${outputBase}/${toSlug(fullName)}">${name}</a>`);
79
+ const directChildNamespaces = (ns) => filter((other) => {
80
+ if (other.startsWith(ns + ".") && !(other.slice(ns.length + 1, other.length).indexOf(".") >= 0)) {
81
+ return !exists((m_1) => (m_1.FullName === other), realModules);
82
+ }
83
+ else {
84
+ return false;
85
+ }
86
+ }, allNamespaces);
87
+ const syntheticModules = filter((m_2) => m_2.IsSynthetic, modules);
88
+ return map((ns_1) => {
89
+ const slug = toSlug(ns_1);
90
+ const modulesInNs = filter((m_3) => (m_3.Namespace === ns_1), realModules);
91
+ const subNamespaces = directChildNamespaces(ns_1);
92
+ const entitiesInNs = collect((m_5) => m_5.Entities, filter((m_4) => (m_4.Namespace === ns_1), syntheticModules));
93
+ return [slug, toMdxPage(renderNamespacePage(curry2(htmlLinkGen))(ns_1)(subNamespaces)(entitiesInNs)(modulesInNs))];
94
+ }, allNamespaces);
95
+ }
96
+
97
+ export function modulePages(outputBase, modules) {
98
+ const realModules = filter((m) => !m.IsSynthetic, modules);
99
+ const htmlLinkGen = (name, fullName) => (`<a href="/${outputBase}/${toSlug(fullName)}">${name}</a>`);
100
+ return map((m_1) => {
101
+ const subModules = filter((other) => (other.Namespace === m_1.FullName), realModules);
102
+ return [toSlug(m_1.FullName), toMdxPage(renderModulePage(curry2(htmlLinkGen))(m_1)(subModules))];
103
+ }, realModules);
104
+ }
105
+
106
+ export function entityPages(outputBase, modules) {
107
+ const htmlLinkGen = (name, fullName) => (`<a href="/${outputBase}/${toSlug(fullName)}">${name}</a>`);
108
+ return toList(delay(() => collect_1((m) => map_1((e) => [toSlug(Entity__get_FullName(e)), toMdxPage(renderEntityPage(curry2(htmlLinkGen))(e)(m))], m.Entities), modules)));
109
+ }
110
+
111
+ export function rootIndexPage(outputBase, assemblies, modules) {
112
+ const htmlLinkGen = (name, fullName) => (`<a href="/${outputBase}/${toSlug(fullName)}">${name}</a>`);
113
+ const globalModules = filter((m) => {
114
+ if (!m.IsSynthetic) {
115
+ return m.Namespace === "";
116
+ }
117
+ else {
118
+ return false;
119
+ }
120
+ }, modules);
121
+ return ["index", toMdxPage(renderRootIndexPage(curry2(htmlLinkGen))(assemblies)(globalModules))];
122
+ }
123
+
124
+ function sidebarLink(outputBase, label, fullName, letter, kind) {
125
+ return {
126
+ label: label,
127
+ link: concat("/", outputBase, "/", ...toSlug(fullName)),
128
+ };
129
+ }
130
+
131
+ function sidebarGroup(label, letter, kind, items) {
132
+ return {
133
+ label: label,
134
+ items: toArray(items),
135
+ collapsed: true,
136
+ };
137
+ }
138
+
139
+ function entityLetterAndKind(entity) {
140
+ switch (entity.tag) {
141
+ case 1:
142
+ return ["U", "union"];
143
+ case 3:
144
+ return ["C", "class"];
145
+ case 4:
146
+ return ["I", "interface"];
147
+ case 2:
148
+ return ["A", "abbrev"];
149
+ case 5:
150
+ return ["E", "enum"];
151
+ case 6:
152
+ return ["M", "measure"];
153
+ case 7:
154
+ return ["X", "exception"];
155
+ case 8:
156
+ return ["D", "delegate"];
157
+ default:
158
+ return ["R", "record"];
159
+ }
160
+ }
161
+
162
+ function entitySidebarItem(outputBase, entity) {
163
+ const patternInput = entityLetterAndKind(entity);
164
+ const letter = patternInput[0];
165
+ const kind = patternInput[1];
166
+ return {
167
+ label: Entity__get_Name(entity),
168
+ link: concat("/", outputBase, "/", ...toSlug(Entity__get_FullName(entity))),
169
+ };
170
+ }
171
+
172
+ /**
173
+ * Returns a Starlight sidebar group with a full hierarchy:
174
+ * namespaces → modules → entities.
175
+ */
176
+ export function sidebarTree(outputBase, label, modules) {
177
+ const realModules = filter((m) => !m.IsSynthetic, modules);
178
+ const syntheticModules = filter((m_1) => m_1.IsSynthetic, modules);
179
+ const allNamespaces = namespacesOf(modules);
180
+ const moduleHref = (m_2) => concat("/", outputBase, "/", ...toSlug(m_2.FullName));
181
+ const anchorLink = (label_1, href) => ({
182
+ label: label_1,
183
+ link: href,
184
+ });
185
+ const moduleSidebarItem = (m_3) => {
186
+ const subModules = filter((other) => (other.Namespace === m_3.FullName), realModules);
187
+ const overviewLink = {
188
+ label: "Overview",
189
+ link: moduleHref(m_3),
190
+ };
191
+ const entityItems = map((entity) => entitySidebarItem(outputBase, entity), m_3.Entities);
192
+ const functionItems = map((f) => anchorLink(f.Name, concat(moduleHref(m_3), "#", ...f.Name)), m_3.Functions);
193
+ const valueItems = map((v) => anchorLink(v.Name, concat(moduleHref(m_3), "#", ...v.Name)), m_3.Values);
194
+ const subModuleItems = map(moduleSidebarItem, subModules);
195
+ const children = append(cons(overviewLink, entityItems), append(functionItems, append(valueItems, subModuleItems)));
196
+ return sidebarGroup(m_3.Name, "M", "module", children);
197
+ };
198
+ const buildNsGroup = (ns) => {
199
+ let shortName;
200
+ const lastDot = ns.lastIndexOf(".") | 0;
201
+ shortName = ((lastDot < 0) ? ns : ns.slice(lastDot + 1, ns.length));
202
+ const directChildNs = filter((other_1) => {
203
+ if (other_1.startsWith(ns + ".") && !(other_1.slice(ns.length + 1, other_1.length).indexOf(".") >= 0)) {
204
+ return !exists((m_4) => (m_4.FullName === other_1), realModules);
205
+ }
206
+ else {
207
+ return false;
208
+ }
209
+ }, allNamespaces);
210
+ const modulesInNs = filter((m_5) => (m_5.Namespace === ns), realModules);
211
+ const syntheticInNs = filter((m_6) => (m_6.Namespace === ns), syntheticModules);
212
+ const items = toList(delay(() => append_1(map(moduleSidebarItem, modulesInNs), delay(() => append_1(collect_1((sm) => {
213
+ if (sm.Name === "global") {
214
+ return map((entity_1) => entitySidebarItem(outputBase, entity_1), sm.Entities);
215
+ }
216
+ else {
217
+ let smShortName;
218
+ const lastDot_1 = sm.FullName.lastIndexOf(".") | 0;
219
+ smShortName = ((lastDot_1 < 0) ? sm.FullName : sm.FullName.slice(lastDot_1 + 1, sm.FullName.length));
220
+ return singleton(sidebarGroup(smShortName, "N", "namespace", map((entity_2) => entitySidebarItem(outputBase, entity_2), sm.Entities)));
221
+ }
222
+ }, syntheticInNs), delay(() => map(buildNsGroup, directChildNs)))))));
223
+ return sidebarGroup(shortName, "N", "namespace", items);
224
+ };
225
+ const topLevelNs = filter((ns_1) => {
226
+ if (!exists((other_2) => ns_1.startsWith(other_2 + "."), allNamespaces)) {
227
+ return !exists((m_7) => (m_7.FullName === ns_1), realModules);
228
+ }
229
+ else {
230
+ return false;
231
+ }
232
+ }, allNamespaces);
233
+ const globalModules = filter((m_8) => (m_8.Namespace === ""), realModules);
234
+ const overviewLink_1 = {
235
+ label: "Overview",
236
+ link: concat("/", ...outputBase),
237
+ };
238
+ const items_1 = toList(delay(() => append_1(singleton(overviewLink_1), delay(() => append_1(map(moduleSidebarItem, globalModules), delay(() => map(buildNsGroup, topLevelNs)))))));
239
+ return {
240
+ label: label,
241
+ items: toArray(items_1),
242
+ };
243
+ }
244
+
245
+ /**
246
+ * Returns a tiny inline script that publishes the sidebar label so that
247
+ * the external sidebar-controls.js file can find the right section without
248
+ * needing any F#-generated JS logic.
249
+ */
250
+ export function sidebarLabelInitScript(sidebarLabel) {
251
+ const escaped = replace(replace(sidebarLabel, "\\", "\\\\"), "\'", "\\\'");
252
+ return concat("window.__fsharpSidebarLabel = \'", escaped, ..."\';");
253
+ }
254
+
@@ -0,0 +1,69 @@
1
+
2
+ import { Union } from "./fable_modules/fable-library-js.5.0.0-rc.7/Types.js";
3
+ import { union_type, string_type } from "./fable_modules/fable-library-js.5.0.0-rc.7/Reflection.js";
4
+ import { concat } from "./fable_modules/fable-library-js.5.0.0-rc.7/String.js";
5
+ import * as fs from "fs";
6
+ import { some } from "./fable_modules/fable-library-js.5.0.0-rc.7/Option.js";
7
+ import { choose } from "./fable_modules/fable-library-js.5.0.0-rc.7/List.js";
8
+
9
+ /**
10
+ * Result type for file operations
11
+ */
12
+ export class FileOperationResult$1 extends Union {
13
+ constructor(tag, fields) {
14
+ super();
15
+ this.tag = tag;
16
+ this.fields = fields;
17
+ }
18
+ cases() {
19
+ return ["Ok", "Error"];
20
+ }
21
+ }
22
+
23
+ export function FileOperationResult$1_$reflection(gen0) {
24
+ return union_type("Starlight.FSharp.Helpers.FileOperationResult`1", [gen0], FileOperationResult$1, () => [[["Item", gen0]], [["Item", string_type]]]);
25
+ }
26
+
27
+ /**
28
+ * Wraps fs.writeFileSync with error handling
29
+ */
30
+ export function writeSync(path, content) {
31
+ try {
32
+ fs.writeFileSync(path, content, some("utf-8"));
33
+ return new FileOperationResult$1(0, [undefined]);
34
+ }
35
+ catch (ex) {
36
+ return new FileOperationResult$1(1, [concat("Failed to write file \'", path, "\': ", ...ex.message)]);
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Wraps fs.mkdirSync with error handling
42
+ */
43
+ export function mkdirSync(path) {
44
+ try {
45
+ fs.mkdirSync(path, {
46
+ recursive: true,
47
+ });
48
+ return new FileOperationResult$1(0, [undefined]);
49
+ }
50
+ catch (ex) {
51
+ return new FileOperationResult$1(1, [concat("Failed to create directory \'", path, "\': ", ...ex.message)]);
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Collects all errors from a list of results
57
+ */
58
+ export function collectErrors(results) {
59
+ return choose((_arg) => {
60
+ if (_arg.tag === 0) {
61
+ return undefined;
62
+ }
63
+ else {
64
+ const msg = _arg.fields[0];
65
+ return msg;
66
+ }
67
+ }, results);
68
+ }
69
+
package/dist/Plugin.js ADDED
@@ -0,0 +1,139 @@
1
+
2
+ import * as path from "path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { toArray, singleton, append, delay, toList } from "./fable_modules/fable-library-js.5.0.0-rc.7/Seq.js";
5
+ import * as child_process from "child_process";
6
+ import { map, defaultArg, some } from "./fable_modules/fable-library-js.5.0.0-rc.7/Option.js";
7
+ import { stringHash, Exception } from "./fable_modules/fable-library-js.5.0.0-rc.7/Util.js";
8
+ import { join, concat, interpolate } from "./fable_modules/fable-library-js.5.0.0-rc.7/String.js";
9
+ import { Extra_empty } from "./fable_modules/Thoth.Json.Core.Auto.0.1.0/Domain.fs.js";
10
+ import { Root_$reflection } from "./FSharp.Oracle.Schema/Schema.js";
11
+ import { generateDecoder } from "./fable_modules/Thoth.Json.Core.Auto.0.1.0/Decode.fs.js";
12
+ import { unsafeFromString } from "./fable_modules/Thoth.Json.JavaScript.0.5.0/Decode.fs.js";
13
+ import { PromiseBuilder__Delay_62FBFDE1, PromiseBuilder__Run_212F1D4B } from "./fable_modules/Fable.Promise.3.2.0/Promise.fs.js";
14
+ import { promise } from "./fable_modules/Fable.Promise.3.2.0/PromiseImpl.fs.js";
15
+ import { createRenderer } from "astro-expressive-code";
16
+ import { generateCss } from "./Themes.js";
17
+ import { length, isEmpty, contains, filter, map as map_1, collect } from "./fable_modules/fable-library-js.5.0.0-rc.7/List.js";
18
+ import { entityPages, rootIndexPage, namespacePages as namespacePages_1, modulePages as modulePages_1, sidebarTree, sidebarLabelInitScript } from "./Generate.js";
19
+ import { collectErrors, FileOperationResult$1, writeSync, mkdirSync } from "./Helpers.js";
20
+
21
+ function runExtractor(logger, outputBase, dllPaths) {
22
+ const maxBuffer = ((50 * 1024) * 1024) | 0;
23
+ const oracleProject = path.join(path.dirname(fileURLToPath(import.meta.url)), "..", "packages", "FSharp.Oracle");
24
+ const args = toList(delay(() => append(singleton("run"), delay(() => append(singleton("--project"), delay(() => append(singleton(oracleProject), delay(() => append(singleton("--"), delay(() => append(singleton("--output-base"), delay(() => append(singleton(outputBase), delay(() => dllPaths))))))))))))));
25
+ const result = child_process.spawnSync("dotnet", Array.from(args), some({
26
+ encoding: "utf-8",
27
+ maxBuffer: maxBuffer,
28
+ }));
29
+ if (result.error) {
30
+ throw result.error;
31
+ }
32
+ else if (result.status !== 0) {
33
+ throw new Exception(`F# docs extractor failed (exit ${result.status}):
34
+ ${interpolate("%A%P()", [result.stderr])}`);
35
+ }
36
+ else {
37
+ const json = result.stdout;
38
+ let decoder_1;
39
+ const extra_1 = Extra_empty;
40
+ const losslessOption_1 = true;
41
+ const ty = Root_$reflection();
42
+ const decoder = generateDecoder(undefined, extra_1.DecoderOverrides, false, losslessOption_1, ty);
43
+ decoder_1 = decoder;
44
+ return unsafeFromString(decoder_1, json);
45
+ }
46
+ }
47
+
48
+ function starlightFSharpDoc(pluginOptions) {
49
+ return {
50
+ hooks: {
51
+ "config:setup": (hookOptions) => PromiseBuilder__Run_212F1D4B(promise, PromiseBuilder__Delay_62FBFDE1(promise, () => {
52
+ const logger = hookOptions.logger;
53
+ const astroConfig = hookOptions.astroConfig;
54
+ const command = hookOptions.command;
55
+ switch (command) {
56
+ case "dev":
57
+ case "build":
58
+ case "sync": {
59
+ logger.info("Extracting F# API docs...");
60
+ let updateConfig;
61
+ const clo = hookOptions.updateConfig;
62
+ updateConfig = ((arg) => {
63
+ clo(arg);
64
+ });
65
+ return createRenderer({}).then((_arg) => {
66
+ let matchValue, matchValue_1, msg_1, msg;
67
+ const ecRenderer = _arg;
68
+ const themesCss = generateCss(ecRenderer);
69
+ const outputBase = defaultArg(pluginOptions.output, "api");
70
+ const root = runExtractor(logger, outputBase, toList(pluginOptions.assemblies));
71
+ const modules = collect((_arg_1) => _arg_1.Modules, root.Assemblies);
72
+ const sidebarLabel = defaultArg(map((s) => s.label, pluginOptions.sidebar), "API Reference");
73
+ const existingSidebar = defaultArg(hookOptions.config.sidebar, []);
74
+ updateConfig({
75
+ head: [{
76
+ content: themesCss,
77
+ tag: "style",
78
+ }, {
79
+ content: sidebarLabelInitScript(sidebarLabel),
80
+ tag: "script",
81
+ }],
82
+ sidebar: toArray(delay(() => append(existingSidebar, delay(() => singleton(sidebarTree(outputBase, sidebarLabel, modules)))))),
83
+ });
84
+ const outputDir = path.join(astroConfig.root.pathname, "src", "pages", outputBase);
85
+ return ((matchValue = mkdirSync(outputDir), (matchValue.tag === 0) ? ((matchValue_1 = writeSync(path.join(outputDir, ".gitignore"), "# Autogenerated by starlight-fsharp-oracle\n**/*\n"), (matchValue_1.tag === 0) ? (Promise.resolve()) : ((msg_1 = matchValue_1.fields[0], (logger.warn(concat("Failed to write .gitignore: ", ...msg_1)), Promise.resolve()))))) : ((msg = matchValue.fields[0], (logger.error(msg), ((() => {
86
+ throw new Exception(msg);
87
+ })(), Promise.resolve())))))).then(() => PromiseBuilder__Delay_62FBFDE1(promise, () => {
88
+ const modulePages = modulePages_1(outputBase, modules);
89
+ const namespacePages = namespacePages_1(outputBase, modules);
90
+ const moduleSlugs = map_1((tuple) => tuple[0], modulePages);
91
+ const dedupedNamespacePages = filter((tupledArg) => {
92
+ const slug = tupledArg[0];
93
+ return !contains(slug, moduleSlugs, {
94
+ Equals: (x, y) => (x === y),
95
+ GetHashCode: (x) => (stringHash(x) | 0),
96
+ });
97
+ }, namespacePages);
98
+ const pages = toList(delay(() => append(singleton(rootIndexPage(outputBase, root.Assemblies, modules)), delay(() => append(dedupedNamespacePages, delay(() => append(modulePages, delay(() => entityPages(outputBase, modules)))))))));
99
+ const writeResults = map_1((tupledArg_1) => {
100
+ const slug_1 = tupledArg_1[0];
101
+ const content = tupledArg_1[1];
102
+ const filePath = path.join(outputDir, slug_1 + ".mdx");
103
+ const matchValue_2 = writeSync(filePath, content);
104
+ if (matchValue_2.tag === 0) {
105
+ logger.info(concat(" wrote ", ...filePath));
106
+ return new FileOperationResult$1(0, [undefined]);
107
+ }
108
+ else {
109
+ const msg_2 = matchValue_2.fields[0];
110
+ logger.error(msg_2);
111
+ return new FileOperationResult$1(1, [msg_2]);
112
+ }
113
+ }, pages);
114
+ const errors = collectErrors(writeResults);
115
+ if (!isEmpty(errors)) {
116
+ const errorMsg = (`Failed to write ${length(errors)} file(s):
117
+ `) + join("\n", errors);
118
+ logger.error(errorMsg);
119
+ throw new Exception(errorMsg);
120
+ return Promise.resolve();
121
+ }
122
+ else {
123
+ return Promise.resolve();
124
+ }
125
+ }));
126
+ });
127
+ }
128
+ default: {
129
+ return Promise.resolve();
130
+ }
131
+ }
132
+ })),
133
+ },
134
+ name: "starlight-fsharp-oracle",
135
+ };
136
+ }
137
+
138
+ export default (starlightFSharpDoc);
139
+
@@ -0,0 +1,87 @@
1
+
2
+ import { System_Text_StringBuilder__StringBuilder_NewLine, System_Text_StringBuilder__StringBuilder_WriteLine_Z721C83C5 } from "../Extensions/StringBuilder.js";
3
+ import { h2, renderExamples, escapeMdxText } from "./Primitives.js";
4
+ import { iterate } from "../fable_modules/fable-library-js.5.0.0-rc.7/Seq.js";
5
+ import { toArray } from "../fable_modules/fable-library-js.5.0.0-rc.7/Option.js";
6
+ import { ofArray, tryFind, collect, isEmpty } from "../fable_modules/fable-library-js.5.0.0-rc.7/List.js";
7
+ import { disposeSafe, getEnumerator } from "../fable_modules/fable-library-js.5.0.0-rc.7/Util.js";
8
+ import { FSharp_Oracle_Schema_TextNode__TextNode_ToHtml_Static_Z3A0E64B3, FSharp_Oracle_Schema_TextNode__TextNode_get_Html } from "../Extensions/TextNode.js";
9
+ import { TextNode } from "../FSharp.Oracle.Schema/Schema.js";
10
+
11
+ export function renderSummary(sb, xmlDoc) {
12
+ const matchValue = xmlDoc.Summary;
13
+ if (matchValue == null) {
14
+ }
15
+ else {
16
+ const summary = matchValue;
17
+ System_Text_StringBuilder__StringBuilder_WriteLine_Z721C83C5(sb, escapeMdxText(summary));
18
+ System_Text_StringBuilder__StringBuilder_NewLine(sb);
19
+ }
20
+ }
21
+
22
+ /**
23
+ * Renders summary + optional extra content + examples.
24
+ * Used by all DocEntry documentation closures for consistency.
25
+ */
26
+ export function renderDocumentationBlock(sb, xmlDoc, renderExtra) {
27
+ renderSummary(sb, xmlDoc);
28
+ renderExtra();
29
+ renderExamples(sb, xmlDoc.Examples);
30
+ }
31
+
32
+ export function renderXmlDocSummaryAndRemarks(sb, toc, xmlDoc) {
33
+ iterate((summary) => {
34
+ h2(sb, toc, "description", "Description");
35
+ System_Text_StringBuilder__StringBuilder_WriteLine_Z721C83C5(sb, escapeMdxText(summary));
36
+ System_Text_StringBuilder__StringBuilder_NewLine(sb);
37
+ }, toArray(xmlDoc.Summary));
38
+ iterate((remarks) => {
39
+ System_Text_StringBuilder__StringBuilder_WriteLine_Z721C83C5(sb, escapeMdxText(remarks));
40
+ System_Text_StringBuilder__StringBuilder_NewLine(sb);
41
+ }, toArray(xmlDoc.Remarks));
42
+ }
43
+
44
+ function renderParamsAndReturns(sb, parameters, xmlDoc) {
45
+ if (!isEmpty(xmlDoc.Params)) {
46
+ System_Text_StringBuilder__StringBuilder_WriteLine_Z721C83C5(sb, "<strong>Parameters</strong>");
47
+ const enumerator = getEnumerator(collect((x) => x, parameters));
48
+ try {
49
+ while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
50
+ const parameter = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
51
+ const paramDoc = tryFind((p) => (p.Name === parameter.Name), xmlDoc.Params);
52
+ if (paramDoc == null) {
53
+ System_Text_StringBuilder__StringBuilder_WriteLine_Z721C83C5(sb, FSharp_Oracle_Schema_TextNode__TextNode_get_Html(parameter.Declaration));
54
+ }
55
+ else {
56
+ const paramDoc_1 = paramDoc;
57
+ System_Text_StringBuilder__StringBuilder_WriteLine_Z721C83C5(sb, FSharp_Oracle_Schema_TextNode__TextNode_ToHtml_Static_Z3A0E64B3(ofArray([new TextNode(23, ["div", "fs-parameter__signature"]), new TextNode(20, []), parameter.Declaration, new TextNode(20, []), new TextNode(22, ["div"]), new TextNode(20, [])])));
58
+ System_Text_StringBuilder__StringBuilder_WriteLine_Z721C83C5(sb, "<div class=\'fs-parameter__documentation\'>");
59
+ System_Text_StringBuilder__StringBuilder_NewLine(sb);
60
+ System_Text_StringBuilder__StringBuilder_WriteLine_Z721C83C5(sb, escapeMdxText(paramDoc_1.Doc));
61
+ System_Text_StringBuilder__StringBuilder_NewLine(sb);
62
+ System_Text_StringBuilder__StringBuilder_WriteLine_Z721C83C5(sb, "</div>");
63
+ }
64
+ }
65
+ }
66
+ finally {
67
+ disposeSafe(enumerator);
68
+ }
69
+ }
70
+ const matchValue = xmlDoc.Returns;
71
+ if (matchValue == null) {
72
+ }
73
+ else {
74
+ const returnDoc = matchValue;
75
+ System_Text_StringBuilder__StringBuilder_WriteLine_Z721C83C5(sb, "<strong>Returns</strong>");
76
+ System_Text_StringBuilder__StringBuilder_NewLine(sb);
77
+ System_Text_StringBuilder__StringBuilder_WriteLine_Z721C83C5(sb, escapeMdxText(returnDoc));
78
+ System_Text_StringBuilder__StringBuilder_NewLine(sb);
79
+ }
80
+ }
81
+
82
+ export function renderXmlDocBody(sb, parameters, xmlDoc) {
83
+ renderDocumentationBlock(sb, xmlDoc, () => {
84
+ renderParamsAndReturns(sb, parameters, xmlDoc);
85
+ });
86
+ }
87
+