Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/#1177 docfx helper #1251

Merged
merged 3 commits into from
May 30, 2016
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
60 changes: 60 additions & 0 deletions src/app/FakeLib/DocFxHelper.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
[<AutoOpen>]
/// 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
/// Serves the generated documentation on localhost. Default: false
Serve : bool
}

/// 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.
Serve = false
}

/// 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 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
info.Arguments <- args
info.WorkingDirectory <- parameters.WorkingDirectory
) parameters.Timeout
then failwith "DocFx generation failed."

traceEndTask "DocFx" parameters.DocFxJson

1 change: 1 addition & 0 deletions src/app/FakeLib/FakeLib.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@
<Compile Include="SlackNotificationHelper.fs" />
<Compile Include="SonarQubeHelper.fs" />
<Compile Include="AzureKudu.fs" />
<Compile Include="DocFxHelper.fs" />
</ItemGroup>
<ItemGroup>
<Reference Include="ICSharpCode.SharpZipLib">
Expand Down