forked from Tenacom/AaaLib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docs.cake
96 lines (79 loc) · 3.18 KB
/
docs.cake
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
// Copyright (C) Tenacom and contributors. Licensed under the MIT license.
// See LICENSE file in the project root for full license information.
#load "./build/BuildData.cake"
#load "./build/DocFx.cake"
#load "./build/dotnet.cake"
#load "./build/environment.cake"
#load "./build/fail.cake"
#load "./build/filesystem.cake"
#load "./build/git.cake"
#load "./build/github.cake"
#load "./build/json.cake"
#load "./build/nbgv.cake"
#load "./build/options.cake"
#load "./build/process.cake"
#load "./build/public-api.cake"
#load "./build/setup-teardown.cake"
#load "./build/versioning.cake"
#load "./build/workspace.cake"
#nullable enable
using System.Collections.Generic;
using System.Text.Json;
using SysFile = System.IO.File;
// =============================================================================================
// TASKS
// =============================================================================================
DocFx _docfx = null!;
Task("Default")
.Description("Default task - Do nothing (but log build configuration data)")
.Does(context => {
context.Information("The default task does nothing. This is intentional.");
context.Information("Use `dotnet cake --description` to see the list of available tasks.");
});
Task("_init")
.Description("Initialize DocFx support in script")
.Does<BuildData>((context, data) => {
_docfx = new DocFx(context, data, "docs");
var globalMetadata= new
{
RepoOwner = data.RepositoryOwner,
RepoName = data.RepositoryName,
RepoUrl = $"{data.RepositoryHostUrl}/{data.RepositoryOwner}/{data.RepositoryName}",
RepoVersion = data.VersionStr,
};
var options = new JsonSerializerOptions
{
WriteIndented = true,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
};
var jsonPath = new DirectoryPath("docs").CombineWithFilePath("globalMetadata.json");
using var stream = SysFile.Create(jsonPath.FullPath);
JsonSerializer.Serialize(stream, globalMetadata, options);
});
Task("_build")
.Description("Build solution to get correct metadata")
.Does<BuildData>((context, data) => context.BuildSolution(data, true));
Task("Metadata")
.Description("Generate documentation metadata from sources")
.IsDependentOn("_init")
.IsDependentOn("_build")
.Does<BuildData>(_ => _docfx.Metadata());
Task("Build")
.Description("Build documentation from metadata")
.IsDependentOn("_init")
.Does<BuildData>(_ => _docfx.Build());
Task("Serve")
.Description("Host documentation web site (only on local machine)")
.WithCriteria<BuildData>(data => !data.IsCI)
.IsDependentOn("_init")
.Does<BuildData>(_ => _docfx.Serve());
Task("All")
.Description("Generate (on local machine, also host) documentation from sources")
.IsDependentOn("_init")
.IsDependentOn("Metadata")
.IsDependentOn("Build")
.IsDependentOn("Serve");
// =============================================================================================
// EXECUTION
// =============================================================================================
RunTarget(Argument("target", "Default"));