@@ -3,6 +3,7 @@ module rec Glutinum.Converter.Transform
3
3
open Fable.Core
4
4
open Glutinum.Converter .FSharpAST
5
5
open Glutinum.Converter .GlueAST
6
+ open System
6
7
7
8
// Not really proud of this implementation, but I was not able to make it in a
8
9
// pure functional way, using a Tree structure or something similar
@@ -88,23 +89,47 @@ let private sanitizeNameAndPushScope
88
89
( name, context)
89
90
90
91
let private transformComment ( comment : GlueAST.GlueComment list ) =
91
- comment
92
- |> List.map ( fun comment ->
93
- match comment with
94
- | GlueComment.Summary summary -> FSharpXmlDoc.Summary summary
95
- | GlueComment.Returns returns -> FSharpXmlDoc.Returns returns
96
- | GlueComment.Param param ->
97
- let content =
98
- param.Content
99
- |> Option.map ( fun content ->
100
- content.TrimStart() .TrimStart( '-' ) .TrimStart()
101
- )
102
- |> Option.defaultValue " "
92
+ let deprecated , others =
93
+ comment
94
+ |> List.partition (
95
+ function
96
+ | GlueComment.Deprecated _ -> true
97
+ | _ -> false
103
98
104
- ({ Name = param.Name; Content = content }: FSharpCommentParam)
105
- |> FSharpXmlDoc.Param
106
- | GlueComment.Remarks remarks -> FSharpXmlDoc.Remarks remarks
107
- )
99
+ )
100
+
101
+ let obsoleteAttributes =
102
+ deprecated
103
+ |> List.map (
104
+ function
105
+ | GlueComment.Deprecated content -> FSharpAttribute.Obsolete content
106
+ | _ -> failwith " Should not happen"
107
+ )
108
+
109
+ let others =
110
+ others
111
+ |> List.map ( fun comment ->
112
+ match comment with
113
+ | GlueComment.Deprecated _ -> failwith " Should not happen"
114
+ | GlueComment.Summary summary -> FSharpXmlDoc.Summary summary
115
+ | GlueComment.Returns returns -> FSharpXmlDoc.Returns returns
116
+ | GlueComment.Param param ->
117
+ let content =
118
+ param.Content
119
+ |> Option.map ( fun content ->
120
+ content.TrimStart() .TrimStart( '-' ) .TrimStart()
121
+ )
122
+ |> Option.defaultValue " "
123
+
124
+ ({ Name = param.Name; Content = content }: FSharpCommentParam)
125
+ |> FSharpXmlDoc.Param
126
+ | GlueComment.Remarks remarks -> FSharpXmlDoc.Remarks remarks
127
+ )
128
+
129
+ {|
130
+ ObsoleteAttributes = obsoleteAttributes
131
+ Others = others
132
+ |}
108
133
109
134
let private transformLiteral ( glueLiteral : GlueLiteral ) : FSharpLiteral =
110
135
match glueLiteral with
@@ -351,8 +376,14 @@ let private transformExports
351
376
| GlueType.FunctionDeclaration info ->
352
377
let name , context = sanitizeNameAndPushScope info.Name context
353
378
379
+ let xmlDocInfo = transformComment info.Documentation
380
+
354
381
{
355
- Attributes = [ FSharpAttribute.Import( info.Name, " module" ) ]
382
+ Attributes =
383
+ [
384
+ FSharpAttribute.Import( info.Name, " module" )
385
+ yield ! xmlDocInfo.ObsoleteAttributes
386
+ ]
356
387
Name = name
357
388
OriginalName = info.Name
358
389
Parameters =
@@ -364,7 +395,7 @@ let private transformExports
364
395
IsStatic = true
365
396
Accessor = None
366
397
Accessibility = FSharpAccessibility.Public
367
- XmlDoc = transformComment info.Documentation
398
+ XmlDoc = xmlDocInfo.Others
368
399
}
369
400
|> FSharpMember.Method
370
401
|> List.singleton
0 commit comments