-
Notifications
You must be signed in to change notification settings - Fork 57
/
config.wyam
178 lines (163 loc) · 6.55 KB
/
config.wyam
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
Settings[Keys.Host] = "wyam.io";
Settings[Keys.LinksUseHttps] = true;
Settings[DocsKeys.Title] = "Wyam";
Settings[DocsKeys.Logo] = "/assets/img/logo.png";
Settings[DocsKeys.SourceFiles] = null;
Settings[DocsKeys.ProjectFiles] = "../release/repo/src/{!clients,*}/**/*.csproj";
//Settings[DocsKeys.ProjectFiles] = "../../Wyam/src/{!clients,*}/**/*.csproj";
Settings[DocsKeys.BaseEditUrl] = "https://github.com/Wyamio/Wyam.Web/tree/master/input/";
Settings[DocsKeys.NetlifyRedirects] = true;
Settings[DocsKeys.ImplicitInheritDoc] = true;
public class KeysModel
{
public string TargetType { get; set; }
public string Usage { get; set; } // If null, type will be scanned for const fields, otherwise <metadata> comments will be used
public bool AlphaSort { get; set; }
public string Intro { get; set; }
public KeysModel(string targetType, string usage, bool alphaSort = true)
{
TargetType = targetType;
Usage = usage;
AlphaSort = alphaSort;
}
public KeysModel(string targetType, bool alphaSort = true)
: this(targetType, null, alphaSort)
{
}
}
Pipelines.InsertBefore(Docs.RenderPages, "Modules",
Execute(ctx =>
AnalyzeCSharp()
.WithAssemblies(ctx.List<string>(DocsKeys.AssemblyFiles))
.WithProjects(ctx.List<string>(DocsKeys.ProjectFiles))
.WithNamedTypes(x => x.AllInterfaces.Any(y => y.Name == "IModule") && !x.IsAbstract)
.WhereNamespaces(x => !x.StartsWith("Wyam.Testing"))
.WherePublic()
.WithDocsForImplicitSymbols()
.WithWritePath(x => {
string name = x.String("DisplayName").ToLower();
if(name == "index")
{
name = "indx"; // Special case for the Index module
}
// Remove generic types
int genericParamsIndex = name.IndexOf("<");
if(genericParamsIndex != -1)
{
name = name.Substring(0, genericParamsIndex);
}
return new FilePath($"modules/{name}.html");
})
),
Branch(
SearchIndex(new SearchIndexItem(
@ctx.GetLink(@doc),
@doc.String(CodeAnalysisKeys.DisplayName),
@doc.String(CodeAnalysisKeys.DisplayName))
)
.WithScript((scriptBuilder, context) =>
{
// Use a custom tokenizer that splits on camel case characters
// https://github.com/olivernn/lunr.js/issues/230#issuecomment-244790648
scriptBuilder.Insert(0, @"
var camelCaseTokenizer = function (builder) {
var pipelineFunction = function (token) {
var previous = '';
var tokenStrings = token.toString().trim().split(/[\s\-]+|(?=[A-Z])/).reduce(function(acc, cur) {
var current = cur.toLowerCase();
if (acc.length === 0) {
previous = current;
return acc.concat(current);
}
previous = previous.concat(current);
return acc.concat([current, previous]);
}, []);
// return token for each string
// will copy any metadata on input token
return tokenStrings.map(function(tokenString) {
return token.clone(function(str) {
return tokenString;
})
});
}
lunr.Pipeline.registerFunction(pipelineFunction, 'camelCaseTokenizer')
builder.pipeline.before(lunr.stemmer, pipelineFunction)
}");
scriptBuilder.Replace("this.ref('id');", @"this.ref('id');
this.use(camelCaseTokenizer);");
return scriptBuilder.ToString();
})
.WithPath("assets/js/modulesSearchIndex.js"),
WriteFiles()
),
Razor().WithLayout("/_ModulesLayout.cshtml"),
Headings(),
HtmlInsert("div#infobar-headings", @ctx.GenerateInfobarHeadings(@doc)),
WriteFiles()
);
Pipelines.InsertBefore(Docs.RenderPages, "Shortcodes",
Execute(ctx =>
AnalyzeCSharp()
.WithAssemblies(ctx.List<string>(DocsKeys.AssemblyFiles))
.WithProjects(ctx.List<string>(DocsKeys.ProjectFiles))
.WithNamedTypes(x => x.AllInterfaces.Any(y => y.Name == "IShortcode") && !x.IsAbstract)
.WhereNamespaces(x => !x.StartsWith("Wyam.Testing"))
.WherePublic()
.WithDocsForImplicitSymbols()
.WithWritePath(x => {
string name = x.String("DisplayName").ToLower();
// Remove generic types
int genericParamsIndex = name.IndexOf("<");
if(genericParamsIndex != -1)
{
name = name.Substring(0, genericParamsIndex);
}
return new FilePath($"shortcodes/{name}.html");
})
),
Branch(
SearchIndex(new SearchIndexItem(
@ctx.GetLink(@doc),
@doc.String(CodeAnalysisKeys.DisplayName),
@doc.String(CodeAnalysisKeys.DisplayName))
)
.WithScript((scriptBuilder, context) =>
{
// Use a custom tokenizer that splits on camel case characters
// https://github.com/olivernn/lunr.js/issues/230#issuecomment-244790648
scriptBuilder.Insert(0, @"
var camelCaseTokenizer = function (builder) {
var pipelineFunction = function (token) {
var previous = '';
var tokenStrings = token.toString().trim().split(/[\s\-]+|(?=[A-Z])/).reduce(function(acc, cur) {
var current = cur.toLowerCase();
if (acc.length === 0) {
previous = current;
return acc.concat(current);
}
previous = previous.concat(current);
return acc.concat([current, previous]);
}, []);
// return token for each string
// will copy any metadata on input token
return tokenStrings.map(function(tokenString) {
return token.clone(function(str) {
return tokenString;
})
});
}
lunr.Pipeline.registerFunction(pipelineFunction, 'camelCaseTokenizer')
builder.pipeline.before(lunr.stemmer, pipelineFunction)
}");
scriptBuilder.Replace("this.ref('id');", @"this.ref('id');
this.use(camelCaseTokenizer);");
return scriptBuilder.ToString();
})
.WithPath("assets/js/shortcodesSearchIndex.js"),
WriteFiles()
),
Razor().WithLayout("/_ShortcodesLayout.cshtml"),
Headings(),
HtmlInsert("div#infobar-headings", @ctx.GenerateInfobarHeadings(@doc)),
WriteFiles()
);