Skip to content

Commit f53619d

Browse files
committed
chore: Javadoc::makeOverview
1 parent ecf237e commit f53619d

File tree

2 files changed

+82
-3
lines changed

2 files changed

+82
-3
lines changed

include/mrdox/Metadata/Javadoc.hpp

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,15 @@ void traverse(
557557
std::forward<Args>(args)...);
558558
}
559559

560+
struct Overview
561+
{
562+
Paragraph const* brief;
563+
std::vector<Block const*> blocks;
564+
Returns const* returns;
565+
std::vector<Param const*> params;
566+
std::vector<TParam const*> tparams;
567+
};
568+
560569
} // doc
561570

562571
//------------------------------------------------
@@ -566,9 +575,6 @@ void traverse(
566575
struct MRDOX_VISIBLE
567576
Javadoc
568577
{
569-
570-
//--------------------------------------------
571-
572578
MRDOX_DECL
573579
Javadoc() noexcept;
574580

@@ -673,6 +679,21 @@ struct MRDOX_VISIBLE
673679
void
674680
postProcess();
675681

682+
/** Return an overview of the javadoc.
683+
684+
The Javadoc is stored as a list of blocks,
685+
in the order of appearance in the corresponding
686+
source code. This function separates elements
687+
according to their semantic content and returns
688+
the result as a set of collated lists and
689+
individual elements.
690+
691+
Ownership of the nodes is not transferred;
692+
the returend overview is invalidated if the
693+
javadoc object is destroyed.
694+
*/
695+
MRDOX_DECL doc::Overview makeOverview() const;
696+
676697
//--------------------------------------------
677698

678699
/** These are used to bottleneck all insertions.

source/Metadata/Javadoc.cpp

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,55 @@
1818
namespace clang {
1919
namespace mrdox {
2020

21+
namespace doc {
22+
23+
static
24+
Overview
25+
makeOverview(
26+
List<Block> const& list)
27+
{
28+
doc::Overview ov;
29+
30+
// VFALCO dupes should already be reported as
31+
// warnings or errors by now so we don't have
32+
// to care about it here.
33+
34+
for(auto it = list.begin();
35+
it != list.end(); ++it)
36+
{
37+
switch((*it)->kind)
38+
{
39+
case Kind::brief:
40+
ov.brief = static_cast<
41+
Paragraph const*>(it->get());
42+
break;
43+
case Kind::returns:
44+
ov.returns = static_cast<
45+
Returns const*>(it->get());
46+
break;
47+
case Kind::param:
48+
ov.params.push_back(static_cast<
49+
Param const*>(it->get()));
50+
break;
51+
case Kind::tparam:
52+
ov.tparams.push_back(static_cast<
53+
TParam const*>(it->get()));
54+
break;
55+
case Kind::paragraph:
56+
ov.brief = static_cast<
57+
Paragraph const*>(it->get());
58+
break;
59+
default:
60+
ov.blocks.push_back(it->get());
61+
break;
62+
}
63+
}
64+
65+
return ov;
66+
}
67+
68+
} // doc
69+
2170
//------------------------------------------------
2271

2372
template<typename T, typename U>
@@ -170,5 +219,14 @@ postProcess()
170219
// as the brief when no written brief exists?
171220
}
172221

222+
//------------------------------------------------
223+
224+
doc::Overview
225+
Javadoc::
226+
makeOverview() const
227+
{
228+
return doc::makeOverview(blocks_);
229+
}
230+
173231
} // mrdox
174232
} // clang

0 commit comments

Comments
 (0)