@@ -5,5 +5,72 @@ open CommandLine
5
5
6
6
[<Verb( " init" , HelpText = " initialize the necessary folder structure and files for creating documentation with fsdocs." ) >]
7
7
type InitCommand () =
8
- class
9
- end
8
+
9
+ let dir = Path.GetDirectoryName( typeof< InitCommand>. Assembly.Location)
10
+
11
+ // get template locations for in-package and in-repo and decide which to use later
12
+ let inPackageLocations = Common.InPackageLocations( Path.Combine( dir, " .." , " .." , " .." ))
13
+ let inRepoLocations = Common.InRepoLocations( Path.Combine( dir, " .." , " .." , " .." , " .." , " .." ))
14
+
15
+ [<Option( " output" ,
16
+ Required = false ,
17
+ Default = " docs" ,
18
+ HelpText = " The output path for the documentation folder structure" ) >]
19
+ member val output : string = " docs" with get, set
20
+
21
+ member this.Execute () =
22
+
23
+ let outputPath = Path.GetFullPath( this.output)
24
+ let repoRoot = Path.GetFullPath( Path.Combine( outputPath, " .." ))
25
+ let initLocations = Common.InRepoLocations( repoRoot)
26
+
27
+ let ensureOutputDirs () =
28
+ [ outputPath; initLocations.docs; initLocations.docs_ img ]
29
+ |> List.iter ensureDirectory
30
+
31
+ if inPackageLocations.Exist() then
32
+ ensureOutputDirs ()
33
+
34
+ try
35
+ [ ( inPackageLocations.template_ html, initLocations.template_ html)
36
+ ( inPackageLocations.template_ ipynb, initLocations.template_ ipynb)
37
+ ( inPackageLocations.template_ tex, initLocations.template_ tex)
38
+ ( inPackageLocations.dockerfile, initLocations.dockerfile)
39
+ ( inPackageLocations.nuget_ config, initLocations.nuget_ config)
40
+ ( inPackageLocations.logo_ template, Path.GetFullPath( Path.Combine( initLocations.docs_ img, " logo.png" )))
41
+ ( inPackageLocations.index_ md_ template, Path.GetFullPath( Path.Combine( initLocations.docs, " index.md" )))
42
+ ( inPackageLocations.literate_ sample_ template,
43
+ Path.GetFullPath( Path.Combine( initLocations.docs, " literate_sample.fsx" ))) ]
44
+ |> List.iter ( fun ( src , dst ) -> File.Copy( src, dst, true ))
45
+
46
+ 0
47
+ with e as exn ->
48
+ printfn " Error: %s " exn.Message
49
+ 1
50
+
51
+ elif inRepoLocations.Exist() then
52
+ ensureOutputDirs ()
53
+
54
+ try
55
+ [ ( inRepoLocations.template_ html, initLocations.template_ html)
56
+ ( inRepoLocations.template_ ipynb, initLocations.template_ ipynb)
57
+ ( inRepoLocations.template_ tex, initLocations.template_ tex)
58
+ ( inRepoLocations.dockerfile, initLocations.dockerfile)
59
+ ( inRepoLocations.nuget_ config, initLocations.nuget_ config)
60
+ ( inRepoLocations.logo_ template, Path.GetFullPath( Path.Combine( initLocations.docs_ img, " logo.png" )))
61
+ ( inRepoLocations.index_ md_ template, Path.GetFullPath( Path.Combine( initLocations.docs, " index.md" )))
62
+ ( inRepoLocations.literate_ sample_ template,
63
+ Path.GetFullPath( Path.Combine( initLocations.docs, " literate_sample.fsx" ))) ]
64
+ |> List.iter ( fun ( src , dst ) -> File.Copy( src, dst, true ))
65
+
66
+ 0
67
+ with e as exn ->
68
+ printfn " Error: %s " exn.Message
69
+ 1
70
+ else
71
+ printfn
72
+ " no sources for default files found from either %s or %s "
73
+ inPackageLocations.RelAssemblyPath
74
+ inRepoLocations.RelAssemblyPath
75
+
76
+ 1
0 commit comments