Browse Source

Docs: initial setup

pull/197/head
Christoph Ruegg 13 years ago
parent
commit
035ca0ba6d
  1. 5
      MathNet.Numerics.NativeProviders.sln
  2. 12
      MathNet.Numerics.Net35Only.sln
  3. 12
      MathNet.Numerics.Portable.sln
  4. 21
      MathNet.Numerics.sln
  5. 10
      build.fsx
  6. 258
      docs/content/RandomAndDistributions.fsx
  7. 71
      docs/content/index.fsx
  8. BIN
      docs/files/img/logo.png
  9. 89
      docs/tools/build-docs.fsx
  10. 7
      docs/tools/packages.config
  11. 61
      docs/tools/templates/template.cshtml

5
MathNet.Numerics.NativeProviders.sln

@ -20,11 +20,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Numerics", "src\Numerics\Nu
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests-MKL", "src\UnitTests\UnitTests-MKL.csproj", "{3515A344-AB5F-41C7-A14C-04A79B3FFAB1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", ".nuget", "{2D8D8FBA-6B67-4F44-87D3-7D751FF7AFE2}"
ProjectSection(SolutionItems) = preProject
.nuget\packages.config = .nuget\packages.config
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU

12
MathNet.Numerics.Net35Only.sln

@ -17,18 +17,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Numerics-Net35", "src\Numer
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests-Net35", "src\UnitTests\UnitTests-Net35.csproj", "{9014A0CE-725D-4718-918C-923C0CA19FEE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{A4A66FA9-C00C-4D5C-A776-27516EA0C536}"
ProjectSection(SolutionItems) = preProject
build.fsx = build.fsx
build\NuGet\FSharp\MathNet.Numerics.FSharp.nuspec = build\NuGet\FSharp\MathNet.Numerics.FSharp.nuspec
build\NuGet\FSharp.Signed\MathNet.Numerics.FSharp.Signed.nuspec = build\NuGet\FSharp.Signed\MathNet.Numerics.FSharp.Signed.nuspec
build\NuGet\Numerics\MathNet.Numerics.nuspec = build\NuGet\Numerics\MathNet.Numerics.nuspec
build\NuGet\Numerics.Signed\MathNet.Numerics.Signed.nuspec = build\NuGet\Numerics.Signed\MathNet.Numerics.Signed.nuspec
build\NuGet\nuget-signed.proj = build\NuGet\nuget-signed.proj
build\NuGet\nuget.proj = build\NuGet\nuget.proj
.nuget\packages.config = .nuget\packages.config
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU

12
MathNet.Numerics.Portable.sln

@ -52,18 +52,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Numerics-Net35", "src\Numer
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests-Net35", "src\UnitTests\UnitTests-Net35.csproj", "{9014A0CE-725D-4718-918C-923C0CA19FEE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{A4A66FA9-C00C-4D5C-A776-27516EA0C536}"
ProjectSection(SolutionItems) = preProject
build.fsx = build.fsx
build\NuGet\FSharp\MathNet.Numerics.FSharp.nuspec = build\NuGet\FSharp\MathNet.Numerics.FSharp.nuspec
build\NuGet\FSharp.Signed\MathNet.Numerics.FSharp.Signed.nuspec = build\NuGet\FSharp.Signed\MathNet.Numerics.FSharp.Signed.nuspec
build\NuGet\Numerics\MathNet.Numerics.nuspec = build\NuGet\Numerics\MathNet.Numerics.nuspec
build\NuGet\Numerics.Signed\MathNet.Numerics.Signed.nuspec = build\NuGet\Numerics.Signed\MathNet.Numerics.Signed.nuspec
build\NuGet\nuget-signed.proj = build\NuGet\nuget-signed.proj
build\NuGet\nuget.proj = build\NuGet\nuget.proj
.nuget\packages.config = .nuget\packages.config
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU

21
MathNet.Numerics.sln

@ -35,13 +35,30 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{A4A66FA9-C00C-4D5C-A776-27516EA0C536}"
ProjectSection(SolutionItems) = preProject
build.fsx = build.fsx
.nuget\packages.config = .nuget\packages.config
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{039229DA-AFDA-48DB-B7FC-B064691DEE96}"
ProjectSection(SolutionItems) = preProject
docs\content\index.fsx = docs\content\index.fsx
docs\content\RandomAndDistributions.fsx = docs\content\RandomAndDistributions.fsx
docs\tools\templates\template.cshtml = docs\tools\templates\template.cshtml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "NuGet", "NuGet", "{8A295380-F19B-460C-9794-2EF1B67E5483}"
ProjectSection(SolutionItems) = preProject
build\NuGet\FSharp\MathNet.Numerics.FSharp.nuspec = build\NuGet\FSharp\MathNet.Numerics.FSharp.nuspec
build\NuGet\FSharp.Signed\MathNet.Numerics.FSharp.Signed.nuspec = build\NuGet\FSharp.Signed\MathNet.Numerics.FSharp.Signed.nuspec
build\NuGet\Numerics\MathNet.Numerics.nuspec = build\NuGet\Numerics\MathNet.Numerics.nuspec
build\NuGet\Numerics.Signed\MathNet.Numerics.Signed.nuspec = build\NuGet\Numerics.Signed\MathNet.Numerics.Signed.nuspec
build\NuGet\nuget-signed.proj = build\NuGet\nuget-signed.proj
build\NuGet\nuget.proj = build\NuGet\nuget.proj
.nuget\packages.config = .nuget\packages.config
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{DB89F4DB-5204-4B38-B9F5-FE11E69D32AD}"
ProjectSection(SolutionItems) = preProject
docs\tools\build-docs.fsx = docs\tools\build-docs.fsx
docs\tools\packages.config = docs\tools\packages.config
EndProjectSection
EndProject
Global
@ -96,5 +113,7 @@ Global
{DAF07AA8-C5C9-4963-98F7-2C3285064DAD} = {4D50FB34-10BC-495A-8B2F-482E34B4D771}
{8239A6FF-1EF3-4DA4-A860-95C392DD6899} = {49EE74BD-301F-4C3B-B76A-07F90CC88CE7}
{BC81EA37-8EE6-4BF9-B8A9-B30497AEF8B1} = {49EE74BD-301F-4C3B-B76A-07F90CC88CE7}
{8A295380-F19B-460C-9794-2EF1B67E5483} = {A4A66FA9-C00C-4D5C-A776-27516EA0C536}
{DB89F4DB-5204-4B38-B9F5-FE11E69D32AD} = {A4A66FA9-C00C-4D5C-A776-27516EA0C536}
EndGlobalSection
EndGlobal

10
build.fsx

@ -19,7 +19,7 @@ Target "RestorePackages" RestorePackages
Target "AssemblyInfo" DoNothing
Target "Prepare" DoNothing
"Clean" ==> "Restorepackages" ==> "AssemblyInfo" ==> "Prepare"
"Clean" ==> "RestorePackages" ==> "AssemblyInfo" ==> "Prepare"
// BUILD
@ -52,7 +52,13 @@ Target "Test" (fun _ ->
// DOCUMENTATION
Target "Docs" DoNothing
Target "Docs" (fun _ ->
executeFSIWithArgs "docs/tools" "build-docs.fsx" ["--define:RELEASE"] [] |> ignore
)
Target "DocsDev" (fun _ ->
executeFSIWithArgs "docs/tools" "build-docs.fsx" [] [] |> ignore
)
"Build" ==> "Docs"

258
docs/content/RandomAndDistributions.fsx

@ -0,0 +1,258 @@
(*** hide ***)
#I "../../out/lib/net40"
#r "MathNet.Numerics.dll"
#r "MathNet.Numerics.FSharp.dll"
(**
Random Numbers and Probability Distributions
============================================
The .Net Framework base class library includes a pseudo-random number generator
for non-cryptography use in the form of the `System.Random` class.
Math.NET Numerics provides a few alternatives with different characteristics
in randomness, bias, sequence length and performance. All these classes
inherit from `System.Random` so you can use them as a drop-in replacement
even in third-party code.
All random number generators (RNG) generate numbers in a more-or-less uniform
distribution. In practice you often need to sample random numbers with a different
distribution, like a Gaussian or Poisson. You can do that with one of our probability
distribution classes, or in F# also using the `Sample` module. Once parametrized,
the distribution classes also provide a variety of other functionality around probability
distributions, like evaluating statistical distribution properties or functions.
Initialization
--------------
We need to reference Math.NET Numerics and open the namespaces for
random numbers and probability distributions:
[lang=csharp]
using MathNet.Numerics.Random;
using MathNet.Numerics.Distributions;
Or in F#:
*)
open MathNet.Numerics.Random
open MathNet.Numerics.Distributions
(**
Random Number Generators
------------------------
Let's sample a few uniform random values using Mersenne Twister in C#:
[lang=csharp]
var rng = new MersenneTwister(42);
int randomInt = rng.Next();
double randomDouble = rng.NextDouble();
In F# you can use the constructor as well, or alternatively use the `Random` module.
In case of the latter, all objects will be cast to their common base type `System.Random`:
*)
let rng = MersenneTwister(42)
let rngEx = Random.mersenneTwisterSeed 42
let randomInt = rng.Next()
(**
If you have used `System.Random` before, you may remember that it only offers `Next` methods
to sample integers, and `NextDouble` for floating point numbers in the [0,1) interval.
Did you ever have a need to generate numbers of the full integer range including negative numbers,
or a `System.Decimal`? Extending discrete random numbers to different ranges or types is non-trivial
if the distribution should still be uniform over the chosen range. That's why we've added a few extensions
methods which are available on all RNGs (including `System.Random` itself):
*)
let values =
( rng.Next(), // built-in: int32 in the range [0, Int.MaxValue)
rng.NextInt64(), // int64 in the range [0, Long.MaxValue)
rng.NextFullRangeInt32(), // int32 in the range [Int.MinValue, Int.MaxValue]
rng.NextFullRangeInt64(), // int64 in the range [Long.MinValue, Long.MaxValue]
rng.NextDouble(), // built-in: double in the range [0.0, 1.0)
rng.NextDecimal() ) // decimal in then range [0.0, 1.0)
(**
The following custom RNGs are currently available in Math.NET Numerics:
* `MersenneTwister`: Mersenne Twister 19937 generator
* `Xorshift`: Multiply-with-carry XOR-shift generator
* `Mcg31m1`: Multiplicative congruental generator using a modulus of 2^31-1 and a multiplier of 1132489760
* `Mcg59`: Multiplicative congruental generator using a modulus of 2^59 and a multiplier of 13^13
* `WH1982`: Wichmann-Hill's 1982 combined multiplicative congruental generator
* `WH2006`: Wichmann-Hill's 2006 combined multiplicative congruental generator
* `Mrg32k3a`: 32-bit combined multiple recursive generator with 2 components of order 3
* `Palf`: Parallel Additive Lagged Fibonacci generator
* `SystemCryptoRandomNumberGenerator`: Using the RNGCryptoServiceProvider of the .Net Framework. *Not available in portable builds.*
Seeds and Thread Safety
-----------------------
Other than for cryptographic random numbers where you'd never want to provide
a seed, all other RNGs can be initialized with a custom seed. In the code sample
above we've used `42` as seed. The same seed causes the same number sequence
to be generated, which can be very useful if you need results to be reproducible,
e.g. in testing/verification.
If no seed is provided, `System.Random` uses a time based seed equivalent to the
one below. This means that all instances created within a short timeframe
(which typically spans about a thousand CPU clock cycles) will generate
exactly the same sequence. This can happen easily e.g. in parallel computing
and is often unwanted. That's why all number generators created using
Math.NET Numerics routines are by default initialized with a seed that combines
the time with a Guid (which are supposed to be generated uniquely, worldwide).
*)
let someTimeSeed = RandomSeed.Time()
let someGuidSeed = RandomSeed.Guid()
(**
Note that the generators should be reused when generating multiple numbers.
If you'd create a new generator each time, the numbers it generates would be
exactly as random as your seed - and thus not very random at all.
However, generators are not automatically thread-safe in .Net. They *are* thread-safe
when created using Math.NET Numerics by default, but that can be controlled either by a
boolean argument at creation or by setting `Control.ThreadSafeRandomNumberGenerators`.
*)
let a = Random.system ()
let b = Random.systemSeed (RandomSeed.Guid())
let c = Random.crypto ()
let d = Random.mersenneTwister ()
let e = Random.mersenneTwisterWith 1000 true (* thread-safe *)
let f = Random.xorshift ()
let g = Random.xorshiftCustom someTimeSeed false 916905990L 13579L 362436069L 77465321L
let h = Random.wh2006 ()
let i = Random.palf ()
(**
Probability Distributions
-------------------------
For non-uniform random number generation you can use one the wide range of probability
distributions in the `MathNet.Numerics.Distributions` namespace.
There are many ways to parametrize a distribution in the literature. When using the
default constructor, read carefully which parameters it requires. For distributions where
multiple ways are common there are also static methods, so you can use the one that fits best.
For example, a normal distribution is usually parametrized with mean and standard deviation,
but if you'd rather use mean and precision:
[lang=csharp]
var normal = Normal.WithMeanPrecision(0.0, 0.5);
Since probability distributions can also be sampled to generate random numbers
with the configured distribution, all constructors optionally accept a random generator
as last argument. A few more examples, this time in F#:
*)
// some probability distributions
let normal = Normal.WithMeanVariance(3.0, 1.5, g)
let exponential = Exponential(2.4)
let gamma = Gamma(2.0, 1.5, Random.crypto())
let cauchy = Cauchy(0.0, 1.0, Random.mrg32k3aWith 10 false)
let poisson = Poisson(3.0)
let geometric = Geometric(0.8, Random.system())
// sample some random rumbers from these distributions
let continuous =
[ yield normal.Sample()
yield exponential.Sample()
yield! gamma.Samples() |> Seq.take 10 ]
let discrete =
[ poisson.Sample()
poisson.Sample()
geometric.Sample() ]
// direct sampling (without creating a distribution object)
let u = Normal.Sample(Random.system(), 2.0, 4.0)
let v = Laplace.Samples(Random.mersenneTwister(), 1.0, 3.0) |> Seq.take 100 |> List.ofSeq
let w = Rayleigh.Sample(c, 1.5)
let x = Hypergeometric.Sample(h, 100, 20, 5)
(**
Distribution Functions and Properties
-------------------------------------
Distributions can not just be used to generate non-uniform random samples.
Once parametrized they can compute a variety of distribution properties
or evaluate distribution functions. Because it is often numerically more stable
and faster to compute and work with such quantities in the logarithmic domain,
some of them are also available with the `Ln`-suffix.
*)
// distribution properties of the gamma we've configured above
let gammaStats =
( gamma.Mean,
gamma.Variance,
gamma.StdDev,
gamma.Entropy,
gamma.Skewness,
gamma.Mode )
// probability distribution functions of the normal we've configured above.
let nd = normal.Density(4.0) (* pdf *)
let ndLn = normal.DensityLn(4.0) (* ln(pdf) *)
let nc = normal.CumulativeDistribution(4.0) (* cdf *)
let nic = normal.InverseCumulativeDistribution(0.7) (* invcdf *)
// Distribution functions can also be evaluated without creating an object,
// but then you have to pass in the distribution parameters as first arguments:
let nd2 = Normal.PDF(3.0, sqrt 1.5, 4.0)
let ndLn2 = Normal.PDFLn(3.0, sqrt 1.5, 4.0)
let nc2 = Normal.CDF(3.0, sqrt 1.5, 4.0)
let nic2 = Normal.InvCDF(3.0, sqrt 1.5, 0.7)
(**
Some of the distributions also have routines for maximum-likelihood parameter
estimation from a set of samples:
*)
let estimation = LogNormal.Estimate([| 2.0; 1.5; 2.1; 1.2; 3.0; 2.4; 1.8 |])
let mean, variance = estimation.Mean, estimation.Variance
let moreSamples = estimation.Samples() |> Seq.take 10 |> Seq.toArray
(**
or in C#:
[lang=csharp]
LogNormal estimation = LogNormal.Estimate(new [] {2.0, 1.5, 2.1, 1.2, 3.0, 2.4, 1.8});
double mean = estimation.Mean, variance = estimation.Variance;
double[] moreSamples = estimation.Samples().Take(10).ToArray();
Let's do some random walks, using distributions and random sources defined above (TODO: Graph):
*)
Seq.scan (+) 0.0 (normal.Samples()) |> Seq.take 10 |> Seq.toArray
Seq.scan (+) 0.0 (Sample.normalSeq 0.0 0.5 a) |> Seq.take 10 |> Seq.toArray
(**
Composing Distributions
-----------------------
Specifically for F# there is also a `Sample` module that allows a somewhat more functional
view on distribution sampling functions by having the random source passed in as last argument.
This way they can be composed and transformed arbitrarily if curried:
*)
/// Transform a sample from a distribution
let s1 rng = tanh (Sample.normal 2.0 0.5 rng)
/// But we really want to transform the function, not the resulting sample:
let s1f rng = Sample.map tanh (Sample.normal 2.0 0.5) rng
/// Exactly the same also works with functions generating full sequences
let s1s rng = Sample.mapSeq tanh (Sample.normalSeq 2.0 0.5) rng
/// Now with multiple distributions, e.g. their product:
let s2 rng = (Sample.normal 2.0 1.5 rng) * (Sample.cauchy 2.0 0.5 rng)
let s2f rng = Sample.map2 (*) (Sample.normal 2.0 1.5) (Sample.cauchy 2.0 0.5) rng
let s2s rng = Sample.mapSeq2 (*) (Sample.normalSeq 2.0 1.5) (Sample.cauchySeq 2.0 0.5) rng
// Taking some samples from the composed function
Seq.take 10 (s2s (Random.system())) |> Seq.toArray
// The random walk from above, but this time using the composition from above
Seq.scan (+) 0.0 (s1s a) |> Seq.take 10 |> Seq.toArray

71
docs/content/index.fsx

@ -0,0 +1,71 @@
(*** hide ***)
#I "../../out/lib/net40"
#r "MathNet.Numerics.dll"
#r "MathNet.Numerics.FSharp.dll"
(**
Getting Started
===============
Installation Instructions
-------------------------
The recommended way to get Math.NET Numerics is to use NuGet. The following packages are provided and maintained in the public [NuGet Gallery](https://nuget.org/profiles/mathnet/):
- `MathNet.Numerics` - core package, including .Net 4, .Net 3.5 and portable/PCL builds
- `MathNet.Numerics.FSharp` - optional extensions for a better F# experience
- `MathNet.Numerics.Data.Text` - optional extensions for text-based matrix input/output
- `MathNet.Numerics.Data.Matlab` - optional extensions for MATLAB matrix file input/output
- `MathNet.Numerics.MKL.Win-x86` - optional Linear Algebra MKL native provider
- `MathNet.Numerics.MKL.Win-x64` - optional Linear Algebra MKL native provider
- `MathNet.Numerics.Signed` - strong-named version of the core package *(not recommended)*
- `MathNet.Numerics.FSharp.Signed` - strong-named version of the F# package *(not recommended)*
Alternatively you can also download the binaries in Zip packages, available on [CodePlex](http://mathnetnumerics.codeplex.com/releases):
- Binaries - core package and F# extensions, including .Net 4, .Net 3.5 and portable/PCL builds.
- Signed Binaries - strong-named version of the core package *(not recommended)*.
Supported Platforms:
- .Net 4.0, .Net 3.5 and Mono: Windows, Linux and Mac.
- PCL Portable Profiles 47 and 136: Silverlight 5, Windows Phone 8, .NET for Windows Store apps (Metro).
- PCL/Xamarin: Andoid, iOS
Building Math.NET Numerics
--------------------------
If you do not want to use the official binaries, or if you like to modify, debug or contribute, you can compile Math.NET Numerics locally either using Visual Studio or manually with the build scripts.
* The Visual Studio solutions should build out of the box, without any preparation steps or package restores.
* Instead of a compatible IDE you can also build the solutions with `msbuild`, or on Mono with `xbuild`.
* The full build including unit tests, docs, NuGet and Zip packages is using [FAKE](http://fsharp.github.io/FAKE/).
### How to build with MSBuild/XBuild
[lang=sh]
msbuild MathNet.Numerics.sln # only build for .Net 4 (main solution)
msbuild MathNet.Numerics.Net35Only.sln # only build for .Net 3.5
msbuild MathNet.Numerics.Portable.sln # full build with .Net 4, 3.5 and PCL profiles
xbuild MathNet.Numerics.sln # build with Mono, e.g. on Linux or Mac
### How to build with FAKE
[lang=sh]
build.cmd # normal build (.Net 4.0), run unit tests
./build.sh # normal build (.Net 4.0), run unit tests - on Linux or Mac
build.cmd Build # normal build (.Net 4.0)
build.cmd Build full # full build (.Net 3.5, 4.0, PCL)
build.cmd Build net35 # compatibility build (.Net 3.5)
build.cmd Test # normal build (.Net 4.0), run unit tests
build.cmd Test full # full build (.Net 3.5, 4.0, PCL), run all unit tests
build.cmd Test net35 # compatibility build (.Net 3.5), run unit tests
build.cmd Clean # cleanup build artifacts
build.cmd Docs # generate documentation, normal build
build.cmd NuGet # generate NuGet packages, full build
FAKE itself is not included in the repository but it will download and bootstrap itself automatically when build.cmd is run the first time. Note that this step is *not* required when using Visual Studio or `msbuild` directly.
*)

BIN
docs/files/img/logo.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

89
docs/tools/build-docs.fsx

@ -0,0 +1,89 @@
// --------------------------------------------------------------------------------------
// Builds the documentation from `.fsx` and `.md` files in the 'docs/content' directory
// (the generated documentation is stored in the 'docs/output' directory)
// --------------------------------------------------------------------------------------
// Binaries that have XML documentation (in a corresponding generated XML file)
let referenceBinaries = [ "MathNet.Numerics.dll"; "MathNet.Numerics.FSharp.dll" ]
// Web site location for the generated documentation
let website = "http://numerics.mathdotnet.com/docs"
// Specify more information about your project
let info =
[ "project-name", "Math.NET Numerics"
"project-author", "Christoph Ruegg, Marcus Cuda, Jurgen Van Gael"
"project-summary", "Math.NET Numerics, providing methods and algorithms for numerical computations in science, engineering and every day use. .Net 4, .Net 3.5, SL5, Win8, WP8, PCL 47 and 136, Mono, Xamarin Andoid/iOS."
"project-github", "http://github.com/mathnet/mathnet-numerics"
"project-nuget", "http://nuget.com/packages/MathNet.Numerics" ]
// --------------------------------------------------------------------------------------
// For typical project, no changes are needed below
// --------------------------------------------------------------------------------------
#I "../../packages/FSharp.Formatting.2.3.5-beta/lib/net40"
#I "../../packages/RazorEngine.3.3.0/lib/net40/"
#r "../../packages/Microsoft.AspNet.Razor.2.0.30506.0/lib/net40/System.Web.Razor.dll"
#I "../../packages/FSharp.Compiler.Service.0.0.11-alpha/lib/net40"
#r "../../packages/FAKE/tools/FakeLib.dll"
#r "FSharp.Compiler.Service.dll"
#r "RazorEngine.dll"
#r "FSharp.Literate.dll"
#r "FSharp.CodeFormat.dll"
#r "FSharp.MetadataFormat.dll"
open Fake
open System.IO
open Fake.FileHelper
open FSharp.Literate
open FSharp.MetadataFormat
// When called from 'build.fsx', use the public project URL as <root>
// otherwise, use the current 'output' directory.
#if RELEASE
let root = website
#else
let root = "file://" + (__SOURCE_DIRECTORY__ @@ "../../out/docs")
#endif
// Paths with template/source/output locations
let bin = __SOURCE_DIRECTORY__ @@ "../../out/lib/net40"
let content = __SOURCE_DIRECTORY__ @@ "../content"
let output = __SOURCE_DIRECTORY__ @@ "../../out/docs"
let files = __SOURCE_DIRECTORY__ @@ "../files"
let templates = __SOURCE_DIRECTORY__ @@ "templates"
let formatting = __SOURCE_DIRECTORY__ @@ "../../packages/FSharp.Formatting.2.3.5-beta/"
let docTemplate = formatting @@ "templates/docpage.cshtml"
// Where to look for *.csproj templates (in this order)
let layoutRoots =
[ templates; formatting @@ "templates"
formatting @@ "templates/reference" ]
// Copy static files and CSS + JS from F# Formatting
let copyFiles () =
CopyRecursive files output true |> Log "Copying file: "
ensureDirectory (output @@ "content")
CopyRecursive (formatting @@ "styles") (output @@ "content") true
|> Log "Copying styles and scripts: "
// Build API reference from XML comments
let buildReference () =
CleanDir (output @@ "reference")
for lib in referenceBinaries do
MetadataFormat.Generate
( bin @@ lib, output @@ "reference", layoutRoots,
parameters = ("root", root)::info )
// Build documentation from `fsx` and `md` files in `docs/content`
let buildDocumentation () =
let subdirs = Directory.EnumerateDirectories(content, "*", SearchOption.AllDirectories)
for dir in Seq.append [content] subdirs do
let sub = if dir.Length > content.Length then dir.Substring(content.Length + 1) else "."
Literate.ProcessDirectory
( dir, docTemplate, output @@ sub, replacements = ("root", root)::info,
layoutRoots = layoutRoots )
// Generate
copyFiles()
buildDocumentation()
//buildReference()

7
docs/tools/packages.config

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FSharp.Formatting" version="2.3.5-beta" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="2.0.30506.0" targetFramework="net45" />
<package id="RazorEngine" version="3.3.0" targetFramework="net45" />
<package id="FSharp.Compiler.Service" version="0.0.11-alpha" targetFramework="net45" />
</packages>

61
docs/tools/templates/template.cshtml

@ -0,0 +1,61 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>@Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="@Description">
<meta name="author" content="@Properties["project-author"]">
<script src="http://code.jquery.com/jquery-1.8.0.js"></script>
<script src="http://code.jquery.com/ui/1.8.23/jquery-ui.js"></script>
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/js/bootstrap.min.js"></script>
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.1/css/bootstrap-combined.min.css" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="@Root/content/style.css" />
<script type="text/javascript" src="@Root/content/tips.js"></script>
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<div class="masthead">
<ul class="nav nav-pills pull-right">
<li><a href="http://www.mathdotnet.com">Math.NET Project</a></li>
<li><a href="http://numerics.mathdotnet.com">Math.NET Numerics</a></li>
<li><a href="https://github.com/mathnet/mathnet-numerics">GitHub</a></li>
<li><a href="https://mathnetnumerics.codeplex.com/">CodePlex</a></li>
</ul>
<h3 class="muted">Math.NET Numerics Documenation</h3>
</div>
<hr />
<div class="row">
<div class="span9" id="main">
@RenderBody()
</div>
<div class="span3">
<ul class="nav nav-list" id="menu">
<li><img src="img/logo.png" alt="Math.NET Logo" style="width: 200px; height: 200px; margin-left: auto; margin-right: auto; display: block; " /></li>
<li class="nav-header">Math.NET Numerics</li>
<li><a href="http://numerics.mathdotnet.com">Project Website</a></li>
<li><a href="https://github.com/mathnet/mathnet-numerics/blob/master/RELEASENOTES.md">Release Notes</a></li>
<li><a href="https://github.com/mathnet/mathnet-numerics/blob/master/CONTRIBUTING.md">Contributing</a></li>
<li><a href="http://mathnetnumerics.codeplex.com/license">MIT/X11 License</a></li>
<li class="nav-header">user Guide</li>
<li><a href="@Root/index.html">Getting started</a></li>
<li><a href="@Root/RandomAndDistributions.html">Random & Distributions</a></li>
<li class="nav-header">Documentation</li>
<li><a href="http://numerics.mathdotnet.com/api/">API Reference (docu)</a></li>
<li><a href="@Root/reference/index.html">API Reference (new)</a></li>
</ul>
</div>
</div>
</div>
</body>
</html>
Loading…
Cancel
Save