From 6e4a6b63a8d6e63a1c89733bb69a2150ebf0deaf Mon Sep 17 00:00:00 2001 From: Matthias Dittrich Date: Fri, 20 Nov 2015 20:43:55 +0100 Subject: [PATCH] use FAKE for documentation generation. --- build.template | 50 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/build.template b/build.template index 4077600..7cab52f 100644 --- a/build.template +++ b/build.template @@ -182,22 +182,52 @@ Target "PublishNuget" (fun _ -> // -------------------------------------------------------------------------------------- // Generate the documentation + +let fakePath = "packages" @@ "FAKE" @@ "tools" @@ "FAKE.exe" +let fakeStartInfo script workingDirectory args fsiargs environmentVars = + (fun (info: System.Diagnostics.ProcessStartInfo) -> + info.FileName <- System.IO.Path.GetFullPath fakePath + info.Arguments <- sprintf "%s --fsiargs -d:FAKE %s \"%s\"" args fsiargs script + info.WorkingDirectory <- workingDirectory + let setVar k v = + info.EnvironmentVariables.[k] <- v + for (k, v) in environmentVars do + setVar k v + setVar "MSBuild" msBuildExe + setVar "GIT" Git.CommandHelper.gitPath + setVar "FSI" fsiPath) + +/// Run the given buildscript with FAKE.exe +let executeFAKEWithOutput workingDirectory script fsiargs envArgs = + let exitCode = + ExecProcessWithLambdas + (fakeStartInfo script workingDirectory "" fsiargs envArgs) + TimeSpan.MaxValue false ignore ignore + System.Threading.Thread.Sleep 1000 + exitCode + +// Documentation +let buildDocumentationTarget fsiargs target = + trace (sprintf "Building documentation (%s), this could take some time, please wait..." target) + let exit = executeFAKEWithOutput "docs/tools" "generate.fsx" fsiargs ["target", target] + if exit <> 0 then + failwith "generating reference documentation failed" + () + Target "GenerateReferenceDocs" (fun _ -> - if not <| executeFSIWithArgs "docs/tools" "generate.fsx" ["--define:RELEASE"; "--define:REFERENCE"] [] then - failwith "generating reference documentation failed" + buildDocumentationTarget "-d:RELEASE -d:REFERENCE" "Default" ) let generateHelp' fail debug = let args = - if debug then ["--define:HELP"] - else ["--define:RELEASE"; "--define:HELP"] - if executeFSIWithArgs "docs/tools" "generate.fsx" args [] then + if debug then "--define:HELP" + else "--define:RELEASE --define:HELP" + try + buildDocumentationTarget args "Default" traceImportant "Help generated" - else - if fail then - failwith "generating help documentation failed" - else - traceImportant "generating help documentation failed" + with + | e when not fail -> + traceImportant "generating help documentation failed" let generateHelp fail = generateHelp' fail false