@@ -54,6 +54,7 @@ class MustacheTemplateFile : public Template {
54
54
std::unique_ptr<llvm::MemoryBuffer> Buffer = std::move (BufferOrError.get ());
55
55
llvm::StringRef FileContent = Buffer->getBuffer ();
56
56
registerPartial (Name, FileContent);
57
+ return llvm::Error::success ();
57
58
}
58
59
59
60
MustacheTemplateFile (StringRef TemplateStr) : Template(TemplateStr) {}
@@ -72,6 +73,7 @@ setupTemplateFiles(const clang::doc::ClangDocContext &CDCtx) {
72
73
return llvm::createFileError (" cannot open file" , EC);
73
74
}
74
75
NamespaceTemplate = std::move (Template.get ());
76
+ return llvm::Error::success ();
75
77
}
76
78
77
79
llvm::Error
@@ -118,6 +120,7 @@ MustacheHTMLGenerator::generateDocs(llvm::StringRef RootDir,
118
120
}
119
121
}
120
122
}
123
+ return llvm::Error::success ();
121
124
}
122
125
123
126
Value extractValue (const Location &L,
@@ -130,6 +133,8 @@ Value extractValue(const Location &L,
130
133
SmallString<128 > FileURL (*RepositoryUrl);
131
134
llvm::sys::path::append (FileURL, llvm::sys::path::Style::posix, L.Filename );
132
135
Obj.insert ({" FileURL" , FileURL});
136
+
137
+ return Obj;
133
138
}
134
139
135
140
Value extractValue (const Reference &I, StringRef CurrentDirectory) {
@@ -280,29 +285,39 @@ Value extractValue(const NamespaceInfo &I, const ClangDocContext &CDCtx) {
280
285
Value ArrNamespace = Array ();
281
286
for (const Reference& Child : I.Children .Namespaces )
282
287
ArrNamespace.getAsArray ()->emplace_back (extractValue (Child, BasePath));
283
- NamespaceValue.insert ({" Namespace" , ArrNamespace});
288
+
289
+ if (!ArrNamespace.getAsArray ()->empty ())
290
+ NamespaceValue.insert ({" Namespace" , Object{{" Links" , ArrNamespace}}});
284
291
285
292
Value ArrRecord = Array ();
286
293
for (const Reference& Child : I.Children .Records )
287
294
ArrRecord.getAsArray ()->emplace_back (extractValue (Child, BasePath));
288
- NamespaceValue.insert ({" Record" , ArrRecord});
295
+
296
+ if (!ArrRecord.getAsArray ()->empty ())
297
+ NamespaceValue.insert ({" Record" , Object{{" Links" , ArrRecord}}});
289
298
290
299
Value ArrFunction = Array ();
291
300
for (const FunctionInfo& Child : I.Children .Functions )
292
301
ArrFunction.getAsArray ()->emplace_back (extractValue (Child, BasePath,
293
302
CDCtx));
294
- NamespaceValue.insert ({" Function" , ArrRecord});
303
+ if (!ArrFunction.getAsArray ()->empty ())
304
+ NamespaceValue.insert ({" Function" , Object{{" Obj" , ArrFunction}}});
295
305
296
306
Value ArrEnum = Array ();
297
307
for (const EnumInfo& Child : I.Children .Enums )
298
308
ArrEnum.getAsArray ()->emplace_back (extractValue (Child, CDCtx));
299
- NamespaceValue.insert ({" Enums" , ArrEnum });
309
+
310
+ if (!ArrEnum.getAsArray ()->empty ())
311
+ NamespaceValue.insert ({" Enums" , Object{{" Obj" , ArrEnum }}});
300
312
301
313
Value ArrTypedefs = Array ();
302
314
for (const TypedefInfo& Child : I.Children .Typedefs )
303
315
ArrTypedefs.getAsArray ()->emplace_back (extractValue (Child));
304
- NamespaceValue.insert ({" Typedefs" , ArrTypedefs });
305
316
317
+ if (!ArrTypedefs.getAsArray ()->empty ())
318
+ NamespaceValue.insert ({" Typedefs" , Object{{" Obj" , ArrTypedefs }}});
319
+
320
+ return NamespaceValue;
306
321
}
307
322
308
323
@@ -313,6 +328,7 @@ MustacheHTMLGenerator::generateDocForInfo(Info *I, llvm::raw_ostream &OS,
313
328
switch (I->IT ) {
314
329
case InfoType::IT_namespace: {
315
330
Value V = extractValue (*static_cast <clang::doc::NamespaceInfo *>(I), CDCtx);
331
+ llvm::outs () << V << " \n " ;
316
332
OS << NamespaceTemplate->render (V);
317
333
break ;
318
334
}
@@ -332,18 +348,18 @@ MustacheHTMLGenerator::generateDocForInfo(Info *I, llvm::raw_ostream &OS,
332
348
}
333
349
334
350
llvm::Error MustacheHTMLGenerator::createResources (ClangDocContext &CDCtx) {
335
-
351
+ return llvm::Error::success ();
336
352
}
337
353
338
- const char *MustacheHTMLGenerator::Format = " mustache " ;
354
+ const char *MustacheHTMLGenerator::Format = " mhtml " ;
339
355
340
356
341
357
static GeneratorRegistry::Add<MustacheHTMLGenerator> MHTML (MustacheHTMLGenerator::Format,
342
358
" Generator for mustache HTML output." );
343
359
344
360
// This anchor is used to force the linker to link in the generated object
345
361
// file and thus register the generator.
346
- volatile int HTMLGeneratorAnchorSource = 0 ;
362
+ volatile int MHTMLGeneratorAnchorSource = 0 ;
347
363
348
364
} // namespace doc
349
365
} // namespace clang
0 commit comments