Skip to content

Commit f450458

Browse files
committed
output format work
1 parent 97ac444 commit f450458

File tree

2 files changed

+222
-12
lines changed

2 files changed

+222
-12
lines changed

source/lib/format/Asciidoc.cpp

+207-12
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,9 @@ writeRecord(
234234
RecordInfo const& I)
235235
{
236236
openSection(I.Name);
237-
if(auto brief = I.javadoc.getBrief())
238-
{
239-
// print it
240-
}
237+
238+
// Brief
239+
writeBrief(I.javadoc.getBrief());
241240

242241
// Synopsis
243242
openSection("Synopsis");
@@ -262,13 +261,8 @@ writeRecord(
262261
"----\n";
263262
closeSection();
264263

265-
//if(! I.javadoc.desc.empty())
266-
{
267-
os_ << "\n";
268-
openSection("Description");
269-
//os_ << I.javadoc.desc << "\n";
270-
closeSection();
271-
}
264+
// Description
265+
writeDescription(I.javadoc.getBlocks());
272266

273267
writeMemberTypes(
274268
"Data Members",
@@ -318,8 +312,11 @@ Writer::
318312
writeFunction(
319313
FunctionInfo const& I)
320314
{
315+
return;
321316
openSection(I.Name);
322-
//os_ << I.javadoc.brief << "\n\n";
317+
318+
// Brief
319+
writeBrief(I.javadoc.getBrief());
323320

324321
// Synopsis
325322
openSection("Synopsis");
@@ -329,6 +326,9 @@ writeFunction(
329326
"[,cpp]\n"
330327
"----\n";
331328

329+
// Description
330+
writeDescription(I.javadoc.getBlocks());
331+
332332
// params
333333
if(! I.Params.empty())
334334
{
@@ -371,6 +371,16 @@ Writer::
371371
writeEnum(
372372
EnumInfo const& I)
373373
{
374+
return;
375+
openSection(I.Name);
376+
377+
// Brief
378+
writeBrief(I.javadoc.getBrief());
379+
380+
// Description
381+
writeDescription(I.javadoc.getBlocks());
382+
383+
closeSection();
374384
}
375385

376386
void
@@ -379,6 +389,16 @@ Writer::
379389
writeTypedef(
380390
TypedefInfo const& I)
381391
{
392+
return;
393+
openSection(I.Name);
394+
395+
// Brief
396+
writeBrief(I.javadoc.getBrief());
397+
398+
// Description
399+
writeDescription(I.javadoc.getBlocks());
400+
401+
closeSection();
382402
}
383403

384404
//------------------------------------------------
@@ -478,6 +498,181 @@ writeMemberTypes(
478498

479499
//------------------------------------------------
480500

501+
void
502+
AsciidocGenerator::
503+
Writer::
504+
writeBrief(
505+
Javadoc::Paragraph const* node)
506+
{
507+
if(! node)
508+
return;
509+
if(node->empty())
510+
return;
511+
writeNode(*node);
512+
}
513+
514+
void
515+
AsciidocGenerator::
516+
Writer::
517+
writeDescription(
518+
List<Javadoc::Block> const& list)
519+
{
520+
if(list.empty())
521+
return;
522+
os_ << "\n";
523+
openSection("Description");
524+
writeNodes(list);
525+
closeSection();
526+
}
527+
528+
//------------------------------------------------
529+
530+
template<class T>
531+
void
532+
AsciidocGenerator::
533+
Writer::
534+
writeNodes(
535+
List<T> const& list)
536+
{
537+
if(list.empty())
538+
return;
539+
for(auto const& node : list)
540+
writeNode(node);
541+
}
542+
543+
void
544+
AsciidocGenerator::
545+
Writer::
546+
writeNode(
547+
Javadoc::Node const& node)
548+
{
549+
switch(node.kind)
550+
{
551+
case Javadoc::Kind::text:
552+
writeNode(static_cast<Javadoc::Text const&>(node));
553+
return;
554+
case Javadoc::Kind::styled:
555+
writeNode(static_cast<Javadoc::StyledText const&>(node));
556+
return;
557+
#if 0
558+
case Javadoc::Node::block:
559+
writeNode(static_cast<Javadoc::Block const&>(node));
560+
return;
561+
#endif
562+
case Javadoc::Kind::brief:
563+
case Javadoc::Kind::paragraph:
564+
writeNode(static_cast<Javadoc::Paragraph const&>(node));
565+
return;
566+
case Javadoc::Kind::admonition:
567+
writeNode(static_cast<Javadoc::Admonition const&>(node));
568+
return;
569+
case Javadoc::Kind::code:
570+
writeNode(static_cast<Javadoc::Code const&>(node));
571+
return;
572+
case Javadoc::Kind::param:
573+
writeNode(static_cast<Javadoc::Param const&>(node));
574+
return;
575+
case Javadoc::Kind::tparam:
576+
writeNode(static_cast<Javadoc::TParam const&>(node));
577+
return;
578+
case Javadoc::Kind::returns:
579+
writeNode(static_cast<Javadoc::Returns const&>(node));
580+
return;
581+
default:
582+
llvm_unreachable("unknown kind");
583+
}
584+
}
585+
586+
void
587+
AsciidocGenerator::
588+
Writer::
589+
writeNode(
590+
Javadoc::Text const& node)
591+
{
592+
os_ << node.text << '\n';
593+
}
594+
595+
void
596+
AsciidocGenerator::
597+
Writer::
598+
writeNode(
599+
Javadoc::StyledText const& node)
600+
{
601+
switch(node.style)
602+
{
603+
case Javadoc::Style::bold:
604+
os_ << '*' << node.text << '*';
605+
break;
606+
case Javadoc::Style::mono:
607+
os_ << '`' << node.text << '`';
608+
break;
609+
case Javadoc::Style::italic:
610+
os_ << '_' << node.text << '_';
611+
break;
612+
default:
613+
os_ << node.text;
614+
break;
615+
}
616+
}
617+
618+
void
619+
AsciidocGenerator::
620+
Writer::
621+
writeNode(
622+
Javadoc::Paragraph const& node)
623+
{
624+
writeNodes(node.list);
625+
}
626+
627+
void
628+
AsciidocGenerator::
629+
Writer::
630+
writeNode(
631+
Javadoc::Admonition const& node)
632+
{
633+
writeNodes(node.list);
634+
}
635+
636+
void
637+
AsciidocGenerator::
638+
Writer::
639+
writeNode(
640+
Javadoc::Code const& node)
641+
{
642+
os_ <<
643+
"[,cpp]\n"
644+
"----\n";
645+
writeNodes(node.list);
646+
os_ <<
647+
"----\n";
648+
}
649+
650+
void
651+
AsciidocGenerator::
652+
Writer::
653+
writeNode(
654+
Javadoc::Param const& node)
655+
{
656+
}
657+
658+
void
659+
AsciidocGenerator::
660+
Writer::
661+
writeNode(
662+
Javadoc::TParam const& node)
663+
{
664+
}
665+
666+
void
667+
AsciidocGenerator::
668+
Writer::
669+
writeNode(
670+
Javadoc::Returns const& node)
671+
{
672+
}
673+
674+
//------------------------------------------------
675+
481676
void
482677
AsciidocGenerator::
483678
Writer::

source/lib/format/Asciidoc.hpp

+15
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,21 @@ class AsciidocGenerator::Writer
113113
llvm::SmallVectorImpl<MemberTypeInfo> const& list,
114114
AccessSpecifier access);
115115

116+
void writeBrief(Javadoc::Paragraph const* node);
117+
void writeDescription(List<Javadoc::Block> const& list);
118+
119+
template<class T>
120+
void writeNodes(List<T> const& list);
121+
void writeNode(Javadoc::Node const& node);
122+
void writeNode(Javadoc::Text const& node);
123+
void writeNode(Javadoc::StyledText const& node);
124+
void writeNode(Javadoc::Paragraph const& node);
125+
void writeNode(Javadoc::Admonition const& node);
126+
void writeNode(Javadoc::Code const& node);
127+
void writeNode(Javadoc::Param const& node);
128+
void writeNode(Javadoc::TParam const& node);
129+
void writeNode(Javadoc::Returns const& node);
130+
116131
FormalParam formalParam(FieldTypeInfo const& ft);
117132
TypeName typeName(TypeInfo const& ti);
118133

0 commit comments

Comments
 (0)