Skip to content

Commit 81d2d91

Browse files
committed
Javadoc returns paragraph has its own container
1 parent 6c4cbda commit 81d2d91

File tree

4 files changed

+69
-6
lines changed

4 files changed

+69
-6
lines changed

include/mrdox/Metadata/AnyList.hpp

+49-6
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,8 @@ class AnyList : public AnyListBase<compare_result_t<T>>
140140
T& back() noexcept;
141141

142142
void clear() noexcept;
143+
iterator erase(iterator it) noexcept;
144+
143145
AnyListNodes extractNodes() noexcept;
144146
void spliceBack(AnyListNodes&& nodes) noexcept;
145147

@@ -239,9 +241,6 @@ class AnyList<T>::iterator_impl
239241
{
240242
friend class AnyList;
241243

242-
using value_type = std::conditional_t<isConst, T const, T>;
243-
using pointer = std::conditional_t<isConst, T const*, T*>;
244-
using reference = std::conditional_t<isConst, T const&, T&>;
245244
using node_type = std::conditional_t<isConst, Node const, Node>;
246245

247246
node_type* it_;
@@ -256,12 +255,23 @@ class AnyList<T>::iterator_impl
256255
}
257256

258257
public:
259-
using size_type = std::size_t;
260-
using iterator_category =
261-
std::forward_iterator_tag;
258+
using value_type = std::conditional_t<isConst, T const, T>;
259+
using pointer = std::conditional_t<isConst, T const*, T*>;
260+
using reference = std::conditional_t<isConst, T const&, T&>;
261+
using size_type = std::size_t;
262+
using iterator_category = std::forward_iterator_tag;
262263

263264
iterator_impl() = default;
264265

266+
template<bool IsConst_, class =
267+
std::enable_if_t<! IsConst_>>
268+
iterator_impl(
269+
iterator_impl<IsConst_> other) noexcept
270+
: it_(other.it_)
271+
, prev_(other.prev_)
272+
{
273+
}
274+
265275
iterator_impl& operator++() noexcept
266276
{
267277
prev_ = it_;
@@ -542,6 +552,39 @@ clear() noexcept
542552
size_ = 0;
543553
}
544554

555+
template<class T>
556+
auto
557+
AnyList<T>::
558+
erase(
559+
iterator it) noexcept ->
560+
iterator
561+
{
562+
iterator result;
563+
if(it.it_ == head_)
564+
{
565+
head_ = head_->next;
566+
if( head_ == &end_)
567+
{
568+
tail_ = &end_;
569+
result = iterator( &end_, nullptr );
570+
}
571+
else
572+
{
573+
result = iterator( head_, nullptr );
574+
}
575+
}
576+
else
577+
{
578+
result = iterator( it.it_->next, it.prev_ );
579+
it.prev_->next = it.it_->next;
580+
if( it.it_->next == &end_)
581+
tail_ = it.prev_;
582+
}
583+
delete it.it_;
584+
--size_;
585+
return result;
586+
}
587+
545588
template<class T>
546589
AnyListNodes
547590
AnyList<T>::

include/mrdox/Metadata/Javadoc.hpp

+9
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,14 @@ struct MRDOX_VISIBLE
326326
return blocks_;
327327
}
328328

329+
/** Return the element describing the return type.
330+
*/
331+
Returns const*
332+
getReturns() const noexcept
333+
{
334+
return returns_.get();
335+
}
336+
329337
/** Return the list of top level blocks.
330338
*/
331339
AnyList<Param> const&
@@ -439,6 +447,7 @@ struct MRDOX_VISIBLE
439447

440448
private:
441449
std::shared_ptr<Paragraph const> brief_;
450+
std::shared_ptr<Returns const> returns_;
442451
AnyList<Block> blocks_;
443452
AnyList<Param> params_;
444453
AnyList<TParam> tparams_;

source/api/Metadata/Javadoc.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ postProcess()
8686
brief = static_cast<Paragraph*>(&*it);
8787
goto done;
8888
}
89+
else if(it->kind == Kind::returns)
90+
{
91+
if(! returns_)
92+
{
93+
returns_ = std::make_shared<Returns>(
94+
std::move(static_cast<Returns &>(*it)));
95+
it = blocks_.erase(it);
96+
}
97+
}
8998
else if(it->kind == Kind::param)
9099
{
91100
it = blocks_.move_to(it, params_);

source/api/_XML/XMLWriter.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,8 @@ writeJavadoc(
448448
if(auto brief = javadoc->getBrief())
449449
writeBrief(*brief);
450450
writeNodes(javadoc->getBlocks());
451+
if(auto returns = javadoc->getReturns())
452+
writeNode(*returns);
451453
writeNodes(javadoc->getParams());
452454
writeNodes(javadoc->getTParams());
453455
tags_.close(javadocTagName);

0 commit comments

Comments
 (0)