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.
- package/Directory.Build.props +25 -0
- package/Directory.Packages.props +18 -0
- package/README.md +80 -0
- package/dist/Extensions/StringBuilder.js +28 -0
- package/dist/Extensions/TextNode.js +115 -0
- package/dist/FSharp.Oracle.Schema/Schema.js +674 -0
- package/dist/Generate.js +254 -0
- package/dist/Helpers.js +69 -0
- package/dist/Plugin.js +139 -0
- package/dist/Render/Documentation.js +87 -0
- package/dist/Render/Entries.js +148 -0
- package/dist/Render/Pages.js +292 -0
- package/dist/Render/Primitives.js +114 -0
- package/dist/Render/Types.js +30 -0
- package/dist/Render.js +12 -0
- package/dist/Themes.js +78 -0
- package/oracle-bin/FSharp.Compiler.Service.dll +0 -0
- package/oracle-bin/FSharp.Core.dll +0 -0
- package/oracle-bin/FSharp.DependencyManager.Nuget.dll +0 -0
- package/oracle-bin/FSharp.Oracle.Schema.dll +0 -0
- package/oracle-bin/FSharp.Oracle.Schema.pdb +0 -0
- package/oracle-bin/FSharp.Oracle.Schema.xml +219 -0
- package/oracle-bin/Fable.Core.dll +0 -0
- package/oracle-bin/Oracle +0 -0
- package/oracle-bin/Oracle.deps.json +280 -0
- package/oracle-bin/Oracle.dll +0 -0
- package/oracle-bin/Oracle.pdb +0 -0
- package/oracle-bin/Oracle.runtimeconfig.json +13 -0
- package/oracle-bin/Oracle.xml +111 -0
- package/oracle-bin/Thoth.Json.Core.Auto.dll +0 -0
- package/oracle-bin/Thoth.Json.Core.dll +0 -0
- package/oracle-bin/Thoth.Json.System.Text.Json.dll +0 -0
- package/oracle-bin/cs/FSharp.Compiler.Service.resources.dll +0 -0
- package/oracle-bin/cs/FSharp.Core.resources.dll +0 -0
- package/oracle-bin/cs/FSharp.DependencyManager.Nuget.resources.dll +0 -0
- package/oracle-bin/de/FSharp.Compiler.Service.resources.dll +0 -0
- package/oracle-bin/de/FSharp.Core.resources.dll +0 -0
- package/oracle-bin/de/FSharp.DependencyManager.Nuget.resources.dll +0 -0
- package/oracle-bin/es/FSharp.Compiler.Service.resources.dll +0 -0
- package/oracle-bin/es/FSharp.Core.resources.dll +0 -0
- package/oracle-bin/es/FSharp.DependencyManager.Nuget.resources.dll +0 -0
- package/oracle-bin/fr/FSharp.Compiler.Service.resources.dll +0 -0
- package/oracle-bin/fr/FSharp.Core.resources.dll +0 -0
- package/oracle-bin/fr/FSharp.DependencyManager.Nuget.resources.dll +0 -0
- package/oracle-bin/it/FSharp.Compiler.Service.resources.dll +0 -0
- package/oracle-bin/it/FSharp.Core.resources.dll +0 -0
- package/oracle-bin/it/FSharp.DependencyManager.Nuget.resources.dll +0 -0
- package/oracle-bin/ja/FSharp.Compiler.Service.resources.dll +0 -0
- package/oracle-bin/ja/FSharp.Core.resources.dll +0 -0
- package/oracle-bin/ja/FSharp.DependencyManager.Nuget.resources.dll +0 -0
- package/oracle-bin/ko/FSharp.Compiler.Service.resources.dll +0 -0
- package/oracle-bin/ko/FSharp.Core.resources.dll +0 -0
- package/oracle-bin/ko/FSharp.DependencyManager.Nuget.resources.dll +0 -0
- package/oracle-bin/pl/FSharp.Compiler.Service.resources.dll +0 -0
- package/oracle-bin/pl/FSharp.Core.resources.dll +0 -0
- package/oracle-bin/pl/FSharp.DependencyManager.Nuget.resources.dll +0 -0
- package/oracle-bin/pt-BR/FSharp.Compiler.Service.resources.dll +0 -0
- package/oracle-bin/pt-BR/FSharp.Core.resources.dll +0 -0
- package/oracle-bin/pt-BR/FSharp.DependencyManager.Nuget.resources.dll +0 -0
- package/oracle-bin/ru/FSharp.Compiler.Service.resources.dll +0 -0
- package/oracle-bin/ru/FSharp.Core.resources.dll +0 -0
- package/oracle-bin/ru/FSharp.DependencyManager.Nuget.resources.dll +0 -0
- package/oracle-bin/tr/FSharp.Compiler.Service.resources.dll +0 -0
- package/oracle-bin/tr/FSharp.Core.resources.dll +0 -0
- package/oracle-bin/tr/FSharp.DependencyManager.Nuget.resources.dll +0 -0
- package/oracle-bin/zh-Hans/FSharp.Compiler.Service.resources.dll +0 -0
- package/oracle-bin/zh-Hans/FSharp.Core.resources.dll +0 -0
- package/oracle-bin/zh-Hans/FSharp.DependencyManager.Nuget.resources.dll +0 -0
- package/oracle-bin/zh-Hant/FSharp.Compiler.Service.resources.dll +0 -0
- package/oracle-bin/zh-Hant/FSharp.Core.resources.dll +0 -0
- package/oracle-bin/zh-Hant/FSharp.DependencyManager.Nuget.resources.dll +0 -0
- package/package.json +38 -0
- package/packages/FSharp.Oracle/Extractor/Assembly.fs +160 -0
- package/packages/FSharp.Oracle/Extractor/EntityExtractor.fs +608 -0
- package/packages/FSharp.Oracle/Extractor/Helpers.fs +150 -0
- package/packages/FSharp.Oracle/Extractor/MemberExtractor.fs +172 -0
- package/packages/FSharp.Oracle/Extractor/ModuleExtractor.fs +45 -0
- package/packages/FSharp.Oracle/Extractor/ParameterExtractor.fs +47 -0
- package/packages/FSharp.Oracle/Extractor/SignatureRendering.fs +464 -0
- package/packages/FSharp.Oracle/Extractor/ValueExtractor.fs +171 -0
- package/packages/FSharp.Oracle/FSharp.Oracle.fsproj +36 -0
- package/packages/FSharp.Oracle/Program.fs +66 -0
- package/packages/FSharp.Oracle/XmlDoc.fs +463 -0
- package/packages/FSharp.Oracle.Schema/FSharp.Oracle.Schema.fsproj +16 -0
- package/packages/FSharp.Oracle.Schema/Schema.fs +454 -0
- package/packages/Starlight.FSharp.Oracle/components/DocEntry.astro +256 -0
- package/packages/Starlight.FSharp.Oracle/components/FSharpDocPage.astro +121 -0
- package/packages/Starlight.FSharp.Oracle/components/fsharp-doc.css +58 -0
- package/packages/Starlight.FSharp.Oracle/layouts/FSharpDocLayout.astro +27 -0
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
namespace FSharp.Oracle
|
|
2
|
+
|
|
3
|
+
open FSharp.Compiler.Symbols
|
|
4
|
+
open FSharp.Oracle.Schema
|
|
5
|
+
open Helpers
|
|
6
|
+
|
|
7
|
+
module internal SignatureRendering =
|
|
8
|
+
let rec renderFSharpType
|
|
9
|
+
(toUrl: string -> string)
|
|
10
|
+
(isTopLevel: bool)
|
|
11
|
+
(typ: FSharpType)
|
|
12
|
+
: TextNode
|
|
13
|
+
=
|
|
14
|
+
if typ.IsGenericParameter then
|
|
15
|
+
let gp = typ.GenericParameter
|
|
16
|
+
|
|
17
|
+
TextNode.Node
|
|
18
|
+
[
|
|
19
|
+
if isSrtp gp then
|
|
20
|
+
TextNode.Text "^"
|
|
21
|
+
else
|
|
22
|
+
TextNode.Tick
|
|
23
|
+
TextNode.Text gp.DisplayName
|
|
24
|
+
]
|
|
25
|
+
elif typ.IsFunctionType then
|
|
26
|
+
let parts =
|
|
27
|
+
[
|
|
28
|
+
for i in 0 .. typ.GenericArguments.Count - 1 do
|
|
29
|
+
let arg = typ.GenericArguments.[i]
|
|
30
|
+
|
|
31
|
+
if i > 0 then
|
|
32
|
+
TextNode.Space
|
|
33
|
+
TextNode.Arrow
|
|
34
|
+
TextNode.Space
|
|
35
|
+
|
|
36
|
+
renderFSharpType toUrl false arg
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
if isTopLevel then
|
|
40
|
+
TextNode.Node parts
|
|
41
|
+
else
|
|
42
|
+
TextNode.Node
|
|
43
|
+
[
|
|
44
|
+
TextNode.LeftParen
|
|
45
|
+
yield! parts
|
|
46
|
+
TextNode.RightParen
|
|
47
|
+
]
|
|
48
|
+
elif typ.IsTupleType then
|
|
49
|
+
TextNode.Node
|
|
50
|
+
[
|
|
51
|
+
for i in 0 .. typ.GenericArguments.Count - 1 do
|
|
52
|
+
let arg = typ.GenericArguments.[i]
|
|
53
|
+
|
|
54
|
+
if i > 0 then
|
|
55
|
+
TextNode.Space
|
|
56
|
+
TextNode.Star
|
|
57
|
+
TextNode.Space
|
|
58
|
+
|
|
59
|
+
renderFSharpType toUrl false arg
|
|
60
|
+
]
|
|
61
|
+
elif typ.IsAnonRecordType then
|
|
62
|
+
let details = typ.AnonRecordTypeDetails
|
|
63
|
+
let names = details.SortedFieldNames
|
|
64
|
+
let types = typ.GenericArguments |> Seq.toArray
|
|
65
|
+
|
|
66
|
+
let fields =
|
|
67
|
+
names
|
|
68
|
+
|> Array.mapi (fun i name ->
|
|
69
|
+
let fieldType = types.[i]
|
|
70
|
+
|
|
71
|
+
TextNode.Node
|
|
72
|
+
[
|
|
73
|
+
TextNode.Text name
|
|
74
|
+
TextNode.Space
|
|
75
|
+
TextNode.Colon
|
|
76
|
+
TextNode.Space
|
|
77
|
+
renderFSharpType toUrl false fieldType
|
|
78
|
+
]
|
|
79
|
+
)
|
|
80
|
+
|> Array.toList
|
|
81
|
+
|
|
82
|
+
TextNode.Node
|
|
83
|
+
[
|
|
84
|
+
yield TextNode.Text "{|"
|
|
85
|
+
yield TextNode.Space
|
|
86
|
+
for i, field in List.indexed fields do
|
|
87
|
+
if i > 0 then
|
|
88
|
+
yield TextNode.Text ";"
|
|
89
|
+
yield TextNode.Space
|
|
90
|
+
|
|
91
|
+
yield field
|
|
92
|
+
yield TextNode.Space
|
|
93
|
+
yield TextNode.Text "|}"
|
|
94
|
+
]
|
|
95
|
+
elif typ.HasTypeDefinition && typ.GenericArguments.Count = 0 then
|
|
96
|
+
let td = typ.TypeDefinition
|
|
97
|
+
|
|
98
|
+
match tryGetFullName td with
|
|
99
|
+
| Some fullName -> TextNode.TypeRef(td.DisplayName, fullName, toUrl fullName)
|
|
100
|
+
| None -> TextNode.Text td.DisplayName
|
|
101
|
+
elif
|
|
102
|
+
typ.HasTypeDefinition
|
|
103
|
+
&& typ.TypeDefinition.IsArrayType
|
|
104
|
+
&& typ.GenericArguments.Count = 1
|
|
105
|
+
then
|
|
106
|
+
let arg = renderFSharpType toUrl false typ.GenericArguments.[0]
|
|
107
|
+
|
|
108
|
+
TextNode.Node
|
|
109
|
+
[
|
|
110
|
+
arg
|
|
111
|
+
TextNode.Text "[]"
|
|
112
|
+
]
|
|
113
|
+
elif typ.HasTypeDefinition && typ.GenericArguments.Count = 1 then
|
|
114
|
+
let td = typ.TypeDefinition
|
|
115
|
+
let arg = renderFSharpType toUrl false typ.GenericArguments.[0]
|
|
116
|
+
|
|
117
|
+
let isPostfix =
|
|
118
|
+
Set.contains td.DisplayName postfixTypeDisplayNames
|
|
119
|
+
|| match tryGetFullName td with
|
|
120
|
+
| Some fullName -> Set.contains fullName postfixTypeNames
|
|
121
|
+
| None -> false
|
|
122
|
+
|
|
123
|
+
if isPostfix then
|
|
124
|
+
let head =
|
|
125
|
+
match tryGetFullName td with
|
|
126
|
+
| Some fullName -> TextNode.TypeRef(td.DisplayName, fullName, toUrl fullName)
|
|
127
|
+
| None -> TextNode.Text td.DisplayName
|
|
128
|
+
|
|
129
|
+
TextNode.Node
|
|
130
|
+
[
|
|
131
|
+
arg
|
|
132
|
+
TextNode.Space
|
|
133
|
+
head
|
|
134
|
+
]
|
|
135
|
+
else
|
|
136
|
+
let args =
|
|
137
|
+
[
|
|
138
|
+
for i in 0 .. typ.GenericArguments.Count - 1 do
|
|
139
|
+
let a = typ.GenericArguments.[i]
|
|
140
|
+
|
|
141
|
+
if i > 0 then
|
|
142
|
+
TextNode.Comma
|
|
143
|
+
TextNode.Space
|
|
144
|
+
|
|
145
|
+
renderFSharpType toUrl false a
|
|
146
|
+
]
|
|
147
|
+
|
|
148
|
+
let head =
|
|
149
|
+
match tryGetFullName td with
|
|
150
|
+
| Some fullName -> TextNode.TypeRef(td.DisplayName, fullName, toUrl fullName)
|
|
151
|
+
| None -> TextNode.Text td.DisplayName
|
|
152
|
+
|
|
153
|
+
TextNode.Node
|
|
154
|
+
[
|
|
155
|
+
head
|
|
156
|
+
TextNode.LessThan
|
|
157
|
+
yield! args
|
|
158
|
+
TextNode.GreaterThan
|
|
159
|
+
]
|
|
160
|
+
elif typ.HasTypeDefinition then
|
|
161
|
+
let td = typ.TypeDefinition
|
|
162
|
+
|
|
163
|
+
let args =
|
|
164
|
+
[
|
|
165
|
+
for i in 0 .. typ.GenericArguments.Count - 1 do
|
|
166
|
+
let arg = typ.GenericArguments.[i]
|
|
167
|
+
|
|
168
|
+
if i > 0 then
|
|
169
|
+
TextNode.Comma
|
|
170
|
+
TextNode.Space
|
|
171
|
+
|
|
172
|
+
renderFSharpType toUrl false arg
|
|
173
|
+
]
|
|
174
|
+
|
|
175
|
+
let head =
|
|
176
|
+
match tryGetFullName td with
|
|
177
|
+
| Some fullName -> TextNode.TypeRef(td.DisplayName, fullName, toUrl fullName)
|
|
178
|
+
| None -> TextNode.Text td.DisplayName
|
|
179
|
+
|
|
180
|
+
TextNode.Node
|
|
181
|
+
[
|
|
182
|
+
head
|
|
183
|
+
TextNode.LessThan
|
|
184
|
+
yield! args
|
|
185
|
+
TextNode.GreaterThan
|
|
186
|
+
]
|
|
187
|
+
else
|
|
188
|
+
TextNode.Text(typ.Format FSharpDisplayContext.Empty)
|
|
189
|
+
|
|
190
|
+
/// Render a single generic parameter constraint as a TextNode list.
|
|
191
|
+
let renderConstraint
|
|
192
|
+
(toUrl: string -> string)
|
|
193
|
+
(gp: FSharpGenericParameter)
|
|
194
|
+
(c: FSharpGenericParameterConstraint)
|
|
195
|
+
: TextNode list
|
|
196
|
+
=
|
|
197
|
+
if c.IsComparisonConstraint then
|
|
198
|
+
[
|
|
199
|
+
TextNode.Colon
|
|
200
|
+
TextNode.Space
|
|
201
|
+
TextNode.Keyword "comparison"
|
|
202
|
+
]
|
|
203
|
+
elif c.IsEqualityConstraint then
|
|
204
|
+
[
|
|
205
|
+
TextNode.Colon
|
|
206
|
+
TextNode.Space
|
|
207
|
+
TextNode.Keyword "equality"
|
|
208
|
+
]
|
|
209
|
+
elif c.IsUnmanagedConstraint then
|
|
210
|
+
[
|
|
211
|
+
TextNode.Colon
|
|
212
|
+
TextNode.Space
|
|
213
|
+
TextNode.Keyword "unmanaged"
|
|
214
|
+
]
|
|
215
|
+
elif c.IsNonNullableValueTypeConstraint then
|
|
216
|
+
[
|
|
217
|
+
TextNode.Colon
|
|
218
|
+
TextNode.Space
|
|
219
|
+
TextNode.Keyword "struct"
|
|
220
|
+
]
|
|
221
|
+
elif c.IsReferenceTypeConstraint then
|
|
222
|
+
[
|
|
223
|
+
TextNode.Colon
|
|
224
|
+
TextNode.Space
|
|
225
|
+
TextNode.Keyword "not null"
|
|
226
|
+
]
|
|
227
|
+
elif c.IsNotSupportsNullConstraint then
|
|
228
|
+
[
|
|
229
|
+
TextNode.Colon
|
|
230
|
+
TextNode.Space
|
|
231
|
+
TextNode.Keyword "not null"
|
|
232
|
+
]
|
|
233
|
+
elif c.IsSupportsNullConstraint then
|
|
234
|
+
[
|
|
235
|
+
TextNode.Colon
|
|
236
|
+
TextNode.Space
|
|
237
|
+
TextNode.Keyword "null"
|
|
238
|
+
]
|
|
239
|
+
elif c.IsCoercesToConstraint then
|
|
240
|
+
let ty = c.CoercesToTarget
|
|
241
|
+
|
|
242
|
+
[
|
|
243
|
+
TextNode.Text ":>"
|
|
244
|
+
TextNode.Space
|
|
245
|
+
renderFSharpType toUrl false ty
|
|
246
|
+
]
|
|
247
|
+
elif c.IsMemberConstraint then
|
|
248
|
+
// SRTP — render simplified member constraint
|
|
249
|
+
let m = c.MemberConstraintData
|
|
250
|
+
let argTypes = m.MemberArgumentTypes |> Seq.toList
|
|
251
|
+
|
|
252
|
+
let argNodes =
|
|
253
|
+
if List.isEmpty argTypes then
|
|
254
|
+
[]
|
|
255
|
+
else
|
|
256
|
+
[
|
|
257
|
+
TextNode.Space
|
|
258
|
+
for i, arg in List.indexed argTypes do
|
|
259
|
+
if i > 0 then
|
|
260
|
+
TextNode.Space
|
|
261
|
+
TextNode.Star
|
|
262
|
+
TextNode.Space
|
|
263
|
+
|
|
264
|
+
renderFSharpType toUrl false arg
|
|
265
|
+
]
|
|
266
|
+
|
|
267
|
+
let retNodes =
|
|
268
|
+
let rt = m.MemberReturnType
|
|
269
|
+
|
|
270
|
+
if isNull (box rt) then
|
|
271
|
+
[]
|
|
272
|
+
elif List.isEmpty argTypes then
|
|
273
|
+
// No args, just return type: `: ret`
|
|
274
|
+
[
|
|
275
|
+
TextNode.Space
|
|
276
|
+
renderFSharpType toUrl false rt
|
|
277
|
+
]
|
|
278
|
+
else
|
|
279
|
+
// Args + return type: `: args -> ret`
|
|
280
|
+
[
|
|
281
|
+
TextNode.Space
|
|
282
|
+
TextNode.Arrow
|
|
283
|
+
TextNode.Space
|
|
284
|
+
renderFSharpType toUrl false rt
|
|
285
|
+
]
|
|
286
|
+
|
|
287
|
+
[
|
|
288
|
+
TextNode.Colon
|
|
289
|
+
TextNode.Space
|
|
290
|
+
TextNode.LeftParen
|
|
291
|
+
if m.MemberIsStatic then
|
|
292
|
+
TextNode.Keyword "static member"
|
|
293
|
+
else
|
|
294
|
+
TextNode.Keyword "member"
|
|
295
|
+
TextNode.Space
|
|
296
|
+
TextNode.Text m.MemberName
|
|
297
|
+
if not (List.isEmpty argTypes) || not (isNull (box m.MemberReturnType)) then
|
|
298
|
+
TextNode.Space
|
|
299
|
+
TextNode.Colon
|
|
300
|
+
yield! argNodes
|
|
301
|
+
yield! retNodes
|
|
302
|
+
TextNode.RightParen
|
|
303
|
+
]
|
|
304
|
+
elif c.IsRequiresDefaultConstructorConstraint then
|
|
305
|
+
[
|
|
306
|
+
TextNode.Colon
|
|
307
|
+
TextNode.Space
|
|
308
|
+
TextNode.LeftParen
|
|
309
|
+
TextNode.Keyword "new"
|
|
310
|
+
TextNode.Space
|
|
311
|
+
TextNode.Colon
|
|
312
|
+
TextNode.Space
|
|
313
|
+
TextNode.Text "unit"
|
|
314
|
+
TextNode.Space
|
|
315
|
+
TextNode.Arrow
|
|
316
|
+
TextNode.Space
|
|
317
|
+
TextNode.Tick
|
|
318
|
+
TextNode.Text gp.DisplayName
|
|
319
|
+
TextNode.RightParen
|
|
320
|
+
]
|
|
321
|
+
elif c.IsEnumConstraint then
|
|
322
|
+
let target = c.EnumConstraintTarget
|
|
323
|
+
|
|
324
|
+
[
|
|
325
|
+
TextNode.Colon
|
|
326
|
+
TextNode.Space
|
|
327
|
+
TextNode.Keyword "enum"
|
|
328
|
+
TextNode.LessThan
|
|
329
|
+
renderFSharpType toUrl false target
|
|
330
|
+
TextNode.GreaterThan
|
|
331
|
+
]
|
|
332
|
+
elif c.IsDelegateConstraint then
|
|
333
|
+
[
|
|
334
|
+
TextNode.Colon
|
|
335
|
+
TextNode.Space
|
|
336
|
+
TextNode.Keyword "delegate"
|
|
337
|
+
]
|
|
338
|
+
elif c.IsDefaultsToConstraint then
|
|
339
|
+
let data = c.DefaultsToConstraintData
|
|
340
|
+
|
|
341
|
+
[
|
|
342
|
+
TextNode.Equal
|
|
343
|
+
TextNode.Space
|
|
344
|
+
renderFSharpType toUrl false data.DefaultsToTarget
|
|
345
|
+
]
|
|
346
|
+
elif c.IsSimpleChoiceConstraint then
|
|
347
|
+
c.SimpleChoices
|
|
348
|
+
|> Seq.map (renderFSharpType toUrl false)
|
|
349
|
+
|> Seq.toList
|
|
350
|
+
|> List.mapi (fun i tn ->
|
|
351
|
+
if i = 0 then
|
|
352
|
+
tn
|
|
353
|
+
else
|
|
354
|
+
TextNode.Node
|
|
355
|
+
[
|
|
356
|
+
TextNode.Space
|
|
357
|
+
TextNode.Text "|"
|
|
358
|
+
TextNode.Space
|
|
359
|
+
tn
|
|
360
|
+
]
|
|
361
|
+
)
|
|
362
|
+
else
|
|
363
|
+
[]
|
|
364
|
+
|
|
365
|
+
/// Render the generic-parameter list for a function or member, e.g.
|
|
366
|
+
/// `<'T when 'T : comparison>` or `<^T when ^T : (static member (+) : ^T * ^T -> ^T)>`.
|
|
367
|
+
/// Returns `None` when there are no parameters.
|
|
368
|
+
let renderGenericParams
|
|
369
|
+
(toUrl: string -> string)
|
|
370
|
+
(gps: FSharpGenericParameter seq)
|
|
371
|
+
: TextNode option
|
|
372
|
+
=
|
|
373
|
+
let gps = gps |> Seq.toList
|
|
374
|
+
|
|
375
|
+
if List.isEmpty gps then
|
|
376
|
+
None
|
|
377
|
+
else
|
|
378
|
+
let nodes =
|
|
379
|
+
[
|
|
380
|
+
TextNode.LessThan
|
|
381
|
+
for i, gp in List.indexed gps do
|
|
382
|
+
if i > 0 then
|
|
383
|
+
TextNode.Comma
|
|
384
|
+
TextNode.Space
|
|
385
|
+
// Use ^ only for SRTP (member constraints)
|
|
386
|
+
if isSrtp gp then
|
|
387
|
+
TextNode.Text "^"
|
|
388
|
+
else
|
|
389
|
+
TextNode.Tick
|
|
390
|
+
|
|
391
|
+
TextNode.Text gp.DisplayName
|
|
392
|
+
|
|
393
|
+
let constraints =
|
|
394
|
+
gp.Constraints |> Seq.toList |> List.map (renderConstraint toUrl gp)
|
|
395
|
+
|
|
396
|
+
if not (List.isEmpty constraints) then
|
|
397
|
+
TextNode.Space
|
|
398
|
+
TextNode.Keyword "when"
|
|
399
|
+
TextNode.Space
|
|
400
|
+
|
|
401
|
+
if isSrtp gp then
|
|
402
|
+
TextNode.Text "^"
|
|
403
|
+
else
|
|
404
|
+
TextNode.Tick
|
|
405
|
+
|
|
406
|
+
TextNode.Text gp.DisplayName
|
|
407
|
+
|
|
408
|
+
for i, cList in List.indexed constraints do
|
|
409
|
+
TextNode.Space
|
|
410
|
+
|
|
411
|
+
if i > 0 then
|
|
412
|
+
TextNode.Keyword "and"
|
|
413
|
+
TextNode.Space
|
|
414
|
+
|
|
415
|
+
if isSrtp gp then
|
|
416
|
+
TextNode.Text "^"
|
|
417
|
+
else
|
|
418
|
+
TextNode.Tick
|
|
419
|
+
|
|
420
|
+
TextNode.Text gp.DisplayName
|
|
421
|
+
TextNode.Space
|
|
422
|
+
|
|
423
|
+
for cNode in cList do
|
|
424
|
+
cNode
|
|
425
|
+
TextNode.GreaterThan
|
|
426
|
+
]
|
|
427
|
+
|
|
428
|
+
Some(TextNode.Node nodes)
|
|
429
|
+
|
|
430
|
+
/// Strip `<`, `>` and the leading type variable from a generic-parameter list,
|
|
431
|
+
/// returning only the constraint clause (e.g. ` when 'T : comparison`).
|
|
432
|
+
/// Used to append constraints after a value/member signature.
|
|
433
|
+
let stripGenericParamBrackets (genericParams: TextNode option) : TextNode =
|
|
434
|
+
match genericParams with
|
|
435
|
+
| None -> TextNode.Node []
|
|
436
|
+
| Some(TextNode.Node nodes) ->
|
|
437
|
+
let inner =
|
|
438
|
+
nodes
|
|
439
|
+
|> List.skipWhile (
|
|
440
|
+
function
|
|
441
|
+
| TextNode.LessThan -> true
|
|
442
|
+
| _ -> false
|
|
443
|
+
)
|
|
444
|
+
|> List.skipWhile (
|
|
445
|
+
function
|
|
446
|
+
| TextNode.Tick -> true
|
|
447
|
+
| TextNode.Text _ -> true
|
|
448
|
+
| _ -> false
|
|
449
|
+
)
|
|
450
|
+
|> List.rev
|
|
451
|
+
|> List.skipWhile (
|
|
452
|
+
function
|
|
453
|
+
| TextNode.GreaterThan -> true
|
|
454
|
+
| _ -> false
|
|
455
|
+
)
|
|
456
|
+
|> List.rev
|
|
457
|
+
|> List.skipWhile (
|
|
458
|
+
function
|
|
459
|
+
| TextNode.Space -> true
|
|
460
|
+
| _ -> false
|
|
461
|
+
)
|
|
462
|
+
|
|
463
|
+
TextNode.Node(TextNode.Space :: inner)
|
|
464
|
+
| Some _ -> TextNode.Node []
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
namespace FSharp.Oracle
|
|
2
|
+
|
|
3
|
+
open FSharp.Compiler.Symbols
|
|
4
|
+
open FSharp.Oracle.Schema
|
|
5
|
+
open Oracle.XmlDoc
|
|
6
|
+
open Helpers
|
|
7
|
+
open SignatureRendering
|
|
8
|
+
open ParameterExtractor
|
|
9
|
+
|
|
10
|
+
module internal ValueExtractor =
|
|
11
|
+
let extractFunction
|
|
12
|
+
(toUrl: string -> string)
|
|
13
|
+
(docs: Map<string, string>)
|
|
14
|
+
(mfv: FSharpMemberOrFunctionOrValue)
|
|
15
|
+
: Function
|
|
16
|
+
=
|
|
17
|
+
let obsoleteInfo = obsoleteOf mfv
|
|
18
|
+
let parameters = curriedParams toUrl mfv
|
|
19
|
+
let allParams = parameters |> List.collect id
|
|
20
|
+
let returnTypeNode = renderFSharpType toUrl false mfv.ReturnParameter.Type
|
|
21
|
+
|
|
22
|
+
// The colon column is determined by the longest of: function name, parameter names.
|
|
23
|
+
// Both the `val name :` line and parameter lines align their colons to this column.
|
|
24
|
+
let maxNameLength =
|
|
25
|
+
let maxParamNameLength =
|
|
26
|
+
if allParams.IsEmpty then
|
|
27
|
+
0
|
|
28
|
+
else
|
|
29
|
+
allParams |> List.map (fun p -> p.Name.Length) |> List.max
|
|
30
|
+
|
|
31
|
+
(max mfv.DisplayName.Length maxParamNameLength) + 1 // name + space before colon
|
|
32
|
+
|
|
33
|
+
// Compute AlignedDeclaration for each parameter now that maxNameLength is known.
|
|
34
|
+
let alignedParameters =
|
|
35
|
+
parameters
|
|
36
|
+
|> List.map (fun group ->
|
|
37
|
+
group
|
|
38
|
+
|> List.map (fun p ->
|
|
39
|
+
{ p with
|
|
40
|
+
AlignedDeclaration =
|
|
41
|
+
TextNode.Node
|
|
42
|
+
[
|
|
43
|
+
TextNode.NewLine
|
|
44
|
+
TextNode.Spaces 4
|
|
45
|
+
TextNode.Text p.Name
|
|
46
|
+
TextNode.Spaces(maxNameLength - p.Name.Length)
|
|
47
|
+
TextNode.Colon
|
|
48
|
+
TextNode.Space
|
|
49
|
+
p.Type
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
let genericParams = renderGenericParams toUrl mfv.GenericParameters
|
|
56
|
+
|
|
57
|
+
let isInline =
|
|
58
|
+
(mfv.InlineAnnotation = FSharpInlineAnnotation.AlwaysInline
|
|
59
|
+
|| mfv.InlineAnnotation = FSharpInlineAnnotation.AggressiveInline)
|
|
60
|
+
&& not mfv.IsActivePattern
|
|
61
|
+
|
|
62
|
+
let constraintClause = stripGenericParamBrackets genericParams
|
|
63
|
+
|
|
64
|
+
let valKeyword =
|
|
65
|
+
if isInline then
|
|
66
|
+
"val inline"
|
|
67
|
+
elif mfv.IsMutable then
|
|
68
|
+
"val mutable"
|
|
69
|
+
else
|
|
70
|
+
"val"
|
|
71
|
+
|
|
72
|
+
let simpleDeclaration =
|
|
73
|
+
TextNode.Node
|
|
74
|
+
[
|
|
75
|
+
TextNode.Keyword valKeyword
|
|
76
|
+
TextNode.Space
|
|
77
|
+
TextNode.Text mfv.DisplayName
|
|
78
|
+
TextNode.Space
|
|
79
|
+
TextNode.Colon
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
let alignedDeclaration =
|
|
83
|
+
TextNode.Node
|
|
84
|
+
[
|
|
85
|
+
TextNode.Keyword valKeyword
|
|
86
|
+
TextNode.Space
|
|
87
|
+
TextNode.Text mfv.DisplayName
|
|
88
|
+
TextNode.Spaces(max (maxNameLength - mfv.DisplayName.Length) 1)
|
|
89
|
+
TextNode.Colon
|
|
90
|
+
]
|
|
91
|
+
|
|
92
|
+
let signatureNode = renderFSharpType toUrl true mfv.FullType
|
|
93
|
+
let xmlDoc = xmlDocOf docs mfv.XmlDocSig
|
|
94
|
+
|
|
95
|
+
{
|
|
96
|
+
Name = mfv.DisplayName
|
|
97
|
+
FullName = mfv.FullName
|
|
98
|
+
Signature = signatureNode
|
|
99
|
+
Parameters = alignedParameters
|
|
100
|
+
Declaration = simpleDeclaration
|
|
101
|
+
AlignedDeclaration = alignedDeclaration
|
|
102
|
+
GenericParameters = genericParams
|
|
103
|
+
ReturnType =
|
|
104
|
+
if allParams.IsEmpty then
|
|
105
|
+
TextNode.Node
|
|
106
|
+
[
|
|
107
|
+
TextNode.Space
|
|
108
|
+
returnTypeNode
|
|
109
|
+
constraintClause
|
|
110
|
+
]
|
|
111
|
+
else
|
|
112
|
+
// The arrow aligns with the colons above:
|
|
113
|
+
// 4 (indent) + maxNameLength
|
|
114
|
+
TextNode.Node
|
|
115
|
+
[
|
|
116
|
+
TextNode.NewLine
|
|
117
|
+
TextNode.Spaces(4 + maxNameLength)
|
|
118
|
+
TextNode.Arrow
|
|
119
|
+
TextNode.Space
|
|
120
|
+
returnTypeNode
|
|
121
|
+
constraintClause
|
|
122
|
+
]
|
|
123
|
+
XmlDoc = xmlDoc
|
|
124
|
+
ObsoleteInfo = obsoleteInfo
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
let extractValue
|
|
128
|
+
(toUrl: string -> string)
|
|
129
|
+
(docs: Map<string, string>)
|
|
130
|
+
(mfv: FSharpMemberOrFunctionOrValue)
|
|
131
|
+
: Value
|
|
132
|
+
=
|
|
133
|
+
let obsoleteInfo = obsoleteOf mfv
|
|
134
|
+
let typeNode = renderFSharpType toUrl true mfv.FullType
|
|
135
|
+
let genericParams = renderGenericParams toUrl mfv.GenericParameters
|
|
136
|
+
|
|
137
|
+
let isInline =
|
|
138
|
+
(mfv.InlineAnnotation = FSharpInlineAnnotation.AlwaysInline
|
|
139
|
+
|| mfv.InlineAnnotation = FSharpInlineAnnotation.AggressiveInline)
|
|
140
|
+
&& not mfv.IsActivePattern
|
|
141
|
+
|
|
142
|
+
let constraintClause = stripGenericParamBrackets genericParams
|
|
143
|
+
|
|
144
|
+
let valKeyword =
|
|
145
|
+
if isInline then
|
|
146
|
+
"val inline"
|
|
147
|
+
elif mfv.IsMutable then
|
|
148
|
+
"val mutable"
|
|
149
|
+
else
|
|
150
|
+
"val"
|
|
151
|
+
|
|
152
|
+
{
|
|
153
|
+
Name = mfv.DisplayName
|
|
154
|
+
FullName = mfv.FullName
|
|
155
|
+
Signature = typeNode
|
|
156
|
+
Declaration =
|
|
157
|
+
TextNode.Node
|
|
158
|
+
[
|
|
159
|
+
TextNode.Keyword valKeyword
|
|
160
|
+
TextNode.Space
|
|
161
|
+
TextNode.Text mfv.DisplayName
|
|
162
|
+
TextNode.Space
|
|
163
|
+
TextNode.Colon
|
|
164
|
+
TextNode.Space
|
|
165
|
+
typeNode
|
|
166
|
+
constraintClause
|
|
167
|
+
]
|
|
168
|
+
GenericParameters = genericParams
|
|
169
|
+
XmlDoc = xmlDocOf docs mfv.XmlDocSig
|
|
170
|
+
ObsoleteInfo = obsoleteInfo
|
|
171
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<Project Sdk="Microsoft.NET.Sdk">
|
|
2
|
+
|
|
3
|
+
<PropertyGroup>
|
|
4
|
+
<OutputType>Exe</OutputType>
|
|
5
|
+
<TargetFramework>net10.0</TargetFramework>
|
|
6
|
+
<PackAsTool>true</PackAsTool>
|
|
7
|
+
<ToolCommandName>fsharp-docs-oracle</ToolCommandName>
|
|
8
|
+
<AssemblyName>Oracle</AssemblyName>
|
|
9
|
+
<RootNamespace>Oracle</RootNamespace>
|
|
10
|
+
</PropertyGroup>
|
|
11
|
+
|
|
12
|
+
<ItemGroup>
|
|
13
|
+
<Compile Include="XmlDoc.fs" />
|
|
14
|
+
<Compile Include="Extractor/Helpers.fs" />
|
|
15
|
+
<Compile Include="Extractor/SignatureRendering.fs" />
|
|
16
|
+
<Compile Include="Extractor/ParameterExtractor.fs" />
|
|
17
|
+
<Compile Include="Extractor/ValueExtractor.fs" />
|
|
18
|
+
<Compile Include="Extractor/MemberExtractor.fs" />
|
|
19
|
+
<Compile Include="Extractor/EntityExtractor.fs" />
|
|
20
|
+
<Compile Include="Extractor/ModuleExtractor.fs" />
|
|
21
|
+
<Compile Include="Extractor/Assembly.fs" />
|
|
22
|
+
<Compile Include="Program.fs" />
|
|
23
|
+
</ItemGroup>
|
|
24
|
+
|
|
25
|
+
<ItemGroup>
|
|
26
|
+
<PackageReference Include="FSharp.Compiler.Service" />
|
|
27
|
+
<PackageReference Include="Thoth.Json.Core.Auto" />
|
|
28
|
+
<PackageReference Include="Thoth.Json.System.Text.Json" />
|
|
29
|
+
</ItemGroup>
|
|
30
|
+
|
|
31
|
+
<ItemGroup>
|
|
32
|
+
<ProjectReference Include="../FSharp.Oracle.Schema/FSharp.Oracle.Schema.fsproj" />
|
|
33
|
+
</ItemGroup>
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
</Project>
|