From c48fe3819bb83d02f5cebc05e70a0760ba5fecfa Mon Sep 17 00:00:00 2001 From: shortsn Date: Fri, 27 May 2016 23:40:48 +0200 Subject: [PATCH 1/3] #1177 DocFx - Helper --- src/app/FakeLib/DocFxHelper.fs | 53 ++++++++++++++++++++++++++++++++++ src/app/FakeLib/FakeLib.fsproj | 1 + 2 files changed, 54 insertions(+) create mode 100644 src/app/FakeLib/DocFxHelper.fs diff --git a/src/app/FakeLib/DocFxHelper.fs b/src/app/FakeLib/DocFxHelper.fs new file mode 100644 index 00000000000..23306a67879 --- /dev/null +++ b/src/app/FakeLib/DocFxHelper.fs @@ -0,0 +1,53 @@ +[] +/// Contains helper functions to run the documentation tool "docfx". +module Fake.DocFxHelper + +open System + +/// The parameter type for DocFx. +type DocFxParams = + { /// The tool path - FAKE tries to find docfx.exe automatically in any sub folder. + ToolPath : string + /// the DocFxJson Config-File. Default: docs/docfx.json + DocFxJson : string + /// DocFx WorkingDirectory. Default: docs + WorkingDirectory : string + /// Allows to specify a timeout for DocFx. Default: 5 min + Timeout : TimeSpan + } + +/// The default parameters +let DocFxDefaults = + let toolPath = findToolInSubPath "docfx.exe" (currentDirectory @@ "tools" @@ "docfx.msbuild") + let docsPath = currentDirectory @@ "docs" + { ToolPath = toolPath + DocFxJson = docsPath @@ "docfx.json" + WorkingDirectory = docsPath + Timeout = TimeSpan.FromMinutes 5. + } + +/// Generates a DocFx documentation. +/// ## Parameters +/// - `setParams` - Function used to manipulate the default DocFx parameters. See `DocFxDefaults` +/// ## Sample +/// +/// DocFx (fun p -> +/// { p with +/// DocFxJson = "foo" @@ "bar" @@ "docfx.json" +/// Timeout = TimeSpan.FromMinutes 10. +/// }) +let DocFx setParams = + let parameters = DocFxDefaults |> setParams + + traceStartTask "DocFx" parameters.DocFxJson + + let args = parameters.DocFxJson |> FullName + + if 0 <> ExecProcess (fun info -> + info.FileName <- parameters.ToolPath |> FullName + info.Arguments <- args + info.WorkingDirectory <- parameters.WorkingDirectory + ) parameters.Timeout + then failwith "DocFx generation failed." + + traceEndTask "DocFx" parameters.DocFxJson \ No newline at end of file diff --git a/src/app/FakeLib/FakeLib.fsproj b/src/app/FakeLib/FakeLib.fsproj index 762eb3f2b6b..ec609bcef35 100644 --- a/src/app/FakeLib/FakeLib.fsproj +++ b/src/app/FakeLib/FakeLib.fsproj @@ -180,6 +180,7 @@ + From 0c029bf3667f36be190fc04feaec7947a29c6845 Mon Sep 17 00:00:00 2001 From: shortsn Date: Sat, 28 May 2016 00:11:34 +0200 Subject: [PATCH 2/3] #1177 support for serve parameter --- src/app/FakeLib/DocFxHelper.fs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/app/FakeLib/DocFxHelper.fs b/src/app/FakeLib/DocFxHelper.fs index 23306a67879..77ec65256f3 100644 --- a/src/app/FakeLib/DocFxHelper.fs +++ b/src/app/FakeLib/DocFxHelper.fs @@ -14,6 +14,8 @@ type DocFxParams = WorkingDirectory : string /// Allows to specify a timeout for DocFx. Default: 5 min Timeout : TimeSpan + /// Serves the generated documentation on localhost. Default: false + Serve : bool } /// The default parameters @@ -24,6 +26,7 @@ let DocFxDefaults = DocFxJson = docsPath @@ "docfx.json" WorkingDirectory = docsPath Timeout = TimeSpan.FromMinutes 5. + Serve = false } /// Generates a DocFx documentation. @@ -31,17 +34,20 @@ let DocFxDefaults = /// - `setParams` - Function used to manipulate the default DocFx parameters. See `DocFxDefaults` /// ## Sample /// -/// DocFx (fun p -> -/// { p with -/// DocFxJson = "foo" @@ "bar" @@ "docfx.json" -/// Timeout = TimeSpan.FromMinutes 10. -/// }) +/// DocFx (fun p -> +/// { p with +/// DocFxJson = "foo" @@ "bar" @@ "docfx.json" +/// Timeout = TimeSpan.FromMinutes 10. +/// }) let DocFx setParams = let parameters = DocFxDefaults |> setParams traceStartTask "DocFx" parameters.DocFxJson - let args = parameters.DocFxJson |> FullName + let serveArg = if parameters.Serve then "--serve" else "" + let configArg = parameters.DocFxJson |> FullName + + let args = sprintf "%s %s" configArg serveArg if 0 <> ExecProcess (fun info -> info.FileName <- parameters.ToolPath |> FullName From 847e946cd82b0a51bcd05cb09b5107c884bfdf6b Mon Sep 17 00:00:00 2001 From: shortsn Date: Mon, 30 May 2016 17:35:28 +0200 Subject: [PATCH 3/3] empty commit to trigger build again --- src/app/FakeLib/DocFxHelper.fs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/FakeLib/DocFxHelper.fs b/src/app/FakeLib/DocFxHelper.fs index 77ec65256f3..5ad6fc0a541 100644 --- a/src/app/FakeLib/DocFxHelper.fs +++ b/src/app/FakeLib/DocFxHelper.fs @@ -56,4 +56,5 @@ let DocFx setParams = ) parameters.Timeout then failwith "DocFx generation failed." - traceEndTask "DocFx" parameters.DocFxJson \ No newline at end of file + traceEndTask "DocFx" parameters.DocFxJson +