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

Move docsTool netcoreapp3.1 and better test assertions #179

Merged
merged 10 commits into from
Jan 23, 2020
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
126 changes: 64 additions & 62 deletions Content/Library/docsTool/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ module GenerateDocs =
libDirs
|> Array.map(fun fi -> fi.DirectoryName)
|> Array.distinct
|> Array.map(sprintf "-I:%s")
|> Array.map(sprintf "-I:\"%s\"")
let runtimeDeps =
[|
"-r:System.Runtime"
Expand Down Expand Up @@ -305,8 +305,7 @@ module GenerateDocs =
let generate (projInfo : ProjInfo.ProjInfo) =
Trace.tracefn "Generating API Docs for %s" projInfo.TargetPath.FullName
let mscorlibDir =
(Uri(typedefof<System.Runtime.MemoryFailPoint>.GetType().Assembly.CodeBase)) //Find runtime dll
.AbsolutePath // removes file protocol from path
(typedefof<System.Runtime.MemoryFailPoint>.GetType().Assembly.Location) //Find runtime dll]
|> Path.GetDirectoryName
let references =
projInfo.References
Expand All @@ -315,7 +314,6 @@ module GenerateDocs =
|> List.distinct
let libDirs = mscorlibDir :: references
let targetApiDir = docsApiDir cfg.DocsOutputDirectory.FullName @@ IO.Path.GetFileNameWithoutExtension(projInfo.TargetPath.Name)

let generatorOutput =
MetadataFormat.Generate(
projInfo.TargetPath.FullName,
Expand Down Expand Up @@ -525,62 +523,66 @@ open Fake.IO.Globbing.Operators
open DocsTool.CLIArgs
[<EntryPoint>]
let main argv =
use tempDocsOutDir = DisposableDirectory.Create()
use __ = AppDomain.CurrentDomain.ProcessExit.Subscribe(fun _ ->
dispose tempDocsOutDir
)
use __ = Console.CancelKeyPress.Subscribe(fun _ ->
dispose tempDocsOutDir
)
let defaultConfig = {
SiteBaseUrl = Uri(sprintf "http://%s:%d/" WebServer.hostname WebServer.port )
GitHubRepoUrl = Uri "https://github.com"
RepositoryRoot = IO.DirectoryInfo (__SOURCE_DIRECTORY__ @@ "..")
DocsOutputDirectory = tempDocsOutDir.DirectoryInfo
DocsSourceDirectory = IO.DirectoryInfo "docsSrc"
ProjectName = ""
ProjectFilesGlob = !! ""
ReleaseVersion = "0.1.0"
}
try
use tempDocsOutDir = DisposableDirectory.Create()
use __ = AppDomain.CurrentDomain.ProcessExit.Subscribe(fun _ ->
dispose tempDocsOutDir
)
use __ = Console.CancelKeyPress.Subscribe(fun _ ->
dispose tempDocsOutDir
)
let defaultConfig = {
SiteBaseUrl = Uri(sprintf "http://%s:%d/" WebServer.hostname WebServer.port )
GitHubRepoUrl = Uri "https://github.com"
RepositoryRoot = IO.DirectoryInfo (__SOURCE_DIRECTORY__ @@ "..")
DocsOutputDirectory = tempDocsOutDir.DirectoryInfo
DocsSourceDirectory = IO.DirectoryInfo "docsSrc"
ProjectName = ""
ProjectFilesGlob = !! ""
ReleaseVersion = "0.1.0"
}

let errorHandler = ProcessExiter(colorizer = function ErrorCode.HelpText -> None | _ -> Some ConsoleColor.Red)
let programName =
let name = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name
if Fake.Core.Environment.isWindows then
sprintf "%s.exe" name
else
name



let parser = ArgumentParser.Create<CLIArguments>(programName = programName, errorHandler = errorHandler)
let parsedArgs = parser.Parse argv
match parsedArgs.GetSubCommand() with
| Build args ->
let config =
(defaultConfig, args.GetAllResults())
||> List.fold(fun state next ->
match next with
| BuildArgs.SiteBaseUrl url -> { state with SiteBaseUrl = Uri url }
| BuildArgs.ProjectGlob glob -> { state with ProjectFilesGlob = !! glob}
| BuildArgs.DocsOutputDirectory outdir -> { state with DocsOutputDirectory = IO.DirectoryInfo outdir}
| BuildArgs.DocsSourceDirectory srcdir -> { state with DocsSourceDirectory = IO.DirectoryInfo srcdir}
| BuildArgs.GitHubRepoUrl url -> { state with GitHubRepoUrl = Uri url}
| BuildArgs.ProjectName repo -> { state with ProjectName = repo}
| BuildArgs.ReleaseVersion version -> { state with ReleaseVersion = version}
)
GenerateDocs.renderDocs config
| Watch args ->
let config =
(defaultConfig, args.GetAllResults())
||> List.fold(fun state next ->
match next with
| WatchArgs.ProjectGlob glob -> {state with ProjectFilesGlob = !! glob}
| WatchArgs.DocsSourceDirectory srcdir -> { state with DocsSourceDirectory = IO.DirectoryInfo srcdir}
| WatchArgs.GitHubRepoUrl url -> { state with GitHubRepoUrl = Uri url}
| WatchArgs.ProjectName repo -> { state with ProjectName = repo}
| WatchArgs.ReleaseVersion version -> { state with ReleaseVersion = version}
)
use ds = GenerateDocs.watchDocs config
WebServer.serveDocs config.DocsOutputDirectory.FullName
0 // return an integer exit code
let errorHandler = ProcessExiter(colorizer = function ErrorCode.HelpText -> None | _ -> Some ConsoleColor.Red)
let programName =
let name = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name
if Fake.Core.Environment.isWindows then
sprintf "%s.exe" name
else
name



let parser = ArgumentParser.Create<CLIArguments>(programName = programName, errorHandler = errorHandler)
let parsedArgs = parser.Parse argv
match parsedArgs.GetSubCommand() with
| Build args ->
let config =
(defaultConfig, args.GetAllResults())
||> List.fold(fun state next ->
match next with
| BuildArgs.SiteBaseUrl url -> { state with SiteBaseUrl = Uri url }
| BuildArgs.ProjectGlob glob -> { state with ProjectFilesGlob = !! glob}
| BuildArgs.DocsOutputDirectory outdir -> { state with DocsOutputDirectory = IO.DirectoryInfo outdir}
| BuildArgs.DocsSourceDirectory srcdir -> { state with DocsSourceDirectory = IO.DirectoryInfo srcdir}
| BuildArgs.GitHubRepoUrl url -> { state with GitHubRepoUrl = Uri url}
| BuildArgs.ProjectName repo -> { state with ProjectName = repo}
| BuildArgs.ReleaseVersion version -> { state with ReleaseVersion = version}
)
GenerateDocs.renderDocs config
| Watch args ->
let config =
(defaultConfig, args.GetAllResults())
||> List.fold(fun state next ->
match next with
| WatchArgs.ProjectGlob glob -> {state with ProjectFilesGlob = !! glob}
| WatchArgs.DocsSourceDirectory srcdir -> { state with DocsSourceDirectory = IO.DirectoryInfo srcdir}
| WatchArgs.GitHubRepoUrl url -> { state with GitHubRepoUrl = Uri url}
| WatchArgs.ProjectName repo -> { state with ProjectName = repo}
| WatchArgs.ReleaseVersion version -> { state with ReleaseVersion = version}
)
use ds = GenerateDocs.watchDocs config
WebServer.serveDocs config.DocsOutputDirectory.FullName
0
with e ->
eprintfn "Fatal error: %A" e
1
4 changes: 2 additions & 2 deletions Content/Library/docsTool/docsTool.fsproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand Down
4 changes: 0 additions & 4 deletions Content/Library/docsTool/paket.references
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,4 @@ Fake.IO.FileSystem
Fake.DotNet.Cli
FSharp.Literate
Fable.React
Microsoft.AspNetCore.StaticFiles
Microsoft.AspNetCore.Hosting
Microsoft.AspNetCore.Server.Kestrel
Microsoft.AspNetCore.WebSockets
Dotnet.ProjInfo.Workspace.FCS
4 changes: 0 additions & 4 deletions Content/Library/paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,4 @@ group Docs
nuget Fake.DotNet.Cli
nuget FSharp.Literate
nuget Fable.React
nuget Microsoft.AspNetCore.StaticFiles
nuget Microsoft.AspNetCore.Hosting
nuget Microsoft.AspNetCore.Server.Kestrel
nuget Microsoft.AspNetCore.WebSockets
nuget Dotnet.ProjInfo.Workspace.FCS
Loading