Skip to content

Commit 85cdf95

Browse files
Stuart Camrusscam
authored andcommitted
Use the version number present in the global.json file when generating documentation. (#3557)
1 parent 6e85885 commit 85cdf95

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/CodeGeneration/DocGenerator/Program.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using System;
22
using System.Diagnostics;
33
using System.IO;
4+
using System.Linq;
5+
using System.Text.RegularExpressions;
46

57
namespace DocGenerator
68
{
@@ -14,6 +16,7 @@ string P(string path)
1416
}
1517

1618
var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory());
19+
var globalJson = P(@"..\..\..\global.json");
1720
if (currentDirectory.Name == "DocGenerator" && currentDirectory.Parent.Name == "CodeGeneration")
1821
{
1922
Console.WriteLine("IDE: " + currentDirectory);
@@ -23,12 +26,21 @@ string P(string path)
2326
}
2427
else
2528
{
29+
globalJson = P(@"..\..\..\..\global.json");
2630
Console.WriteLine("CMD: " + currentDirectory);
2731
InputDirPath = P(@"..\..\..\..\src");
2832
OutputDirPath = P(@"..\..\..\..\docs");
2933
BuildOutputPath = P(@"..\..\..\..\build\output");
3034
}
3135

36+
var globalJsonVersion = string.Join(".", Regex.Matches(File.ReadAllText(globalJson), "\"version\": \"(.*)\"")
37+
.Last().Groups
38+
.Last().Value
39+
.Split(".")
40+
.Take(2));
41+
Console.WriteLine("Using global.json version: " + globalJsonVersion);
42+
DocVersion = globalJsonVersion;
43+
3244
var process = new Process
3345
{
3446
StartInfo = new ProcessStartInfo
@@ -68,7 +80,7 @@ string P(string path)
6880
/// <summary>
6981
/// The Elasticsearch documentation version to link to
7082
/// </summary>
71-
public static string DocVersion => "6.4";
83+
public static string DocVersion { get; set; }
7284

7385
public static string InputDirPath { get; }
7486

0 commit comments

Comments
 (0)