Skip to content

Commit 8d9304b

Browse files
committed
function overloads
1 parent 258a620 commit 8d9304b

File tree

8 files changed

+897
-367
lines changed

8 files changed

+897
-367
lines changed

src/AsciidocGenerator.cpp

Lines changed: 119 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,114 @@ genMarkdown(
229229
writeDescription(C, os);
230230
}
231231

232+
//------------------------------------------------
233+
234+
namespace adoc {
235+
236+
template<class T>
237+
class list
238+
{
239+
T const& t_;
240+
241+
public:
242+
explicit
243+
list(T const& t) noexcept
244+
: t_(t)
245+
{
246+
}
247+
248+
friend
249+
llvm::raw_ostream&
250+
operator<<(
251+
llvm::raw_ostream& os,
252+
T const& t)
253+
{
254+
os <<
255+
"[cols=2]\n" <<
256+
"|===\n";
257+
258+
if(t.empty())
259+
{
260+
os <<
261+
"|===\n"
262+
"\n";
263+
return os;
264+
}
265+
}
266+
};
267+
268+
} // adoc
269+
270+
//------------------------------------------------
271+
272+
//------------------------------------------------
273+
//
274+
// Functions
275+
//
276+
//------------------------------------------------
277+
278+
void
279+
listFunctions(
280+
ClangDocContext const& CDCtx,
281+
llvm::StringRef label,
282+
mrdox::Functions const& v,
283+
llvm::raw_ostream& os)
284+
{
285+
if(v.empty())
286+
return;
287+
288+
section(label, 2, os);
289+
os <<
290+
"[cols=2]\n" <<
291+
"|===\n" <<
292+
"|Name\n" <<
293+
"|Description\n" <<
294+
"\n";
295+
os <<
296+
"|`" << v.front().name << "`\n" <<
297+
"| brief \n";
298+
for(std::size_t i = 1; i < v.size(); ++i)
299+
{
300+
auto const& f = v[i];
301+
os <<
302+
"\n" <<
303+
"|`" << f.name << "`\n" <<
304+
"| brief \n";
305+
}
306+
os <<
307+
"|===\n" <<
308+
"\n";
309+
}
310+
311+
void
312+
listFunctions(
313+
ClangDocContext const& CDCtx,
314+
llvm::StringRef label,
315+
mrdox::ScopedFunctions const& fns,
316+
llvm::raw_ostream& os)
317+
{
318+
listFunctions(
319+
CDCtx,
320+
"Public Functions",
321+
fns.overloads[clang::AccessSpecifier::AS_public],
322+
os);
323+
listFunctions(
324+
CDCtx,
325+
"Protected Functions",
326+
fns.overloads[clang::AccessSpecifier::AS_protected],
327+
os);
328+
listFunctions(
329+
CDCtx,
330+
"Private Functions",
331+
fns.overloads[clang::AccessSpecifier::AS_private],
332+
os);
333+
listFunctions(
334+
CDCtx,
335+
"Functions",
336+
fns.overloads[clang::AccessSpecifier::AS_none],
337+
os);
338+
}
339+
232340
//------------------------------------------------
233341
//
234342
// FunctionInfo
@@ -382,23 +490,30 @@ genMarkdown(
382490
writeNewLine(os);
383491
}
384492

385-
if (!I.Children.Records.empty())
493+
if( ! I.Children.Records.empty() ||
494+
! I.Children.Typedefs.empty())
386495
{
387496
section("Types", 2, os);
388-
for (const auto& R : I.Children.Records) {
497+
for (const auto& R : I.Children.Records)
498+
{
389499
os << "* ";
390500
writeNameLink(BasePath, R, os);
391501
os << "\n";
392502
}
503+
for (const auto& R : I.Children.Typedefs)
504+
os << "* " << R.Name << "\n";
393505
writeNewLine(os);
394506
}
395507

396-
listFunctions(CDCtx, "Functions", I.Children.Functions, os);
508+
listFunctions(CDCtx, "Functions", I.Children.functions, os);
509+
//listFunctions(CDCtx, "Functions", I.Children.Functions, os);
397510

511+
#if 0
398512
for(auto const& fi : I.Children.Functions)
399513
{
400514
emitFunction(CDCtx, fi, os);
401515
}
516+
#endif
402517

403518
if (!I.Children.Enums.empty()) {
404519
section("Enums", 2, os);
@@ -474,7 +589,7 @@ genMarkdown(
474589

475590
// VFALCO STATIC MEMBER FUNCTIONS
476591

477-
listFunctions(CDCtx, "Member Functions", I.Children.Functions, os);
592+
listFunctions(CDCtx, "Member Functions", I.Children.functions, os);
478593

479594
if (!I.Children.Enums.empty())
480595
{

0 commit comments

Comments
 (0)