-
Notifications
You must be signed in to change notification settings - Fork 526
Expand file tree
/
Copy pathgenerate.fsx
More file actions
159 lines (137 loc) · 5.86 KB
/
generate.fsx
File metadata and controls
159 lines (137 loc) · 5.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/// Getting help docs from Paket.exe
#r "../../bin/Argu.dll"
#r "../../bin/Paket.exe"
open System.IO
#if COMMANDS
let MaxCodeWidth = 100
Paket.Commands.getAllCommands()
|> List.iter (fun command ->
let metadata = command.ParentInfo |> Option.get
let additionalText =
let verboseOption = """
If you add the `--verbose` flag Paket will run in verbose mode and show detailed information.
With `--log-file [path]` you can trace the logged information into a file.
"""
let optFile = sprintf "../content/commands/%s.md" metadata.Name.Value
if File.Exists optFile
then verboseOption + File.ReadAllText optFile
else verboseOption
File.WriteAllText(sprintf "../content/paket-%s.md" metadata.Name.Value, Paket.Commands.markdown command MaxCodeWidth additionalText))
#endif
// --------------------------------------------------------------------------------------
// 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 = [ "Paket.Core.dll" ]
let githubLink = "http://github.com/fsprojects/Paket"
// Specify more information about your project
let info =
[ "project-name", "Paket"
"project-author", "Steffen Forkmann, Alexander Groß"
"project-summary", "A dependency manager for .NET with support for NuGet packages and git repositories."
"project-github", githubLink
"project-nuget", "http://nuget.org/packages/Paket" ]
// --------------------------------------------------------------------------------------
// For typical project, no changes are needed below
// --------------------------------------------------------------------------------------
#I "../../packages/build/FAKE/tools/"
#r "NuGet.Core.dll"
#r "FakeLib.dll"
open Fake
open Fake.DotNet
open System.IO
open Fake.FileHelper
// Paths with template/source/output locations
let bin = __SOURCE_DIRECTORY__ @@ "../../bin"
let content = __SOURCE_DIRECTORY__ @@ "../content"
let completion = __SOURCE_DIRECTORY__ @@ "../../completion"
let output = __SOURCE_DIRECTORY__ @@ "../output"
let files = __SOURCE_DIRECTORY__ @@ "../files"
let templates = __SOURCE_DIRECTORY__ @@ "templates"
let formatting = __SOURCE_DIRECTORY__ @@ "../../packages/build/FSharp.Formatting/"
let fsFormattingBin = __SOURCE_DIRECTORY__ @@ "../../packages/build/FSharp.Formatting.CommandTool/tools/fsformatting.exe"
let docTemplate = formatting @@ "templates/docpage.cshtml"
// Where to look for *.csproj templates (in this order)
let layoutRootsAll = new System.Collections.Generic.Dictionary<string, string list>()
layoutRootsAll.Add("en",[ templates; formatting @@ "templates"
formatting @@ "templates/reference" ])
subDirectories (directoryInfo templates)
|> Seq.iter (fun d ->
let name = d.Name
if name.Length = 2 || name.Length = 3 then
layoutRootsAll.Add(
name, [templates @@ name
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")
let binaries =
referenceBinaries
|> List.map (fun lib-> bin @@ lib)
binaries
|> FSFormatting.createDocsForDlls(fun s ->
{ s with
ToolPath = fsFormattingBin
OutputDirectory = output @@ "reference"
LayoutRoots = layoutRootsAll.["en"]
LibDirs = [bin]
ProjectParameters = ("root", "../")::info
Source = __SOURCE_DIRECTORY__ @@ ".." @@ ".."
SourceRepository = githubLink @@ "tree/master" })
(*RazorMetadataFormat.Generate
( binaries, output @@ "reference", layoutRootsAll.["en"],
parameters = ("root", "../")::info,
sourceRepo = githubLink @@ "tree/master",
sourceFolder = __SOURCE_DIRECTORY__ @@ ".." @@ "..",
publicOnly = true, libDirs = [bin] )
*)
// Build documentation from `fsx` and `md` files in `docs/content`
let buildDocumentation () =
!!(completion @@ "*.*.md")
|> Seq.iter (fun f ->
let target =
let name = filename f
name.Replace("README", "shell-completion")
CopyFile (content @@ target) f
)
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 "."
let langSpecificPath(lang, path:string) =
path.Split([|'/'; '\\'|], System.StringSplitOptions.RemoveEmptyEntries)
|> Array.exists(fun i -> i = lang)
let layoutRoots =
let key = layoutRootsAll.Keys |> Seq.tryFind (fun i -> langSpecificPath(i, dir))
match key with
| Some lang -> layoutRootsAll.[lang]
| None -> layoutRootsAll.["en"] // "en" is the default language
FSFormatting.createDocs (fun s ->
{ s with
ToolPath = fsFormattingBin
Source = dir
OutputDirectory = output @@ sub
Template = docTemplate
ProjectParameters = ("root", ".")::info
LayoutRoots = layoutRoots
})
(*RazorLiterate.ProcessDirectory
( dir, docTemplate, output @@ sub, replacements = ("root", ".")::info,
layoutRoots = layoutRoots,
generateAnchors = true )
*)
// Generate
copyFiles()
#if HELP
buildDocumentation()
#endif
#if REFERENCE
buildReference()
#endif