Skip to content

Commit

Permalink
Javadoc returns paragraph has its own container
Browse files Browse the repository at this point in the history
  • Loading branch information
vinniefalco committed May 4, 2023
1 parent 6c4cbda commit 81d2d91
Showing 4 changed files with 69 additions and 6 deletions.
55 changes: 49 additions & 6 deletions include/mrdox/Metadata/AnyList.hpp
Original file line number Diff line number Diff line change
@@ -140,6 +140,8 @@ class AnyList : public AnyListBase<compare_result_t<T>>
T& back() noexcept;

void clear() noexcept;
iterator erase(iterator it) noexcept;

AnyListNodes extractNodes() noexcept;
void spliceBack(AnyListNodes&& nodes) noexcept;

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

using value_type = std::conditional_t<isConst, T const, T>;
using pointer = std::conditional_t<isConst, T const*, T*>;
using reference = std::conditional_t<isConst, T const&, T&>;
using node_type = std::conditional_t<isConst, Node const, Node>;

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

public:
using size_type = std::size_t;
using iterator_category =
std::forward_iterator_tag;
using value_type = std::conditional_t<isConst, T const, T>;
using pointer = std::conditional_t<isConst, T const*, T*>;
using reference = std::conditional_t<isConst, T const&, T&>;
using size_type = std::size_t;
using iterator_category = std::forward_iterator_tag;

iterator_impl() = default;

template<bool IsConst_, class =
std::enable_if_t<! IsConst_>>
iterator_impl(
iterator_impl<IsConst_> other) noexcept
: it_(other.it_)
, prev_(other.prev_)
{
}

iterator_impl& operator++() noexcept
{
prev_ = it_;
@@ -542,6 +552,39 @@ clear() noexcept
size_ = 0;
}

template<class T>
auto
AnyList<T>::
erase(
iterator it) noexcept ->
iterator
{
iterator result;
if(it.it_ == head_)
{
head_ = head_->next;
if( head_ == &end_)
{
tail_ = &end_;
result = iterator( &end_, nullptr );
}
else
{
result = iterator( head_, nullptr );
}
}
else
{
result = iterator( it.it_->next, it.prev_ );
it.prev_->next = it.it_->next;
if( it.it_->next == &end_)
tail_ = it.prev_;
}
delete it.it_;
--size_;
return result;
}

template<class T>
AnyListNodes
AnyList<T>::
9 changes: 9 additions & 0 deletions include/mrdox/Metadata/Javadoc.hpp
Original file line number Diff line number Diff line change
@@ -326,6 +326,14 @@ struct MRDOX_VISIBLE
return blocks_;
}

/** Return the element describing the return type.
*/
Returns const*
getReturns() const noexcept
{
return returns_.get();
}

/** Return the list of top level blocks.
*/
AnyList<Param> const&
@@ -439,6 +447,7 @@ struct MRDOX_VISIBLE

private:
std::shared_ptr<Paragraph const> brief_;
std::shared_ptr<Returns const> returns_;
AnyList<Block> blocks_;
AnyList<Param> params_;
AnyList<TParam> tparams_;
9 changes: 9 additions & 0 deletions source/api/Metadata/Javadoc.cpp
Original file line number Diff line number Diff line change
@@ -86,6 +86,15 @@ postProcess()
brief = static_cast<Paragraph*>(&*it);
goto done;
}
else if(it->kind == Kind::returns)
{
if(! returns_)
{
returns_ = std::make_shared<Returns>(
std::move(static_cast<Returns &>(*it)));
it = blocks_.erase(it);
}
}
else if(it->kind == Kind::param)
{
it = blocks_.move_to(it, params_);
2 changes: 2 additions & 0 deletions source/api/_XML/XMLWriter.cpp
Original file line number Diff line number Diff line change
@@ -448,6 +448,8 @@ writeJavadoc(
if(auto brief = javadoc->getBrief())
writeBrief(*brief);
writeNodes(javadoc->getBlocks());
if(auto returns = javadoc->getReturns())
writeNode(*returns);
writeNodes(javadoc->getParams());
writeNodes(javadoc->getTParams());
tags_.close(javadocTagName);

0 comments on commit 81d2d91

Please sign in to comment.