Skip to content

Commit a3616ae

Browse files
committed
Fix docs:
- Add temporary helper functions to render charts for docs - Fix references and charts in all docs - add releaselocal target to test docs locally
1 parent 7c6ec95 commit a3616ae

File tree

171 files changed

+17446
-341
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

171 files changed

+17446
-341
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,3 +186,4 @@ docsrc/tools/FSharp.Formatting.svclog
186186

187187
/docs
188188
AssemblyInfo.fs
189+
temp/gh-pages

FSharp.Plotly.sln

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,34 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{83F16175
2727
EndProject
2828
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{8E6D5255-776D-4B61-85F9-73C37AA1FB9A}"
2929
ProjectSection(SolutionItems) = preProject
30-
docs\content\2d-histograms.fsx = docs\content\2d-histograms.fsx
31-
docs\content\3d-line-plots.fsx = docs\content\3d-line-plots.fsx
32-
docs\content\3d-mesh-plots.fsx = docs\content\3d-mesh-plots.fsx
33-
docs\content\3d-scatter-plots.fsx = docs\content\3d-scatter-plots.fsx
34-
docs\content\3d-surface-plots.fsx = docs\content\3d-surface-plots.fsx
35-
docs\content\area-plots.fsx = docs\content\area-plots.fsx
36-
docs\content\bar-charts.fsx = docs\content\bar-charts.fsx
37-
docs\content\box-plots.fsx = docs\content\box-plots.fsx
38-
docs\content\bubble-charts.fsx = docs\content\bubble-charts.fsx
39-
docs\content\choropleth-map.fsx = docs\content\choropleth-map.fsx
40-
docs\content\contour-plots.fsx = docs\content\contour-plots.fsx
41-
docs\content\errorbars.fsx = docs\content\errorbars.fsx
42-
docs\content\extensions.fsx = docs\content\extensions.fsx
43-
docs\content\getting-started.fsx = docs\content\getting-started.fsx
44-
docs\content\heatmaps.fsx = docs\content\heatmaps.fsx
45-
docs\content\histograms.fsx = docs\content\histograms.fsx
46-
docs\content\index.fsx = docs\content\index.fsx
47-
docs\content\line-scatter-plots.fsx = docs\content\line-scatter-plots.fsx
48-
docs\content\multiple-charts.fsx = docs\content\multiple-charts.fsx
49-
docs\content\parallel-coords.fsx = docs\content\parallel-coords.fsx
50-
docs\content\pie-daughnut-charts.fsx = docs\content\pie-daughnut-charts.fsx
51-
docs\content\plotly-wpf.fsx = docs\content\plotly-wpf.fsx
52-
docs\content\polar-charts.fsx = docs\content\polar-charts.fsx
53-
docs\content\range-plots.fsx = docs\content\range-plots.fsx
54-
docs\content\shapes.fsx = docs\content\shapes.fsx
55-
docs\content\violin-plots.fsx = docs\content\violin-plots.fsx
56-
docs\content\windrose-charts.fsx = docs\content\windrose-charts.fsx
30+
docsrc\content\2d-histograms.fsx = docsrc\content\2d-histograms.fsx
31+
docsrc\content\3d-line-plots.fsx = docsrc\content\3d-line-plots.fsx
32+
docsrc\content\3d-mesh-plots.fsx = docsrc\content\3d-mesh-plots.fsx
33+
docsrc\content\3d-scatter-plots.fsx = docsrc\content\3d-scatter-plots.fsx
34+
docsrc\content\3d-surface-plots.fsx = docsrc\content\3d-surface-plots.fsx
35+
docsrc\content\area-plots.fsx = docsrc\content\area-plots.fsx
36+
docsrc\content\bar-charts.fsx = docsrc\content\bar-charts.fsx
37+
docsrc\content\box-plots.fsx = docsrc\content\box-plots.fsx
38+
docsrc\content\bubble-charts.fsx = docsrc\content\bubble-charts.fsx
39+
docsrc\content\choropleth-map.fsx = docsrc\content\choropleth-map.fsx
40+
docsrc\content\contour-plots.fsx = docsrc\content\contour-plots.fsx
41+
docsrc\content\errorbars.fsx = docsrc\content\errorbars.fsx
42+
docsrc\content\extensions.fsx = docsrc\content\extensions.fsx
43+
docsrc\content\getting-started.fsx = docsrc\content\getting-started.fsx
44+
docsrc\content\heatmaps.fsx = docsrc\content\heatmaps.fsx
45+
docsrc\content\histograms.fsx = docsrc\content\histograms.fsx
46+
docsrc\content\index.fsx = docsrc\content\index.fsx
47+
docsrc\content\line-scatter-plots.fsx = docsrc\content\line-scatter-plots.fsx
48+
docsrc\content\multiple-charts.fsx = docsrc\content\multiple-charts.fsx
49+
docsrc\content\parallel-coords.fsx = docsrc\content\parallel-coords.fsx
50+
docsrc\content\pie-daughnut-charts.fsx = docsrc\content\pie-daughnut-charts.fsx
51+
docsrc\content\plotly-wpf.fsx = docsrc\content\plotly-wpf.fsx
52+
docsrc\content\polar-charts.fsx = docsrc\content\polar-charts.fsx
53+
docsrc\content\range-plots.fsx = docsrc\content\range-plots.fsx
54+
docsrc\content\shapes.fsx = docsrc\content\shapes.fsx
55+
docsrc\content\splom.fsx = docsrc\content\splom.fsx
56+
docsrc\content\violin-plots.fsx = docsrc\content\violin-plots.fsx
57+
docsrc\content\windrose-charts.fsx = docsrc\content\windrose-charts.fsx
5758
EndProjectSection
5859
EndProject
5960
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{ED8079DD-2B06-4030-9F0F-DC548F98E1C4}"

build.fsx

Lines changed: 92 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// --------------------------------------------------------------------------------------
44

55
#r "paket: groupref FakeBuild //"
6-
open Fake.IO
76

87
#load "./.fake/build.fsx/intellisense.fsx"
98

@@ -13,10 +12,68 @@ open Fake.Core.TargetOperators
1312
open Fake.DotNet
1413
open Fake.IO
1514
open Fake.IO.FileSystemOperators
15+
open Fake.IO.Globbing
1616
open Fake.IO.Globbing.Operators
1717
open Fake.DotNet.Testing
1818
open Fake.Tools
1919
open Fake.Api
20+
open Fake.Tools.Git
21+
22+
[<AutoOpen>]
23+
module TemporaryDocumentationHelpers =
24+
25+
type LiterateArguments =
26+
{ ToolPath : string
27+
Source : string
28+
OutputDirectory : string
29+
Template : string
30+
ProjectParameters : (string * string) list
31+
LayoutRoots : string list
32+
FsiEval : bool }
33+
34+
35+
let private run toolPath command =
36+
if 0 <> Process.execSimple ((fun info ->
37+
{ info with
38+
FileName = toolPath
39+
Arguments = command }) >> Process.withFramework) System.TimeSpan.MaxValue
40+
41+
then failwithf "FSharp.Formatting %s failed." command
42+
43+
let createDocs p =
44+
let toolPath = Tools.findToolInSubPath "fsformatting.exe" (Directory.GetCurrentDirectory() @@ "lib/Formatting")
45+
46+
let defaultLiterateArguments =
47+
{ ToolPath = toolPath
48+
Source = ""
49+
OutputDirectory = ""
50+
Template = ""
51+
ProjectParameters = []
52+
LayoutRoots = []
53+
FsiEval = false }
54+
55+
let arguments = (p:LiterateArguments->LiterateArguments) defaultLiterateArguments
56+
let layoutroots =
57+
if arguments.LayoutRoots.IsEmpty then []
58+
else [ "--layoutRoots" ] @ arguments.LayoutRoots
59+
let source = arguments.Source
60+
let template = arguments.Template
61+
let outputDir = arguments.OutputDirectory
62+
let fsiEval = if arguments.FsiEval then [ "--fsieval" ] else []
63+
64+
let command =
65+
arguments.ProjectParameters
66+
|> Seq.map (fun (k, v) -> [ k; v ])
67+
|> Seq.concat
68+
|> Seq.append
69+
(["literate"; "--processdirectory" ] @ layoutroots @ [ "--inputdirectory"; source; "--templatefile"; template;
70+
"--outputDirectory"; outputDir] @ fsiEval @ [ "--replacements" ])
71+
|> Seq.map (fun s ->
72+
if s.StartsWith "\"" then s
73+
else sprintf "\"%s\"" s)
74+
|> String.separated " "
75+
run arguments.ToolPath command
76+
printfn "Successfully generated docs for %s" source
2077

2178
// --------------------------------------------------------------------------------------
2279
// START TODO: Provide project-specific details below
@@ -319,20 +376,43 @@ Target.create "Docs" (fun _ ->
319376
| Some lang -> layoutRootsAll.[lang]
320377
| None -> layoutRootsAll.["en"] // "en" is the default language
321378

322-
FSFormatting.createDocs (fun args ->
379+
createDocs (fun args ->
323380
{ args with
324381
Source = content
325382
OutputDirectory = output
326383
LayoutRoots = layoutRoots
327384
ProjectParameters = ("root", root)::info
328-
Template = docTemplate } )
385+
Template = docTemplate
386+
FsiEval = true
387+
} )
329388
)
330389

