|
7 | 7 | #load @"Tooling.fsx" |
8 | 8 | #load @"Projects.fsx" |
9 | 9 |
|
10 | | -open Microsoft.FSharp.Reflection |
11 | 10 | open System |
12 | | -open System.Collections.Generic |
| 11 | +open System.IO |
| 12 | + |
| 13 | +open Fake |
| 14 | +open System |
13 | 15 | open System.IO |
14 | 16 | open System.Linq |
15 | 17 | open System.Net |
16 | 18 | open System.Text |
17 | 19 | open System.Text.RegularExpressions |
18 | 20 | open System.Xml |
19 | 21 | open System.Xml.Linq |
20 | | -open Fake |
21 | 22 | open Fake.Git.CommandHelper |
| 23 | + |
22 | 24 | open Paths |
23 | 25 | open Projects |
24 | 26 | open Tooling |
@@ -262,63 +264,42 @@ module Differ = |
262 | 264 | | :? XmlException -> ignore() |
263 | 265 |
|
264 | 266 | let private convertToAsciidoc path first second = |
265 | | - let createDiffDescription description (writer:TextWriter) = |
266 | | - let m = Regex.Match(description, "(.*?) changed from (.*?) to (.*).") |
267 | | - if m.Success then |
268 | | - let memberType = m.Groups.[1].Value |
269 | | - let o = m.Groups.[2].Value |
270 | | - let n = m.Groups.[3].Value |
271 | | - writer.WriteLine("+") |
272 | | - writer.WriteLine(sprintf "%s change" memberType) |
273 | | - writer.WriteLine("+") |
274 | | - writer.WriteLine("[source,csharp]") |
275 | | - writer.WriteLine("----") |
276 | | - writer.WriteLine(sprintf "// before in %s" first) |
277 | | - writer.WriteLine(sprintf "%s" o) |
278 | | - writer.WriteLine(sprintf "// now in %s" second) |
279 | | - writer.WriteLine(sprintf "%s" n) |
280 | | - writer.WriteLine("----") |
281 | | - else |
282 | | - writer.WriteLine(sprintf "%s" description) |
283 | | - |
284 | 267 | let name = path |> Path.GetFileNameWithoutExtension |
285 | 268 | try |
286 | 269 | let doc = XDocument.Load path |
287 | 270 | let output = Path.ChangeExtension(path, "asciidoc") |
288 | 271 | DeleteFile output |
289 | 272 | use file = File.OpenWrite <| output |
290 | 273 | use writer = new StreamWriter(file) |
291 | | - writer.WriteLine(name |> replace "." "-" |> toLower |> sprintf "[[%s-breaking-changes]]") |
| 274 | + writer.WriteLine(name |> replace "." "-" |> sprintf "[[%s-breaking-changes]]") |
292 | 275 | writer.WriteLine(sprintf "== Breaking changes for %s between %s and %s" name first second) |
293 | 276 | writer.WriteLine() |
294 | 277 |
|
295 | 278 | for element in (doc |> descendents "Type") do |
296 | 279 | let typeName = element |> attributeValue "Name" |> replace (sprintf "%s." name) "" |
297 | 280 | let diffType = element |> attributeValue "DiffType" |> convertDiffType |
298 | | - |
299 | 281 | match diffType with |
300 | | - | Deleted -> writer.WriteLine(sprintf "`%s`:: deleted" typeName) |
301 | | - | New -> writer.WriteLine(sprintf "`%s`:: added" typeName) |
| 282 | + | Deleted -> writer.WriteLine(sprintf "[float]%s=== `%s` is deleted" Environment.NewLine typeName) |
| 283 | + | New -> writer.WriteLine(sprintf "[float]%s=== `%s` is added" Environment.NewLine typeName) |
302 | 284 | | Modified -> |
303 | 285 | let members = Seq.append (element |> elements "Method") (element |> elements "Property") |
304 | 286 | if Seq.isEmpty members |> not then |
305 | | - writer.WriteLine(sprintf "`%s`::" typeName) |
| 287 | + writer.WriteLine(sprintf "[float]%s=== `%s`" Environment.NewLine typeName) |
306 | 288 | for m in members do |
307 | 289 | let memberName = m |> attributeValue "Name" |
308 | 290 | if isNotNullOrEmpty memberName then |
309 | 291 | let diffType = m |> attributeValue "DiffType" |
310 | 292 | if isNotNullOrEmpty diffType then |
311 | 293 | match convertDiffType diffType with |
312 | | - | Deleted -> writer.WriteLine(sprintf " * `%s` deleted" memberName) |
313 | | - | New -> writer.WriteLine(sprintf " * `%s` added" memberName) |
| 294 | + | Deleted -> writer.WriteLine(sprintf "[float]%s==== `%s` is deleted" Environment.NewLine memberName) |
| 295 | + | New -> writer.WriteLine(sprintf "[float]%s==== `%s` is added" Environment.NewLine memberName) |
314 | 296 | | Modified -> |
315 | 297 | match (m.Descendants(XName.op_Implicit "DiffItem") |> Seq.tryHead) with |
316 | 298 | | Some diffItem -> |
317 | | - writer.WriteLine(sprintf " * `%s`" memberName) |
| 299 | + writer.WriteLine(sprintf "[float]%s==== `%s`" Environment.NewLine memberName) |
318 | 300 | let diffDescription = diffItem.Value |
319 | | - writer |> createDiffDescription diffDescription |
| 301 | + writer.WriteLine(Regex.Replace(diffDescription, "changed from (.*?) to (.*).", "changed from `$1` to `$2`.")) |
320 | 302 | | None -> () |
321 | | - writer.WriteLine() |
322 | 303 | with |
323 | 304 | | :? XmlException -> ignore() |
324 | 305 |
|
|
0 commit comments