-
Notifications
You must be signed in to change notification settings - Fork 0
/
docs.cake
85 lines (81 loc) · 4.16 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
Task("DocsGeneratePot")
.Does(() =>
{
EnsureLinux();
StartProcess("sh", new ProcessSettings {
Arguments = $"-c \"itstool -o po{sep}{shortName}.pot yelp{sep}C{sep}*.page\"",
WorkingDirectory = $"{projectName}.Shared{sep}Docs"
});
});
Task("DocsUpdatePo")
.Does(() =>
{
EnsureLinux();
foreach (var lang in FileReadLines($".{sep}{projectName}.Shared{sep}Docs{sep}po{sep}LINGUAS"))
{
Information($"Updating PO for {lang}...");
StartProcess("msgmerge", new ProcessSettings {
Arguments = $"-U .{sep}{projectName}.Shared{sep}Docs{sep}po{sep}{lang}.po .{sep}{projectName}.Shared{sep}Docs{sep}po{sep}{shortName}.pot"
});
}
});
Task("DocsUpdateYelp")
.Does(() =>
{
EnsureLinux();
foreach (var lang in FileReadLines($".{sep}{projectName}.Shared{sep}Docs{sep}po{sep}LINGUAS"))
{
Information($"Updating Yelp docs for {lang}...");
StartProcess("msgfmt", new ProcessSettings {
Arguments = $"{lang}.po -o {lang}.mo",
WorkingDirectory = $"{projectName}.Shared{sep}Docs{sep}po"
});
CreateDirectory($".{sep}{projectName}.Shared{sep}Docs{sep}yelp{sep}{lang}");
StartProcess("sh", new ProcessSettings {
Arguments = $"-c \"itstool -m po{sep}{lang}.mo -o yelp{sep}{lang}{sep} yelp{sep}C{sep}*.page\"",
WorkingDirectory = $"{projectName}.Shared{sep}Docs"
});
DeleteFile($"{projectName}.Shared{sep}Docs{sep}po{sep}{lang}.mo");
CreateDirectory($".{sep}{projectName}.Shared{sep}Docs{sep}yelp{sep}{lang}{sep}figures");
CopyDirectory($".{sep}{projectName}.Shared{sep}Docs{sep}yelp{sep}C{sep}figures", $".{sep}{projectName}.Shared{sep}Docs{sep}yelp{sep}{lang}{sep}figures");
}
});
Task("DocsUpdateHtml")
.Does(() =>
{
EnsureLinux();
//C for english
CreateDirectory($"{projectName}.Shared{sep}Docs{sep}html{sep}C");
CreateDirectory($"{projectName}.Shared{sep}Docs{sep}html{sep}C{sep}figures");
CopyDirectory($"{projectName}.Shared{sep}Docs{sep}yelp{sep}C{sep}figures", $"{projectName}.Shared{sep}Docs{sep}html{sep}C{sep}figures");
Information("Generating html for C...");
StartProcess("yelp-build", new ProcessSettings {
Arguments = $"html -o html{sep}C{sep} yelp{sep}C{sep}",
WorkingDirectory = $"{projectName}.Shared{sep}Docs"
});
//Other langs
foreach (var lang in FileReadLines($".{sep}{projectName}.Shared{sep}Docs{sep}po{sep}LINGUAS"))
{
Information($"Generating html for {lang}...");
CreateDirectory($"{projectName}.Shared{sep}Docs{sep}html{sep}{lang}");
StartProcess("yelp-build", new ProcessSettings {
Arguments = $"html -o html{sep}{lang}{sep} yelp{sep}{lang}{sep}",
WorkingDirectory = $"{projectName}.Shared{sep}Docs"
});
DeleteDirectory($"{projectName}.Shared{sep}Docs{sep}html{sep}{lang}{sep}figures", new DeleteDirectorySettings {
Force = true,
Recursive = true
});
DeleteFiles($"{projectName}.Shared{sep}Docs{sep}html{sep}{lang}{sep}*.css");
DeleteFiles($"{projectName}.Shared{sep}Docs{sep}html{sep}{lang}{sep}*.js");
ReplaceRegexInFiles($"{projectName}.Shared{sep}Docs{sep}html{sep}{lang}{sep}*.html", "href=\".*.css\"", "href=\"../C/C.css\"");
ReplaceRegexInFiles($"{projectName}.Shared{sep}Docs{sep}html{sep}{lang}{sep}*.html", "src=\"highlight.pack.js\"", "src=\"../C/highlight.pack.js\"");
ReplaceRegexInFiles($"{projectName}.Shared{sep}Docs{sep}html{sep}{lang}{sep}*.html", "src=\"yelp.js\"", "src=\"../C/yelp.js\"");
ReplaceRegexInFiles($"{projectName}.Shared{sep}Docs{sep}html{sep}{lang}{sep}*.html", $"src=\"figures/{shortName}.png\"", $"src=\"../C/figures/{shortName}.png\"");
}
});
Task("DocsUpdateAll")
.IsDependentOn("DocsGeneratePot")
.IsDependentOn("DocsUpdatePo")
.IsDependentOn("DocsUpdateYelp")
.IsDependentOn("DocsUpdateHtml");