Skip to content

Commit

Permalink
Add hotloading for api generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmy Byrd committed Feb 4, 2019
1 parent 6145bf0 commit 8dd9d9a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 9 deletions.
15 changes: 14 additions & 1 deletion Content/Library/build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,21 @@ Target.create "GenerateDocs" <| fun _ ->
Docs.generateDocs Docs.docsFileGlob gitRepoName
Docs.generateAPI gitRepoName (!! srcBinGlob)

let watchBuild () =
!! srcGlob
|> Seq.map(fun proj -> fun () ->
dotnet.watch
(fun opt ->
opt |> DotNet.Options.withWorkingDirectory (IO.Path.GetDirectoryName proj))
"build"
""
|> ignore
)
|> Seq.iter (invokeAsync >> Async.Catch >> Async.Ignore >> Async.Start)

Target.create "ServeDocs" <| fun _ ->
use d = Docs.watchDocs gitRepoName
let d1,d2 = Docs.watchDocs gitRepoName (!! srcBinGlob) watchBuild
use d2 = d2
Docs.serveDocs ()


Expand Down
28 changes: 20 additions & 8 deletions Content/Library/docs.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,27 @@ let generateDocs (docSourcePaths : IGlobbingPattern) githubRepoName =
copyAssets()


let watchDocs githubRepoName =
docsFileGlob
|> ChangeWatcher.run (fun changes ->
changes
|> Seq.iter (fun m ->
generateDocs (!! m.FullPath) githubRepoName
refereshWebpageEvent.Trigger m.FullPath
let watchDocs githubRepoName (dllGlob : IGlobbingPattern) (startWatchBuild : unit -> unit) =
let d1 =
docsFileGlob
|> ChangeWatcher.run (fun changes ->
changes
|> Seq.iter (fun m ->
generateDocs (!! m.FullPath) githubRepoName
refereshWebpageEvent.Trigger m.FullPath
)
)
)
startWatchBuild ()
let d2 =
dllGlob
|> ChangeWatcher.run(fun changes ->
changes
|> Seq.iter(fun c -> Trace.logf "Regenerating API docs due to %s" c.FullPath )
generateAPI githubRepoName dllGlob
refereshWebpageEvent.Trigger "Api"
)
d1, d2


open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Hosting
Expand Down

0 comments on commit 8dd9d9a

Please sign in to comment.