331390
// --------------------------------------------------------------------------------------
332391
// Release Scripts
333392

393+
334394
//#load "paket-files/fsharp/FAKE/modules/Octokit/Octokit.fsx"
335395
//open Octokit
396+
Target.create "ReleaseDocs" (fun _ ->
397+
let tempDocsDir = "temp/gh-pages"
398+
Shell.cleanDir tempDocsDir |> ignore
399+
Git.Repository.cloneSingleBranch "" (gitHome + "/" + gitName + ".git") "gh-pages" tempDocsDir
400+
Shell.copyRecursive "docs" tempDocsDir true |> printfn "%A"
401+
Git.Staging.stageAll tempDocsDir
402+
Git.Commit.exec tempDocsDir (sprintf "Update generated documentation for version %s" release.NugetVersion)
403+
Git.Branches.push tempDocsDir
404+
)
405+
406+
Target.create "ReleaseLocal" (fun _ ->
407+
let tempDocsDir = "temp/gh-pages"
408+
Shell.cleanDir tempDocsDir |> ignore
409+
Shell.copyRecursive "docs" tempDocsDir true |> printfn "%A"
410+
Shell.replaceInFiles
411+
(seq {
412+
yield "href=\"/" + project + "/","href=\""
413+
yield "src=\"/" + project + "/","src=\""})
414+
(Directory.EnumerateFiles tempDocsDir |> Seq.filter (fun x -> x.EndsWith(".html")))
415+
)
336416

