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,150 @@
|
|
|
1
|
+
namespace FSharp.Oracle
|
|
2
|
+
|
|
3
|
+
open FSharp.Compiler.Symbols
|
|
4
|
+
open FSharp.Oracle.Schema
|
|
5
|
+
|
|
6
|
+
module internal Helpers =
|
|
7
|
+
/// Returns everything before the last dot, e.g. "A.B.C" → "A.B".
|
|
8
|
+
/// Returns "" for unqualified names.
|
|
9
|
+
let namespaceOf (fullName: string) =
|
|
10
|
+
let lastDot = fullName.LastIndexOf('.')
|
|
11
|
+
|
|
12
|
+
if lastDot < 0 then
|
|
13
|
+
""
|
|
14
|
+
else
|
|
15
|
+
fullName.[.. lastDot - 1]
|
|
16
|
+
|
|
17
|
+
/// Try to get FullName from a FSharpEntity; returns None for primitives
|
|
18
|
+
/// like 'string', 'int' that are F# type abbreviations with no qualified name.
|
|
19
|
+
let tryGetFullName (entity: FSharpEntity) =
|
|
20
|
+
try
|
|
21
|
+
Some entity.FullName
|
|
22
|
+
with _ ->
|
|
23
|
+
None
|
|
24
|
+
|
|
25
|
+
/// Compute a safe FullName for any entity.
|
|
26
|
+
/// Type abbreviations for primitives (e.g. `type Meters = float`) throw on FullName;
|
|
27
|
+
/// fall back to constructing it from Namespace + DisplayName.
|
|
28
|
+
let safeFullName (entity: FSharpEntity) =
|
|
29
|
+
match tryGetFullName entity with
|
|
30
|
+
| Some fullName -> fullName
|
|
31
|
+
| None ->
|
|
32
|
+
let ns = entity.Namespace |> Option.defaultValue ""
|
|
33
|
+
|
|
34
|
+
if ns = "" then
|
|
35
|
+
entity.DisplayName
|
|
36
|
+
else
|
|
37
|
+
$"{ns}.{entity.DisplayName}"
|
|
38
|
+
|
|
39
|
+
/// True for SRTP parameters (have member/static-member constraints).
|
|
40
|
+
let isSrtp (gp: FSharpGenericParameter) =
|
|
41
|
+
gp.Constraints |> Seq.exists (fun c -> c.IsMemberConstraint)
|
|
42
|
+
|
|
43
|
+
/// Display names for types that conventionally use postfix syntax in F#.
|
|
44
|
+
let postfixTypeDisplayNames =
|
|
45
|
+
Set.ofList
|
|
46
|
+
[
|
|
47
|
+
"list"
|
|
48
|
+
"option"
|
|
49
|
+
"seq"
|
|
50
|
+
"voption"
|
|
51
|
+
"ref"
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
/// Full names for types that conventionally use postfix syntax in F#.
|
|
55
|
+
let postfixTypeNames =
|
|
56
|
+
Set.ofList
|
|
57
|
+
[
|
|
58
|
+
// list
|
|
59
|
+
"Microsoft.FSharp.Collections.list"
|
|
60
|
+
"Microsoft.FSharp.Collections.List"
|
|
61
|
+
"Microsoft.FSharp.Collections.FSharpList"
|
|
62
|
+
// option
|
|
63
|
+
"Microsoft.FSharp.Core.option"
|
|
64
|
+
"Microsoft.FSharp.Core.Option"
|
|
65
|
+
"Microsoft.FSharp.Core.FSharpOption"
|
|
66
|
+
// seq
|
|
67
|
+
"Microsoft.FSharp.Collections.seq"
|
|
68
|
+
"Microsoft.FSharp.Collections.Seq"
|
|
69
|
+
"System.Collections.Generic.IEnumerable"
|
|
70
|
+
"System.Collections.Generic.IEnumerable`1"
|
|
71
|
+
// voption
|
|
72
|
+
"Microsoft.FSharp.Core.voption"
|
|
73
|
+
"Microsoft.FSharp.Core.ValueOption"
|
|
74
|
+
"Microsoft.FSharp.Core.FSharpValueOption"
|
|
75
|
+
// ref
|
|
76
|
+
"Microsoft.FSharp.Core.ref"
|
|
77
|
+
"Microsoft.FSharp.Core.Ref"
|
|
78
|
+
"Microsoft.FSharp.Core.FSharpRef"
|
|
79
|
+
]
|
|
80
|
+
|
|
81
|
+
let memberKindOf (mfv: FSharpMemberOrFunctionOrValue) =
|
|
82
|
+
if mfv.IsConstructor then
|
|
83
|
+
MemberKind.Constructor
|
|
84
|
+
elif mfv.IsProperty then
|
|
85
|
+
MemberKind.Property
|
|
86
|
+
elif mfv.LogicalName.StartsWith("op_") && not mfv.IsActivePattern then
|
|
87
|
+
MemberKind.Operator
|
|
88
|
+
else
|
|
89
|
+
MemberKind.Method
|
|
90
|
+
|
|
91
|
+
let obsoleteOf (mfv: FSharpMemberOrFunctionOrValue) : ObsoleteInfo =
|
|
92
|
+
mfv.Attributes
|
|
93
|
+
|> Seq.tryFind (fun a -> a.AttributeType.FullName = "System.ObsoleteAttribute")
|
|
94
|
+
|> function
|
|
95
|
+
| None -> ObsoleteInfo.Active
|
|
96
|
+
| Some a ->
|
|
97
|
+
a.ConstructorArguments
|
|
98
|
+
|> Seq.tryHead
|
|
99
|
+
|> Option.map (snd >> string)
|
|
100
|
+
|> function
|
|
101
|
+
| Some "" -> ObsoleteInfo.Deprecated
|
|
102
|
+
| Some msg -> ObsoleteInfo.DeprecatedWithMessage msg
|
|
103
|
+
| None -> ObsoleteInfo.Deprecated
|
|
104
|
+
|
|
105
|
+
let hasAttribute (fullName: string) (entity: FSharpEntity) =
|
|
106
|
+
entity.Attributes
|
|
107
|
+
|> Seq.exists (fun a -> a.AttributeType.FullName = fullName)
|
|
108
|
+
|
|
109
|
+
let isStruct (entity: FSharpEntity) =
|
|
110
|
+
hasAttribute "Microsoft.FSharp.Core.StructAttribute" entity
|
|
111
|
+
|
|
112
|
+
let isMeasure (entity: FSharpEntity) =
|
|
113
|
+
hasAttribute "Microsoft.FSharp.Core.MeasureAttribute" entity
|
|
114
|
+
|
|
115
|
+
let obsoleteOfEntity (entity: FSharpEntity) : ObsoleteInfo =
|
|
116
|
+
entity.Attributes
|
|
117
|
+
|> Seq.tryFind (fun a -> a.AttributeType.FullName = "System.ObsoleteAttribute")
|
|
118
|
+
|> function
|
|
119
|
+
| None -> ObsoleteInfo.Active
|
|
120
|
+
| Some a ->
|
|
121
|
+
a.ConstructorArguments
|
|
122
|
+
|> Seq.tryHead
|
|
123
|
+
|> Option.map (snd >> string)
|
|
124
|
+
|> function
|
|
125
|
+
| Some "" -> ObsoleteInfo.Deprecated
|
|
126
|
+
| Some msg -> ObsoleteInfo.DeprecatedWithMessage msg
|
|
127
|
+
| None -> ObsoleteInfo.Deprecated
|
|
128
|
+
|
|
129
|
+
/// Resolves XML-doc <see cref="..."/> strings to page URLs.
|
|
130
|
+
/// cref format: T:Namespace.Type or M:Namespace.Type.Member(...)
|
|
131
|
+
let resolveCref (toUrl: string -> string) (cref: string) : string option =
|
|
132
|
+
if System.String.IsNullOrWhiteSpace cref then
|
|
133
|
+
None
|
|
134
|
+
else
|
|
135
|
+
let stripped =
|
|
136
|
+
if cref.Length > 2 && cref.[1] = ':' then
|
|
137
|
+
cref.[2..]
|
|
138
|
+
else
|
|
139
|
+
cref
|
|
140
|
+
|
|
141
|
+
let typeName =
|
|
142
|
+
// For member refs, drop parameters and the last segment to get the type
|
|
143
|
+
let withoutParams =
|
|
144
|
+
let paren = stripped.IndexOf('(')
|
|
145
|
+
if paren >= 0 then stripped.[..paren - 1] else stripped
|
|
146
|
+
|
|
147
|
+
let lastDot = withoutParams.LastIndexOf('.')
|
|
148
|
+
if lastDot > 0 then withoutParams.[..lastDot - 1] else withoutParams
|
|
149
|
+
|
|
150
|
+
Some(toUrl typeName)
|
|
@@ -0,0 +1,172 @@
|
|
|
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 MemberExtractor =
|
|
11
|
+
/// Builds the signature TextNode for the per-member DocEntry slot (no anchors, no indentation).
|
|
12
|
+
/// This is the pre-computed Declaration stored on Member.
|
|
13
|
+
let buildMemberDeclaration
|
|
14
|
+
(kind: MemberKind)
|
|
15
|
+
(name: string)
|
|
16
|
+
(isStatic: bool)
|
|
17
|
+
(isAbstract: bool)
|
|
18
|
+
(parameters: Parameter list list)
|
|
19
|
+
(returnType: TextNode)
|
|
20
|
+
(constraintClause: TextNode)
|
|
21
|
+
: TextNode
|
|
22
|
+
=
|
|
23
|
+
let prefixNodes =
|
|
24
|
+
match kind with
|
|
25
|
+
| MemberKind.Constructor -> [ TextNode.Keyword "new" ]
|
|
26
|
+
| MemberKind.Operator ->
|
|
27
|
+
// Operators are always static in F#
|
|
28
|
+
[
|
|
29
|
+
TextNode.Keyword "static"
|
|
30
|
+
TextNode.Space
|
|
31
|
+
TextNode.Keyword "member"
|
|
32
|
+
TextNode.Space
|
|
33
|
+
TextNode.Text name
|
|
34
|
+
]
|
|
35
|
+
| MemberKind.Property ->
|
|
36
|
+
if isStatic then
|
|
37
|
+
[
|
|
38
|
+
TextNode.Keyword "static"
|
|
39
|
+
TextNode.Space
|
|
40
|
+
TextNode.Keyword "property"
|
|
41
|
+
TextNode.Space
|
|
42
|
+
TextNode.Text name
|
|
43
|
+
]
|
|
44
|
+
elif isAbstract then
|
|
45
|
+
[
|
|
46
|
+
TextNode.Keyword "abstract"
|
|
47
|
+
TextNode.Space
|
|
48
|
+
TextNode.Keyword "property"
|
|
49
|
+
TextNode.Space
|
|
50
|
+
TextNode.Text name
|
|
51
|
+
]
|
|
52
|
+
else
|
|
53
|
+
[
|
|
54
|
+
TextNode.Keyword "property"
|
|
55
|
+
TextNode.Space
|
|
56
|
+
TextNode.Text name
|
|
57
|
+
]
|
|
58
|
+
| MemberKind.Method ->
|
|
59
|
+
if isStatic then
|
|
60
|
+
[
|
|
61
|
+
TextNode.Keyword "static"
|
|
62
|
+
TextNode.Space
|
|
63
|
+
TextNode.Keyword "member"
|
|
64
|
+
TextNode.Space
|
|
65
|
+
TextNode.Text name
|
|
66
|
+
]
|
|
67
|
+
elif isAbstract then
|
|
68
|
+
[
|
|
69
|
+
TextNode.Keyword "abstract"
|
|
70
|
+
TextNode.Space
|
|
71
|
+
TextNode.Keyword "member"
|
|
72
|
+
TextNode.Space
|
|
73
|
+
TextNode.Text name
|
|
74
|
+
]
|
|
75
|
+
else
|
|
76
|
+
[
|
|
77
|
+
TextNode.Keyword "member"
|
|
78
|
+
TextNode.Space
|
|
79
|
+
TextNode.Text name
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
let allParams = parameters |> List.collect id
|
|
83
|
+
|
|
84
|
+
let typeNodes =
|
|
85
|
+
if allParams.IsEmpty then
|
|
86
|
+
[
|
|
87
|
+
returnType
|
|
88
|
+
constraintClause
|
|
89
|
+
]
|
|
90
|
+
else
|
|
91
|
+
[
|
|
92
|
+
for i, param in List.indexed allParams do
|
|
93
|
+
if i > 0 then
|
|
94
|
+
yield TextNode.Space
|
|
95
|
+
yield TextNode.Arrow
|
|
96
|
+
yield TextNode.Space
|
|
97
|
+
|
|
98
|
+
yield param.Declaration
|
|
99
|
+
yield TextNode.Space
|
|
100
|
+
yield TextNode.Arrow
|
|
101
|
+
yield TextNode.Space
|
|
102
|
+
yield returnType
|
|
103
|
+
yield constraintClause
|
|
104
|
+
]
|
|
105
|
+
|
|
106
|
+
let withGetNodes =
|
|
107
|
+
if kind = MemberKind.Property then
|
|
108
|
+
[
|
|
109
|
+
TextNode.Space
|
|
110
|
+
TextNode.Keyword "with"
|
|
111
|
+
TextNode.Space
|
|
112
|
+
TextNode.Keyword "get"
|
|
113
|
+
]
|
|
114
|
+
else
|
|
115
|
+
[]
|
|
116
|
+
|
|
117
|
+
TextNode.Node
|
|
118
|
+
[
|
|
119
|
+
yield! prefixNodes
|
|
120
|
+
yield TextNode.Space
|
|
121
|
+
yield TextNode.Colon
|
|
122
|
+
yield TextNode.Space
|
|
123
|
+
yield! typeNodes
|
|
124
|
+
yield! withGetNodes
|
|
125
|
+
]
|
|
126
|
+
|
|
127
|
+
let extractMember
|
|
128
|
+
(toUrl: string -> string)
|
|
129
|
+
(docs: Map<string, string>)
|
|
130
|
+
(mfv: FSharpMemberOrFunctionOrValue)
|
|
131
|
+
: Member
|
|
132
|
+
=
|
|
133
|
+
let obsoleteInfo = obsoleteOf mfv
|
|
134
|
+
let kind = memberKindOf mfv
|
|
135
|
+
// Constructors are all named ".ctor" by FCS; use "new" as a canonical
|
|
136
|
+
// display name. Multiple-constructor disambiguation happens in extractEntity.
|
|
137
|
+
let name =
|
|
138
|
+
if mfv.IsConstructor then
|
|
139
|
+
"new"
|
|
140
|
+
else
|
|
141
|
+
mfv.DisplayName
|
|
142
|
+
|
|
143
|
+
let parameters = curriedParams toUrl mfv
|
|
144
|
+
let returnType = renderFSharpType toUrl false mfv.ReturnParameter.Type
|
|
145
|
+
let isStatic = mfv.IsModuleValueOrMember && not mfv.IsInstanceMember
|
|
146
|
+
let isAbstract = mfv.IsDispatchSlot
|
|
147
|
+
|
|
148
|
+
let genericParams = renderGenericParams toUrl mfv.GenericParameters
|
|
149
|
+
|
|
150
|
+
let constraintClause = stripGenericParamBrackets genericParams
|
|
151
|
+
|
|
152
|
+
{
|
|
153
|
+
Kind = kind
|
|
154
|
+
Name = name
|
|
155
|
+
FullName = mfv.FullName
|
|
156
|
+
Parameters = parameters
|
|
157
|
+
ReturnType = returnType
|
|
158
|
+
Declaration =
|
|
159
|
+
buildMemberDeclaration
|
|
160
|
+
kind
|
|
161
|
+
name
|
|
162
|
+
isStatic
|
|
163
|
+
isAbstract
|
|
164
|
+
parameters
|
|
165
|
+
returnType
|
|
166
|
+
constraintClause
|
|
167
|
+
GenericParameters = genericParams
|
|
168
|
+
XmlDoc = xmlDocOf docs mfv.XmlDocSig
|
|
169
|
+
IsStatic = isStatic
|
|
170
|
+
IsAbstract = isAbstract
|
|
171
|
+
ObsoleteInfo = obsoleteInfo
|
|
172
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
namespace FSharp.Oracle
|
|
2
|
+
|
|
3
|
+
open FSharp.Compiler.Symbols
|
|
4
|
+
open FSharp.Oracle.Schema
|
|
5
|
+
open Oracle.XmlDoc
|
|
6
|
+
open Helpers
|
|
7
|
+
open EntityExtractor
|
|
8
|
+
open ValueExtractor
|
|
9
|
+
|
|
10
|
+
module internal ModuleExtractor =
|
|
11
|
+
let extractModule
|
|
12
|
+
(toUrl: string -> string)
|
|
13
|
+
(docs: Map<string, string>)
|
|
14
|
+
(entity: FSharpEntity)
|
|
15
|
+
: Module
|
|
16
|
+
=
|
|
17
|
+
let nested = entity.NestedEntities |> Seq.toList
|
|
18
|
+
|
|
19
|
+
let functions, values =
|
|
20
|
+
entity.MembersFunctionsAndValues
|
|
21
|
+
|> Seq.filter (fun m -> not m.IsCompilerGenerated)
|
|
22
|
+
|> Seq.toList
|
|
23
|
+
|> List.partition (fun m -> m.IsFunction)
|
|
24
|
+
|
|
25
|
+
let obsoleteInfo = obsoleteOfEntity entity
|
|
26
|
+
|
|
27
|
+
let entities =
|
|
28
|
+
nested
|
|
29
|
+
|> List.filter (fun e -> not e.IsFSharpModule)
|
|
30
|
+
|> List.map (extractEntity toUrl docs)
|
|
31
|
+
|
|
32
|
+
let funcs = functions |> List.map (extractFunction toUrl docs)
|
|
33
|
+
let vals = values |> List.map (extractValue toUrl docs)
|
|
34
|
+
|
|
35
|
+
{
|
|
36
|
+
Name = entity.DisplayName
|
|
37
|
+
FullName = entity.FullName
|
|
38
|
+
Namespace = namespaceOf entity.FullName
|
|
39
|
+
XmlDoc = moduleDocOf docs entity.XmlDocSig
|
|
40
|
+
Entities = entities
|
|
41
|
+
Functions = funcs
|
|
42
|
+
Values = vals
|
|
43
|
+
IsSynthetic = false
|
|
44
|
+
ObsoleteInfo = obsoleteInfo
|
|
45
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
namespace FSharp.Oracle
|
|
2
|
+
|
|
3
|
+
open FSharp.Compiler.Symbols
|
|
4
|
+
open FSharp.Oracle.Schema
|
|
5
|
+
open SignatureRendering
|
|
6
|
+
|
|
7
|
+
module internal ParameterExtractor =
|
|
8
|
+
let extractParameter (toUrl: string -> string) (param: FSharpParameter) : Parameter =
|
|
9
|
+
let name = param.DisplayName
|
|
10
|
+
let typeNode = renderFSharpType toUrl false param.Type
|
|
11
|
+
|
|
12
|
+
let declaration =
|
|
13
|
+
TextNode.Node
|
|
14
|
+
[
|
|
15
|
+
TextNode.TypeVar name
|
|
16
|
+
TextNode.Space
|
|
17
|
+
TextNode.Colon
|
|
18
|
+
TextNode.Space
|
|
19
|
+
typeNode
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
{
|
|
23
|
+
Name = name
|
|
24
|
+
Type = typeNode
|
|
25
|
+
Declaration = declaration
|
|
26
|
+
AlignedDeclaration = declaration // overwritten by extractFunction once maxNameLength is known
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let curriedParams (toUrl: string -> string) (mfv: FSharpMemberOrFunctionOrValue) =
|
|
30
|
+
mfv.CurriedParameterGroups
|
|
31
|
+
|> Seq.map (fun group -> group |> Seq.map (extractParameter toUrl) |> Seq.toList)
|
|
32
|
+
|> Seq.toList
|
|
33
|
+
// Drop unit-only groups for properties only — they are FCS artifacts on
|
|
34
|
+
// no-arg getters (e.g. `member _.Zero`). For real functions and methods
|
|
35
|
+
// (e.g. `let timestamp ()`) the unit group is explicit and must be kept.
|
|
36
|
+
|> List.filter (fun group ->
|
|
37
|
+
not (
|
|
38
|
+
mfv.IsProperty
|
|
39
|
+
&& group.Length = 1
|
|
40
|
+
&& (
|
|
41
|
+
match group.[0].Type with
|
|
42
|
+
| TextNode.TypeRef(name, _, _) -> name = "unit"
|
|
43
|
+
| TextNode.Text "unit" -> true
|
|
44
|
+
| _ -> false
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
)
|