From 7790ec3038b57bf23de2a89bd6bc6e852343e125 Mon Sep 17 00:00:00 2001 From: exyi Date: Tue, 23 Jan 2018 09:36:04 +0000 Subject: [PATCH] Added a script to complete xml documentation with tags It allows us to write comments without the section, as the script completes them to fulfill VisualStudio. --- .../ViewModel/AllowStaticCommandAttribute.cs | 1 + src/Tools/add-summary-comments.fsx | 40 +++++++++++++++++++ src/Tools/build/publish.ps1 | 8 +++- 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100755 src/Tools/add-summary-comments.fsx diff --git a/src/DotVVM.Core/ViewModel/AllowStaticCommandAttribute.cs b/src/DotVVM.Core/ViewModel/AllowStaticCommandAttribute.cs index 20d05ddf16..e4c80ee2f3 100644 --- a/src/DotVVM.Core/ViewModel/AllowStaticCommandAttribute.cs +++ b/src/DotVVM.Core/ViewModel/AllowStaticCommandAttribute.cs @@ -2,6 +2,7 @@ namespace DotVVM.Framework.ViewModel { + /// Allows remote invocation of this method from a staticCommand binding public class AllowStaticCommandAttribute: Attribute { } diff --git a/src/Tools/add-summary-comments.fsx b/src/Tools/add-summary-comments.fsx new file mode 100755 index 0000000000..ffcbc7691d --- /dev/null +++ b/src/Tools/add-summary-comments.fsx @@ -0,0 +1,40 @@ +#!/usr/bin/fsharpi + +#r "System.Xml.Linq" +open System +open System.Xml.Linq +let rootElements = Set.ofList [ "example"; "code"; "exception"; "include"; "returns"; "param"; "permission"; "remark"; "seealso"; "value"; "typeparam" ] +let filePath : string option = + if fsi.CommandLineArgs.Length <> 2 then + None + else + Some fsi.CommandLineArgs.[1] +let xml = + match filePath with + | Some file -> XDocument.Load(file) + | None -> XDocument.Parse(Console.In.ReadToEnd()) +let n = XName.Get +// get elements that does not contain +let rawTexts = xml.Root.Element(n "members").Elements(n "member") |> Seq.filter (fun e -> e.Elements(n "summary") |> Seq.isEmpty) +for doccomment in rawTexts do + let nodes = + doccomment.Nodes() + |> Seq.filter (function + | :? XElement as element -> + // filter non-global elements + not <| Set.contains element.Name.LocalName rootElements + | :? XText as text -> + not <| String.IsNullOrEmpty text.Value + | _ -> true) + |> Seq.toArray + for n in nodes do + n.Remove() + + if nodes.Length > 0 then + doccomment.AddFirst( + XElement(n "summary", box nodes) + ) + +match filePath with +| Some file -> xml.Save(file) +| None -> xml.Save(Console.Out) diff --git a/src/Tools/build/publish.ps1 b/src/Tools/build/publish.ps1 index d9347ee4c9..077a0ba628 100644 --- a/src/Tools/build/publish.ps1 +++ b/src/Tools/build/publish.ps1 @@ -58,6 +58,7 @@ function SetVersion() { } function BuildPackages() { + $transformComments = [System.IO.Path]::GetFullPath("Tools/add-summary-comments.fsx") foreach ($package in $packages) { cd .\$($package.Directory) @@ -68,7 +69,12 @@ function BuildPackages() { & dotnet restore --source $nugetRestoreAltSource --source https://nuget.org/api/v2/ | Out-Host } - & dotnet pack | Out-Host + & dotnet build --no-incremental --configuration Release | Out-Host + foreach($commentFile in (ls ./bin/Release/*/*.xml)) { + fsi $transformComments $commentFile + echo "Processed doccomment file $commentFile" + } + & dotnet pack --configuration Release --no-build | Out-Host cd .. } }