Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a script to complete xml documentation with <summary> tags #534

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/DotVVM.Core/ViewModel/AllowStaticCommandAttribute.cs
Expand Up @@ -2,6 +2,7 @@

namespace DotVVM.Framework.ViewModel
{
/// Allows remote invocation of this method from a staticCommand binding
public class AllowStaticCommandAttribute: Attribute
{
}
Expand Down
40 changes: 40 additions & 0 deletions 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 <summary>
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)
8 changes: 7 additions & 1 deletion src/Tools/build/publish.ps1
Expand Up @@ -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)

Expand All @@ -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 ..
}
}
Expand Down