forked from elastic/elasticsearch-net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InheritDoc.fsx
25 lines (23 loc) · 1.08 KB
/
InheritDoc.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
#r "System.Xml.Linq.dll"
open System.Xml
open System.Xml.XPath
open System.Linq
open System.Xml.Linq
open System.Text.RegularExpressions
let PatchXmlDoc = fun (file: string) ->
let xml = XDocument.Load file
let nodes = xml.XPathSelectElements("//inheritdoc")
|> Seq.map (fun n ->
let methodName = n.Parent.Attribute(XName.Get("name")).Value
let interfaceName = Regex.Replace(methodName, @"\.([^.]+\.[^.]+\()", ".I$1")
let interfaceNode = xml.XPathSelectElement (sprintf "//member[@name='%s']" interfaceName)
(n.Parent, interfaceNode)
)
|> Seq.filter (fun (implementationElement, interfaceElement) ->
interfaceElement <> null && implementationElement.HasElements && interfaceElement.HasElements
)
let nodesReplace = nodes
|> Seq.iter (fun (implementationElement, interfaceElement) ->
implementationElement.Add (interfaceElement.Descendants().ToList())
)
xml.Save file