337417
Target.create "Release" (fun _ ->
338418
// not fully converted from FAKE 4
@@ -400,16 +480,16 @@ Target.create "All" ignore
400480
==> "Build"
401481
==> "CopyBinaries"
402482
==> "RunTests"
403-
// ==> "GenerateDocs"
483+
==> "GenerateDocs"
404484
==> "NuGet"
405485
==> "All"
406486

407487
"RunTests" ?=> "CleanDocs"
408488

409489
"CleanDocs"
410490
==>"Docs"
411-
// ==> "ReferenceDocs"
412-
// ==> "GenerateDocs"
491+
==> "ReferenceDocs"
492+
==> "GenerateDocs"
413493

414494
"Clean"
415495
==> "Release"
@@ -418,6 +498,11 @@ Target.create "All" ignore
418498
==> "PublishNuget"
419499
==> "Release"
420500

501+
"GenerateDocs"
502+
==> "ReleaseDocs"
503+
504+
"All"
505+
==> "ReleaseLocal"
421506

422507
"Clean"
423508
==> "AssemblyInfo"
@@ -427,4 +512,4 @@ Target.create "All" ignore
427512
==> "NuGet"
428513
==> "GitReleaseNuget"
429514

430-
Target.runOrDefault "All"
515+
Target.runOrDefaultWithArguments "All"

docsrc/content/2d-histograms.fsx

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(*** hide ***)
22
#r "netstandard"
3-
#r "../../bin/FSharp.Plotly.dll"
3+
#r @"../../lib/Formatting/FSharp.Plotly.dll"
44

55

66
(**
@@ -37,18 +37,25 @@ let step i = a + ((b - a) / float (n - 1)) * float i
3737
let x = Array.init n (fun i -> ((step i)**3.) + (0.3 * (normal (rnd) 0. 2.) ))
3838
let y = Array.init n (fun i -> ((step i)**6.) + (0.3 * (normal (rnd) 0. 2.) ))
3939

40-
(*** define-output:Histogram2dContour1 ***)
41-
[
42-
Chart.Histogram2dContour (x,y,Line=Line.init(Width=0))
43-
Chart.Point(x,y,Opacity=0.3)
44-
]
45-
|> Chart.Combine
46-
(*** include-it:Histogram2dContour1 ***)
40+
let histogramContour =
41+
[
42+
Chart.Histogram2dContour (x,y,Line=Line.init(Width=0))
43+
Chart.Point(x,y,Opacity=0.3)
44+
]
45+
|> Chart.Combine
4746

47+
(***do-not-eval***)
48+
histogramContour |> Chart.Show
4849

49-
(*** define-output:Histogram2d1 ***)
50-
Chart.Histogram2d (x,y)
51-
(*** include-it:Histogram2d1 ***)
50+
(*** include-value:histogramContour ***)
51+
52+
let histogram2d =
53+
Chart.Histogram2d (x,y)
54+
55+
(***do-not-eval***)
56+
histogram2d |> Chart.Show
57+
58+
(*** include-value:histogram2d ***)
5259

5360

5461

docsrc/content/3d-line-plots.fsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(*** hide ***)
22
#r "netstandard"
3-
#r "../../bin/FSharp.Plotly/netstandard2.0/FSharp.Plotly.dll"
3+
#r @"../../lib/Formatting/FSharp.Plotly.dll"
44

55
(**
66
# FSharp.Plotly: Scatter3d Charts with lines
@@ -25,12 +25,16 @@ let x,y,z =
2525
|> List.unzip3
2626

2727

28-
(*** define-output:scatter3d_line_1 ***)
29-
Chart.Scatter3d(x,y,z,StyleParam.Mode.Lines_Markers)
30-
|> Chart.withX_AxisStyle("x-axis")
31-
|> Chart.withY_AxisStyle("y-axis")
32-
|> Chart.withZ_AxisStyle("z-axis")
33-
|> Chart.withSize(800.,800.)
34-
(*** include-it:scatter3d_line_1 ***)
28+
let scatter3dLine =
29+
Chart.Scatter3d(x,y,z,StyleParam.Mode.Lines_Markers)
30+
|> Chart.withX_AxisStyle("x-axis")
31+
|> Chart.withY_AxisStyle("y-axis")
32+
|> Chart.withZ_AxisStyle("z-axis")
33+
|> Chart.withSize(800.,800.)
34+
35+
(***do-not-eval***)
36+
scatter3dLine |> Chart.Show
37+
38+
(*** include-value:scatter3dLine ***)
3539

3640

docsrc/content/3d-mesh-plots.fsx

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(*** hide ***)
22
#r "netstandard"
3-
#r "../../bin/FSharp.Plotly/netstandard2.0/FSharp.Plotly.dll"
3+
#r @"../../lib/Formatting/FSharp.Plotly.dll"
44

55

66
(**
@@ -45,15 +45,19 @@ cont?show <- true
4545
cont?width <- 3
4646

4747

48-
(*** define-output:mesh3d_1 ***)
49-
Trace3d.initMesh3d
50-
(fun mesh3d ->
51-
mesh3d?x <- a
52-
mesh3d?y <- b
53-
mesh3d?z <- c
54-
mesh3d?flatshading <- true
55-
mesh3d?contour <- Contours.initXyz(Show=true)
56-
mesh3d
57-
)
58-
|> GenericChart.ofTraceObject
59-
(*** include-it:mesh3d_1 ***)
48+
let mesh3d =
49+
Trace3d.initMesh3d
50+
(fun mesh3d ->
51+
mesh3d?x <- a
52+
mesh3d?y <- b
53+
mesh3d?z <- c
54+
mesh3d?flatshading <- true
55+
mesh3d?contour <- Contours.initXyz(Show=true)
56+
mesh3d
57+
)
58+
|> GenericChart.ofTraceObject
59+
60+
(***do-not-eval***)
61+
mesh3d |> Chart.Show
62+
63+
(*** include-value:mesh3d_1 ***)

docsrc/content/3d-scatter-plots.fsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
(*** hide ***)
22
#r "netstandard"
3-
#r "../../bin/FSharp.Plotly/netstandard2.0/FSharp.Plotly.dll"
3+
#r @"../../lib/Formatting/FSharp.Plotly.dll"
44

55
(**
66
# FSharp.Plotly: Scatter3d Charts
@@ -17,13 +17,17 @@ let y = [19; 26; 55;]
1717
let z = [19; 26; 55;]
1818

1919

20-
(*** define-output:scatter3d_1 ***)
21-
Chart.Scatter3d(x,y,z,StyleParam.Mode.Markers)
22-
|> Chart.withX_AxisStyle("my x-axis")
23-
|> Chart.withY_AxisStyle("my y-axis")
24-
|> Chart.withZ_AxisStyle("my z-axis")
25-
|> Chart.withSize(800.,800.)
26-
(*** include-it:scatter3d_1 ***)
20+
let scatter3d =
21+
Chart.Scatter3d(x,y,z,StyleParam.Mode.Markers)
22+
|> Chart.withX_AxisStyle("my x-axis")
23+
|> Chart.withY_AxisStyle("my y-axis")
24+
|> Chart.withZ_AxisStyle("my z-axis")
25+
|> Chart.withSize(800.,800.)
26+
27+
(***do-not-eval***)
28+
scatter3d |> Chart.Show
29+
30+
(*** include-value:scatter3d ***)
2731

2832

2933

0 commit comments

Comments
 (0)