Skip to content

Commit

Permalink
Update to new version of F# formatting tools
Browse files Browse the repository at this point in the history
  • Loading branch information
tpetricek committed Nov 2, 2013
1 parent 9a43402 commit b45d01c
Show file tree
Hide file tree
Showing 8 changed files with 121 additions and 61 deletions.
25 changes: 17 additions & 8 deletions RProvider.sln
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# Visual Studio 2013
VisualStudioVersion = 12.0.20827.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "RProvider", "src\RProvider\RProvider.fsproj", "{5624F098-BE3F-4C8E-B50F-1CFC9E1E0708}"
EndProject
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "RWrapperGenerator", "src\RWrapperGenerator\RWrapperGenerator.fsproj", "{66A390A5-526A-4BD1-B876-E7425B643C70}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{5FA7D1AD-DEDA-4553-81D1-6E4728386A2F}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "project", "project", "{5FA7D1AD-DEDA-4553-81D1-6E4728386A2F}"
ProjectSection(SolutionItems) = preProject
build.cmd = build.cmd
build.fsx = build.fsx
LICENSE.md = LICENSE.md
README.md = README.md
RELEASE_NOTES.md = RELEASE_NOTES.md
nuget\RProvider.nuspec = nuget\RProvider.nuspec
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{6D45A358-1BAC-4180-BEE7-39996F45DEAC}"
Expand All @@ -19,6 +25,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{6D45A3
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{B34F96AE-40C8-44AC-8D82-5196202C080E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{9C22FF03-BB06-4332-8104-20AB4959BABA}"
ProjectSection(SolutionItems) = preProject
docs\tools\generate.fsx = docs\tools\generate.fsx
docs\tools\templates\template.cshtml = docs\tools\templates\template.cshtml
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{33FDB386-BD2B-417C-B94D-7C2F11A3E2D0}"
ProjectSection(SolutionItems) = preProject
docs\content\Charts-QuickStart.fsx = docs\content\Charts-QuickStart.fsx
docs\content\howto.md = docs\content\howto.md
Expand All @@ -31,12 +45,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{B34F96AE-4
docs\content\whatwhy.md = docs\content\whatwhy.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{9C22FF03-BB06-4332-8104-20AB4959BABA}"
ProjectSection(SolutionItems) = preProject
docs\tools\generate.fsx = docs\tools\generate.fsx
docs\tools\template.html = docs\tools\template.html
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -57,5 +65,6 @@ Global
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{9C22FF03-BB06-4332-8104-20AB4959BABA} = {B34F96AE-40C8-44AC-8D82-5196202C080E}
{33FDB386-BD2B-417C-B94D-7C2F11A3E2D0} = {B34F96AE-40C8-44AC-8D82-5196202C080E}
EndGlobalSection
EndGlobal
38 changes: 20 additions & 18 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

#r "packages/FAKE/tools/FakeLib.dll"
open System
open System.IO
open Fake
open Fake.Git
open Fake.AssemblyInfoFile
open Fake.ReleaseNotesHelper

Environment.CurrentDirectory <- __SOURCE_DIRECTORY__

// --------------------------------------------------------------------------------------
// Information about the project to be used at NuGet and in AssemblyInfo files
// --------------------------------------------------------------------------------------

let projectName = "RProvider"
let projectSummary = "An F# Type Provider providing strongly typed access to the R statistical package."
let projectDescription = """
Expand All @@ -23,14 +24,19 @@ let authors = ["BlueMountain Capital"]
let companyName = "BlueMountain Capital"
let tags = "F# fsharp R TypeProvider visualization statistics"

// Read release notes & version info from RELEASE_NOTES.md
let release =
File.ReadLines "RELEASE_NOTES.md"
|> ReleaseNotesHelper.parseReleaseNotes
let gitHome = "https://github.com/BlueMountainCapital"
let gitName = "FSharpRProvider"
let testAssemblies = []

// --------------------------------------------------------------------------------------
// Generate assembly info files with the right version & up-to-date information
// The rest of the code is standard F# build script
// --------------------------------------------------------------------------------------

// Read release notes & version info from RELEASE_NOTES.md
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
let release = IO.File.ReadLines "RELEASE_NOTES.md" |> parseReleaseNotes

// Generate assembly info files with the right version & up-to-date information
Target "AssemblyInfo" (fun _ ->
let fileName = "src/Common/AssemblyInfo.fs"
CreateFSharpAssemblyInfo fileName
Expand Down Expand Up @@ -124,20 +130,15 @@ Target "NuGet" (fun _ ->
// --------------------------------------------------------------------------------------
// Generate the documentation

Target "JustGenerateDocs" (fun _ ->
executeFSI "docs/tools" "generate.fsx" [] |> ignore
Target "GenerateDocs" (fun _ ->
executeFSIWithArgs "docs/tools" "generate.fsx" ["--define:RELEASE"] [] |> ignore
)

Target "GenerateDocs" DoNothing
"CleanDocs" ==> "JustGenerateDocs" ==> "GenerateDocs"

// --------------------------------------------------------------------------------------
// Release Scripts

let gitHome = "https://github.com/BlueMountainCapital"

Target "ReleaseDocs" (fun _ ->
Repository.clone "" (gitHome + "/FSharpRProvider.git") "temp/gh-pages"
Repository.clone "" (gitHome + "/" + gitName + ".git") "temp/gh-pages"
Branches.checkoutBranch "temp/gh-pages" "gh-pages"
CopyRecursive "docs/output" "temp/gh-pages" true |> printfn "%A"
CommandHelper.runSimpleGitCommand "temp/gh-pages" "add ." |> printfn "%s"
Expand All @@ -147,7 +148,7 @@ Target "ReleaseDocs" (fun _ ->
)

Target "ReleaseBinaries" (fun _ ->
Repository.clone "" (gitHome + "/FSharpRProvider.git") "temp/release"
Repository.clone "" (gitHome + "/" + gitName + ".git") "temp/release"
Branches.checkoutBranch "temp/release" "release"
CopyRecursive "bin" "temp/release" true |> printfn "%A"
let cmd = sprintf """commit -a -m "Update binaries for version %s""" release.NugetVersion
Expand All @@ -166,11 +167,12 @@ Target "All" DoNothing
==> "RestorePackages"
==> "AssemblyInfo"
==> "Build"
==> "GenerateDocs"
==> "RunTests"
==> "All"

"All"
==> "CleanDocs"
==> "GenerateDocs"
==> "ReleaseDocs"
==> "ReleaseBinaries"
==> "NuGet"
Expand Down
4 changes: 2 additions & 2 deletions docs/content/tutorial.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ After running the first snippet, a window similar to the following should appear
it might not appear as a top-most window).
<div style="text-align:center">
<img src="img/acf.png" />
<img src="images/acf.png" />
</div>
Finally, we can obtain data for multiple different indicators and use the `R.pairs` function
Expand All @@ -108,7 +108,7 @@ R.pairs(df)
As a result, you should see a window showing results similar to these:
<div style="text-align:center">
<img src="img/pairs.png" />
<img src="images/pairs.png" />
</div>
*)
Binary file removed docs/files/img/acf.png
Binary file not shown.
Binary file removed docs/files/img/pairs.png
Binary file not shown.
109 changes: 78 additions & 31 deletions docs/tools/generate.fsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,86 @@
// --------------------------------------------------------------------------------------
// Builds the documentation from FSX files in the 'samples' directory
// (the documentation is stored in the 'docs' directory)
// Builds the documentation from `.fsx` and `.md` files in the 'docs/content' directory
// (the generated documentation is stored in the 'docs/output' directory)
// --------------------------------------------------------------------------------------

#I "../../packages/FSharp.Formatting.2.0.1/lib/net40"
// Binaries that have XML documentation (in a corresponding generated XML file)
let referenceBinaries = [ ]
// Web site location for the generated documentation
let website = "http://bluemountaincapital.github.io/FSharpRProvider"

// Specify more information about your project
let info =
[ "project-name", "R Type Provider"
"project-author", "BlueMountain Capital"
"project-summary", "An F# Type Provider providing strongly typed access to the R statistical package"
"project-github", "http://github.com/BlueMountainCapital/FSharpRProvider"
"project-nuget", "https://nuget.org/packages/RProvider" ]

// --------------------------------------------------------------------------------------
// For typical project, no changes are needed below
// --------------------------------------------------------------------------------------

#I "../../packages/FSharp.Formatting.2.2.1/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"
#r "../../packages/FAKE/tools/FakeLib.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__ @@ "../output")
#endif

// Paths with template/source/output locations
let bin = __SOURCE_DIRECTORY__ @@ "../../bin"
let content = __SOURCE_DIRECTORY__ @@ "../content"
let output = __SOURCE_DIRECTORY__ @@ "../output"
let files = __SOURCE_DIRECTORY__ @@ "../files"
let templates = __SOURCE_DIRECTORY__ @@ "templates"
let formatting = __SOURCE_DIRECTORY__ @@ "../../packages/FSharp.Formatting.2.2.1/"
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 @@ "content") (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 )

