Skip to content

Commit

Permalink
Add FSharp.Plotly support for docu
Browse files Browse the repository at this point in the history
  • Loading branch information
muehlhaus committed Dec 13, 2016
1 parent 00276ab commit e8c691e
Show file tree
Hide file tree
Showing 9 changed files with 318 additions and 45 deletions.
6 changes: 4 additions & 2 deletions FSharp.Stats.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".paket", ".paket", "{63297B98-5CED-492C-A5B7-A5B4F73CF142}"
ProjectSection(SolutionItems) = preProject
paket.dependencies = paket.dependencies
Expand All @@ -20,6 +21,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{BF60
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{83F16175-43B1-4C90-A1EE-8E351C33435D}"
ProjectSection(SolutionItems) = preProject
docs\tools\formatters.fsx = docs\tools\formatters.fsx
docs\tools\generate.fsx = docs\tools\generate.fsx
docs\tools\templates\template.cshtml = docs\tools\templates\template.cshtml
EndProjectSection
Expand Down
Binary file modified docs/files/img/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions docs/tools/formatters.fsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
module Formatters
#I "../../packages/build/FSharp.Formatting/lib/net40"
#r "FSharp.Markdown.dll"
#r "FSharp.Literate.dll"

#r "FSharp.CodeFormat.dll"
#r "RazorEngine.dll"
#r "../../packages/build/FAKE/tools/FakeLib.dll"

//#I "../../bin"
//#r "../../bin/FSharp.Plotly.dll"
#r "../../packages/build/FSharp.Plotly/lib/net40/Fsharp.Plotly.dll"

open Fake
open System.IO
open FSharp.Literate
open FSharp.Markdown

open FSharp.Plotly

// --------------------------------------------------------------------------------------
// Build FSI evaluator
// --------------------------------------------------------------------------------------

/// Builds FSI evaluator that can render System.Image, F# Charts, series & frames
let createFsiEvaluator root output =

/// Counter for saving files
let imageCounter =
let count = ref 0
(fun () -> incr count; !count)

let transformation (value:obj, typ:System.Type) =
match value with
| :? System.Drawing.Image as img ->
// Pretty print image - save the image to the "images" directory
// and return a DirectImage reference to the appropriate location
let id = imageCounter().ToString()
let file = "chart" + id + ".png"
ensureDirectory (output @@ "images")
img.Save(output @@ "images" @@ file, System.Drawing.Imaging.ImageFormat.Png)
Some [ Paragraph [DirectImage ("", (root + "/images/" + file, None))] ]

| :? GenericChart.GenericChart as ch ->
// Just return the inline HTML for a Plotly chart
let html = GenericChart.toChartHtmlWithSize 700 500 ch
Some [InlineBlock <| html]

| _ -> None

// Create FSI evaluator, register transformations & return
let fsiEvaluator = FsiEvaluator()
fsiEvaluator.RegisterTransformation(transformation)
fsiEvaluator
7 changes: 5 additions & 2 deletions docs/tools/generate.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ let info =
// --------------------------------------------------------------------------------------
// For typical project, no changes are needed below
// --------------------------------------------------------------------------------------
#load "formatters.fsx"

#load "../../packages/build/FSharp.Formatting/FSharp.Formatting.fsx"
#I "../../packages/build/FAKE/tools/"
Expand Down Expand Up @@ -107,11 +108,13 @@ let buildReference () =

// Build documentation from `fsx` and `md` files in `docs/content`
let buildDocumentation () =
// Create evaluator and parse script
let fsi = Formatters.createFsiEvaluator root output

// First, process files which are placed in the content root directory.

Literate.ProcessDirectory
( content, docTemplate, output, replacements = ("root", root)::info,
( content, docTemplate, output, fsiEvaluator = fsi, replacements = ("root", root)::info,
layoutRoots = layoutRootsAll.["en"],
generateAnchors = true,
processRecursive = false)
Expand All @@ -131,7 +134,7 @@ let buildDocumentation () =
| None -> layoutRootsAll.["en"] // "en" is the default language

Literate.ProcessDirectory
( dir, docTemplate, output @@ dirname, replacements = ("root", root)::info,
( dir, docTemplate, output @@ dirname, fsiEvaluator = fsi, replacements = ("root", root)::info,
layoutRoots = layoutRoots,
generateAnchors = true )

Expand Down
2 changes: 2 additions & 0 deletions paket.dependencies
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ group Build

github fsharp/FAKE modules/Octokit/Octokit.fsx

nuget FSharp.Plotly

group Test
source https://nuget.org/api/v2

Expand Down
240 changes: 240 additions & 0 deletions paket.lock

Large diffs are not rendered by default.

20 changes: 3 additions & 17 deletions src/FSharp.Stats/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,11 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<runtime>

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

<runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="2.3.0.0" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="2.3.5.0" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="4.0.0.0" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="4.3.0.0" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="3.3.1.0" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="2.3.5.1" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="3.78.3.1" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="3.259.3.1" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="4.3.1.0" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="3.47.4.0" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="3.78.4.0" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="3.259.4.0" newVersion="4.4.0.0" />
</dependentAssembly>
</assemblyBinding></runtime>
</configuration>
</assemblyBinding></runtime></configuration>
14 changes: 7 additions & 7 deletions src/FSharp.Stats/FSharp.Stats.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@
<Compile Include="Random.fs" />
<Compile Include="SpecialFunctions.fs" />
<!-- Distributions -->
<Compile Include="Distributions\Frequency.fs" />
<Compile Include="Distributions\Frequency.fs" />
<Compile Include="Distributions\Empirical.fs" />
<Compile Include="Distributions\Distribution.fs" />
<Compile Include="Distributions\Continuous.fs" />
<Compile Include="Distributions\Discrete.fs" />
<!-- Distributions -->
<Compile Include="Testing\TTest.fs" />
<Compile Include="Testing\TTest.fs" />
<!-- Content -->
<None Include="Script.fsx" />
<None Include="paket.references" />
Expand All @@ -84,6 +84,10 @@
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
</ItemGroup>
<PropertyGroup>
<PostBuildEvent>xcopy /Y "$(TargetDir)*.dll" "$(SolutionDir)bin\"
xcopy /Y "$(TargetDir)*.xml" "$(SolutionDir)bin\"</PostBuildEvent>
</PropertyGroup>
<Choose>
<When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.6.1'">
<ItemGroup>
Expand All @@ -100,14 +104,10 @@
<ItemGroup>
<Reference Include="System.Numerics.Vectors">
<HintPath>..\..\packages\System.Numerics.Vectors\ref\net46\System.Numerics.Vectors.dll</HintPath>
<Private>True</Private>
<Private>False</Private>
<Paket>True</Paket>
</Reference>
</ItemGroup>
</When>
</Choose>
<PropertyGroup>
<PostBuildEvent>xcopy /Y "$(TargetDir)*.dll" "$(SolutionDir)bin\"
xcopy /Y "$(TargetDir)*.xml" "$(SolutionDir)bin\"</PostBuildEvent>
</PropertyGroup>
</Project>
20 changes: 3 additions & 17 deletions tests/FSharp.Stats.Tests/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,11 @@
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<runtime>

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

<runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<Paket>True</Paket>
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="2.3.0.0" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="2.3.5.0" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="4.0.0.0" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="4.3.0.0" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="3.3.1.0" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="2.3.5.1" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="3.78.3.1" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="3.259.3.1" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="4.3.1.0" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="3.47.4.0" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="3.78.4.0" newVersion="4.4.0.0" />
<bindingRedirect oldVersion="3.259.4.0" newVersion="4.4.0.0" />
</dependentAssembly>
</assemblyBinding></runtime>
</configuration>
</assemblyBinding></runtime></configuration>

0 comments on commit e8c691e

Please sign in to comment.