Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions build/scripts/InheritDoc.fsx

This file was deleted.

11 changes: 10 additions & 1 deletion build/scripts/Paths.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ module Projects =

type PrivateProject =
| Tests



type DotNetProject =
| Project of Project
Expand Down Expand Up @@ -58,6 +60,13 @@ module Projects =
DotNetProject.All
|> Seq.map(fun p -> p.Name)
|> Seq.tryFind(fun p -> p.ToLowerInvariant() = name.ToLowerInvariant())

type DotNetFrameworkProject = { framework: DotNetFramework; project: DotNetProject }
let AllPublishableProjectsWithSupportedFrameworks = seq {
for framework in DotNetFramework.All do
for project in DotNetProject.AllPublishable do
yield { framework = framework; project= project}
}


module Paths =
Expand All @@ -71,7 +80,7 @@ module Paths =

let ProjectOutputFolder (project:DotNetProject) (framework:DotNetFramework) =
sprintf "%s/%s/%s" BuildOutput framework.Identifier.MSBuild project.Name

let Tool tool = sprintf "packages/build/%s" tool
let CheckedInToolsFolder = "build/Tools"
let KeysFolder = sprintf "%s/keys" BuildFolder
Expand Down
5 changes: 5 additions & 0 deletions build/scripts/Targets.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#load @"Documentation.fsx"
#load @"Releasing.fsx"
#load @"Profiling.fsx"
#load @"XmlDocPatcher.fsx"

open System

Expand All @@ -17,6 +18,7 @@ open Signing
open Versioning
open Releasing
open Profiling
open XmlDocPatcher

// Default target
Target "Build" <| fun _ -> traceHeader "STARTING BUILD"
Expand All @@ -27,6 +29,8 @@ Target "BuildApp" <| fun _ -> Build.Compile()

Target "Test" <| fun _ -> Tests.RunUnitTests()

Target "InheritDoc" <| fun _ -> InheritDoc.patchInheritDocs()

Target "TestForever" <| fun _ -> Tests.RunUnitTestsForever()

Target "QuickTest" <| fun _ -> Tests.RunUnitTests()
Expand Down Expand Up @@ -59,6 +63,7 @@ Target "Canary" <| fun _ ->
=?> ("Version", hasBuildParam "version")
==> "BuildApp"
=?> ("Test", (not ((getBuildParam "skiptests") = "1")))
==> "InheritDoc"
==> "Build"

"Clean"
Expand Down
95 changes: 95 additions & 0 deletions build/scripts/XmlDocPatcher.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#I @"../../packages/build/FAKE/tools"
#r @"FakeLib.dll"
#r "System.Xml.Linq.dll"

#load @"Paths.fsx"

namespace XmlDocPatcher

open System.Linq
open System.Text.RegularExpressions
open System.Xml
open System.Xml.Linq
open System.Xml.XPath

open Paths
open Projects
open Fake


module InheritDoc =

let private apiName n = Regex.Replace(n, @"^\w\:(.+?)(?:\(.+$|$)", "$1")
let private relatedInterface n = Regex.Replace(n, @"\.([^.]+\.[^.]+)$", ".I$1")
let private relatedInterfaceAsync n = (relatedInterface n).Replace("Async", "")
let private relatedInterfaceDescriptor n = Regex.Replace(n, @"\.([^.]+)Descriptor\.([^.]+)$", ".I$1.$2")
let private relatedInterfaceDescriptorRequest n = Regex.Replace(n, @"\.([^.]+)Descriptor\.([^.]+)$", ".I$1Request.$2")
let private relatedInterfaceDescriptorGeneric n = Regex.Replace(n, @"\.([^.]+)Descriptor[^.]+.([^.]+)$", ".I$1.$2")
let private manualMapping (n : string) =
//this sucks but untill roslyn gets coderewriting API's this is the best we got without making it
//a bigger thing than it already is
match n with
| n when n.Contains("PutMapping") -> n.Replace("PutMapping", "TypeMapping")
| _ -> n
let private relatedApiLookups = [
relatedInterface;
relatedInterfaceAsync;
relatedInterfaceDescriptor;
relatedInterfaceDescriptorRequest;
relatedInterfaceDescriptorGeneric;
manualMapping
];

let private documentedApis = fun (file : string) ->
use reader = XmlReader.Create file
seq {
while reader.ReadToFollowing("member") do
let name = apiName(reader.GetAttribute("name"))
let innerXml = reader.ReadInnerXml().Trim();
if (isNotNullOrEmpty innerXml && not (innerXml.Contains("<inheritdoc"))) then
let xdoc = XDocument.Parse("<x>" + innerXml + "</x>")
yield (name, xdoc)
} |> Map.ofSeq

let private patchInheritDoc = fun file ->
traceFAKE "Rewriting xmldoc: %s" file

let mapOfDocumentedApis = documentedApis file

let findDocumentation (apiElement:string) =
relatedApiLookups
|> Seq.map (fun f -> f apiElement)
|> (Seq.map <| mapOfDocumentedApis.TryFind)
|> Seq.choose id
|> Seq.tryHead

let xml = XDocument.Load file

xml.XPathSelectElements("//inheritdoc")
|> Seq.iter (fun inheritDocElement ->
let parent =inheritDocElement.Parent
let name = apiName (parent.Attribute(XName.Get "name").Value)
let documentation = findDocumentation name

match documentation with
| Some d ->
let elements = d.Element(XName.Get("x")).Elements().ToList();
inheritDocElement.AddBeforeSelf(elements)
| _ ->
//unignore the following to find undocumented/badly inherited methods
//tracefn "not inherited: %s" apiElement
ignore()
)

use writer = new XmlTextWriter(file,null)
writer.Formatting <- Formatting.Indented;
xml.Save(writer);

let patchInheritDocs = fun () ->
AllPublishableProjectsWithSupportedFrameworks
|> Seq.map (fun p ->
let folder = Paths.ProjectOutputFolder p.project p.framework
folder @@ p.project.Name + ".xml"
)
|> Seq.filter fileExists
|> Seq.iter patchInheritDoc
4 changes: 2 additions & 2 deletions build/scripts/scripts.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<None Include="Releasing.fsx" />
<None Include="Versioning.fsx" />
<None Include="Profiling.fsx" />
<None Include="InheritDoc.fsx" />
<None Include="XmlDocPatcher.fsx" />
<None Include="Building.fsx" />
<None Include="Signing.fsx" />
<None Include="Testing.fsx" />
Expand All @@ -85,4 +85,4 @@
<Private>True</Private>
</Reference>
</ItemGroup>
</Project>
</Project>
4 changes: 2 additions & 2 deletions src/Nest/QueryDsl/FullText/CommonTerms/CommonTermsQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public class CommonTermsQuery : FieldNameQueryBase, ICommonTermsQuery
internal static bool IsConditionless(ICommonTermsQuery q) => q.Field.IsConditionless() || q.Query.IsNullOrEmpty();
}

public class CommonTermsQueryDescriptor<T>
public class CommonTermsQueryDescriptor<T>
: FieldNameQueryDescriptorBase<CommonTermsQueryDescriptor<T>, ICommonTermsQuery, T>
, ICommonTermsQuery
, ICommonTermsQuery
where T : class
{
string IQuery.Name { get; set; }
Expand Down