let (++) a b = Path.Combine(a, b)
let template = __SOURCE_DIRECTORY__ ++ "template.html"
let sources = __SOURCE_DIRECTORY__ ++ "../content"
let files = __SOURCE_DIRECTORY__ ++ "../files"
let output = __SOURCE_DIRECTORY__ ++ "../output"

// Root URL for the generated HTML
let root = "http://bluemountaincapital.github.io/FSharpRProvider"
// Root URL for local testing
// let root = "file://C:\dev\FSharp.RProvider\generated"

// Generate HTML from all FSX files in samples & subdirectories
let build () =
// Copy all sample data files to the "data" directory
let copy = [ sources ++ "../../packages/FSharp.Formatting.2.0.1/literate/content", output ++ "content"
files ++ "img", output ++ "img"
files ++ "misc", output ++ "misc" ]
for source, target in copy do
if Directory.Exists target then Directory.Delete(target, true)
Directory.CreateDirectory target |> ignore
for fileInfo in DirectoryInfo(source).EnumerateFiles() do
fileInfo.CopyTo(target ++ fileInfo.Name) |> ignore

Literate.ProcessDirectory
( sources, template, output,
replacements = [ "root", root ] )

build()
// Generate
copyFiles()
buildDocumentation()
buildReference()
4 changes: 3 additions & 1 deletion docs/tools/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FSharp.Data" version="1.1.10" targetFramework="net45" />
<package id="FSharp.Formatting" version="2.0.1" targetFramework="net45" />
<package id="FSharp.Formatting" version="2.2.1" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="2.0.30506.0" targetFramework="net45" />
<package id="RazorEngine" version="3.3.0" targetFramework="net45" />
</packages>
2 changes: 1 addition & 1 deletion nuget/RProvider.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
</metadata>
<files>
<file src="..\bin\RProvider.dll" target="lib" />
<file src="..\bin\RProvider.pdb" target="lib" />
<file src="..\bin\RProvider.pdb" target="lib" />
<file src="..\nuget\init.ps1" target="tools" />
</files>
</package>
Expand Down

0 comments on commit b45d01c

Please sign in to comment.