-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathpartMembers.fsx
172 lines (144 loc) · 4.52 KB
/
partMembers.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#load "../../.fake/build.fsx/intellisense.fsx"
#if !FAKE
#r "Facades/netstandard"
#r "netstandard"
#endif
open System
open Fable.Helpers.React
open Fable.Helpers.React.Props
open FSharp.MetadataFormat
type ModuleByCategory = {
Index : int
GroupKey : string
Members : seq<Member>
Name : string
}
let tooltip (m: Member) (dataId: string) =
div [
Class "tip"
Id dataId
] [
yield strong [] [
str "Signature:"
]
yield str m.Details.Signature
yield br []
if m.Details.Modifiers |> Seq.isEmpty then
yield strong [] [
str "Modifiers:"
]
yield str m.Details.FormatModifiers
yield br []
if m.Details.TypeArguments |> Seq.isEmpty then
yield strong [] [
str "Type parameters:"
]
yield str m.Details.FormatTypeArguments
if m.Attributes |> Seq.isEmpty |> not then
yield span [] [
yield strong [] [
str "Attributes:"
]
yield br []
for attr in m.Attributes do
yield str (attr.Format())
yield br []
]
]
let obsoleteMessage (m: Member) = seq {
if m.IsObsolete then
yield div [
Class "alert alert-warning"
] [
strong [] [
str "WARNING:"
]
str "This API is obsolete"
p [] [
str m.ObsoleteMessage
]
]
}
let repoSourceLink (m: Member) = seq {
if m.Details.FormatSourceLocation |> String.IsNullOrEmpty |> not then
yield a [
Href m.Details.FormatSourceLocation
Class "github-link"
] [
yield img [
Src "../content/img/github.png"
Class "github-link"
]
yield img [
Src "../content/img/github-blue.png"
Class "normal"
]
]
}
let commentBlock (c: Comment) =
let (|EmptyDefaultBlock|NonEmptyDefaultBlock|Section|) (KeyValue(section, content)) =
match section, content with
| "<default>", c when String.IsNullOrEmpty c -> EmptyDefaultBlock
| "<default>", c -> NonEmptyDefaultBlock c
| section, content -> Section (section, content)
let renderSection s: Fable.Import.React.ReactElement list =
match s with
| EmptyDefaultBlock -> []
| NonEmptyDefaultBlock content -> [ div [ Class "comment-block" ] [ RawText content ] ]
| Section(name, content) -> [ h2 [] [ str name ]
RawText content ]
c.Sections
|> List.collect renderSection
let compiledName (m: Member) = seq {
if m.Details.FormatCompiledName |> String.IsNullOrEmpty |> not then
yield p [] [
strong [] [ str "CompiledName:" ]
code [] [ str m.Details.FormatCompiledName ]
]
}
let partMembers (header : string) (tableHeader : string) (members : #seq<Member>) = [
if members |> Seq.length > 0 then
yield h3 [] [
str header
]
yield table [
Class "table"
] [
thead [] [
tr [] [
th [] [
str tableHeader
]
th [] [
str "Description"
]
]
]
tbody [] [
for it in members do
let id = Guid.NewGuid().ToString()
yield tr [] [
td [
Class "member-name"
] [
code [
Class "function-or-value"
HTMLAttr.Custom("data-guid", id)
] [
str (it.Details.FormatUsage(40))
]
tooltip it id
]
td [
Class "xmldoc"
] [
yield! obsoleteMessage it
yield! repoSourceLink it
// printfn "%s:\n%A" it.Name it.Comment
yield! commentBlock it.Comment
yield! compiledName it
]
]
]
]
]