From 8951ef4ab790305165bfaf8f1552de35be4399b1 Mon Sep 17 00:00:00 2001 From: Stuart Cam Date: Wed, 30 Jan 2019 14:57:44 +1100 Subject: [PATCH] Use the version number present in the global.json file when generating documentation. --- src/CodeGeneration/DocGenerator/Program.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/CodeGeneration/DocGenerator/Program.cs b/src/CodeGeneration/DocGenerator/Program.cs index e1e95b3de6b..2c66c86d965 100644 --- a/src/CodeGeneration/DocGenerator/Program.cs +++ b/src/CodeGeneration/DocGenerator/Program.cs @@ -1,6 +1,8 @@ using System; using System.Diagnostics; using System.IO; +using System.Linq; +using System.Text.RegularExpressions; namespace DocGenerator { @@ -14,6 +16,7 @@ string P(string path) } var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory()); + var globalJson = P(@"..\..\..\global.json"); if (currentDirectory.Name == "DocGenerator" && currentDirectory.Parent.Name == "CodeGeneration") { Console.WriteLine("IDE: " + currentDirectory); @@ -23,12 +26,21 @@ string P(string path) } else { + globalJson = P(@"..\..\..\..\global.json"); Console.WriteLine("CMD: " + currentDirectory); InputDirPath = P(@"..\..\..\..\src"); OutputDirPath = P(@"..\..\..\..\docs"); BuildOutputPath = P(@"..\..\..\..\build\output"); } + var globalJsonVersion = string.Join(".", Regex.Matches(File.ReadAllText(globalJson), "\"version\": \"(.*)\"") + .Last().Groups + .Last().Value + .Split(".") + .Take(2)); + Console.WriteLine("Using global.json version: " + globalJsonVersion); + DocVersion = globalJsonVersion; + var process = new Process { StartInfo = new ProcessStartInfo @@ -68,7 +80,7 @@ string P(string path) /// /// The Elasticsearch documentation version to link to /// - public static string DocVersion => "6.4"; + public static string DocVersion { get; set; } public static string InputDirPath { get; }