Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,6 @@ endif()

set(CMAKE_FOLDER Dependencies)

# Boost.Describe + Boost.Mp11 (header-only, fetched via bootstrap.py recipes)
find_package(boost_mp11 REQUIRED)
find_package(boost_describe REQUIRED)

# LLVM + Clang
if (LLVM_ROOT)
# LLVM_ROOT is absolute
Expand Down Expand Up @@ -333,7 +329,6 @@ target_compile_definitions(
PRIVATE
-DMRDOCS_TOOL
)
target_link_libraries(mrdocs-core PRIVATE Boost::describe Boost::mp11)

# Dependencies
target_include_directories(mrdocs-core
Expand Down
4 changes: 0 additions & 4 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,3 @@ flags:
paths:
- util/bootstrap/
carryforward: true

ignore:
# Boost.Describe macro invocations produce false positives
- "src/lib/Support/Reflection/Reflection.hpp"
14 changes: 7 additions & 7 deletions docs/mrdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ implementation-defined:
- 'mrdocs::report::detail'
- 'mrdocs::dom::detail'
exclude-symbols:
# Symbols defined when using the Boost.Describe macros.
- 'mrdocs::**::boost_base_descriptor_fn'
- 'mrdocs::**::boost_public_member_descriptor_fn'
- 'mrdocs::**::boost_protected_member_descriptor_fn'
- 'mrdocs::**::boost_private_member_descriptor_fn'
- 'mrdocs::**::boost_enum_descriptor_fn'
- 'mrdocs::**::should_use_BOOST_DESCRIBE_NESTED_ENUM'
# Reflection facilities.
- 'mrdocs::describe'
- 'mrdocs::describe::**'
# Symbols injected by MRDOCS_DESCRIBE_STRUCT/ENUM.
- '**mrdocs_base_descriptor_fn'
- '**mrdocs_member_descriptor_fn'
- '**mrdocs_enum_descriptor_fn'
multipage: true
generator: adoc
cmake: '-D MRDOCS_DOCUMENTATION_BUILD=ON'
Expand Down
61 changes: 15 additions & 46 deletions include/mrdocs/Dom/LazyObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

#include <mrdocs/Platform.hpp>
#include <mrdocs/Dom.hpp>
#include <mrdocs/Support/Describe.hpp>
#include <mrdocs/Support/Error.hpp>
#include <concepts>
#include <string_view>
#include <functional>

Expand Down Expand Up @@ -92,17 +94,13 @@ namespace detail
void
defer(std::string_view name, F&& deferred)
{
if constexpr (std::same_as<DeferFn, void*>)
if constexpr (std::invocable<DeferFn, std::string_view, F&&>)
{
mapFn(name, deferred);
}
else if (!deferFn)
{
mapFn(name, deferred);
deferFn(name, std::forward<F>(deferred));
}
else
{
deferFn(name, deferred);
mapFn(name, deferred);
}
}
};
Expand All @@ -117,13 +115,6 @@ namespace detail
template <class MapFn>
LazyObjectIO(MapFn) -> LazyObjectIO<MapFn, void*, NoLazyObjectContext>;

// Type-erased LazyObjectIO type alias template.
template <class Context>
using TypeErasedLazyObjectIO = LazyObjectIO<
std::function<void(std::string_view, dom::Value const&)>,
std::function<void(std::string_view, std::function<dom::Value()>)>,
Context>;

} // namespace detail

/** Customization point tag.
Expand Down Expand Up @@ -254,12 +245,6 @@ class LazyObjectImpl : public ObjectImpl
Object overlay_;
MRDOCS_NO_UNIQUE_ADDRESS Context context_{};

// Type alias for the type-erased IO used by this class.
using IOType = detail::TypeErasedLazyObjectIO<Context>;

using MapFnType = std::function<void(std::string_view, dom::Value const&)>;
using DeferFnType = std::function<void(std::string_view, std::function<dom::Value()> const&)>;

public:
/** Wrap an object using the default lazy mapping.
@param obj Object providing the data.
Expand Down Expand Up @@ -319,12 +304,12 @@ LazyObjectImpl<T, Context>::
size() const
{
std::size_t result = 0;
MapFnType mapFn =
auto mapFn =
[&result, this](std::string_view name, auto const& /* value or deferred */)
{
result += !overlay_.exists(name);
};
IOType io(mapFn, nullptr, context_);
detail::LazyObjectIO io(mapFn, nullptr, context_);
if constexpr (HasLazyObjectMapWithContext<T, Context>)
{
tag_invoke(LazyObjectMapTag{}, io, *underlying_, context_);
Expand All @@ -347,15 +332,15 @@ exists(std::string_view key) const
return true;
}
bool result = false;
MapFnType mapFn =
auto mapFn =
[&result, key](std::string_view name, auto const& /* value or deferred */)
{
if (!result && name == key)
{
result = true;
}
};
IOType io(mapFn, nullptr, context_);
detail::LazyObjectIO io(mapFn, nullptr, context_);
if constexpr (HasLazyObjectMapWithContext<T, Context>)
{
tag_invoke(LazyObjectMapTag{}, io, *underlying_, context_);
Expand All @@ -379,7 +364,7 @@ get(std::string_view key) const
return overlay_.get(key);
}
Value result;
IOType io(
detail::LazyObjectIO io(
[&result, key, this](std::string_view name, auto const& value)
{
if (result.isUndefined() && name == key)
Expand Down Expand Up @@ -435,22 +420,23 @@ LazyObjectImpl<T, Context>::
visit(std::function<bool(String, Value)> fn) const
{
bool visitMore = true;
MapFnType mapFn =
auto mapFn =
[&visitMore, &fn, this](std::string_view name, dom::Value const& value)
{
if (visitMore && !overlay_.exists(name))
{
visitMore = fn(String(name), value);
}
};
DeferFnType deferFn = [&visitMore, &fn, this](std::string_view name,
std::function<dom::Value()> const& deferred) {
auto deferFn =
[&visitMore, &fn, this](std::string_view name, auto const& deferred)
{
if (visitMore && !overlay_.exists(name))
{
visitMore = fn(String(name), deferred());
}
};
IOType io(mapFn, deferFn, context_);
detail::LazyObjectIO io(mapFn, deferFn, context_);
if constexpr (HasLazyObjectMapWithContext<T, Context>)
{
tag_invoke(LazyObjectMapTag{}, io, *underlying_, context_);
Expand Down Expand Up @@ -490,23 +476,6 @@ LazyObject(T const& arr, Context const& context)
}

} // dom

class DomCorpus;

/** Type-erased IO type for lazy object mapping.

This alias provides a concrete, non-template IO type
that can be used with `tag_invoke()` overloads for
@ref dom::LazyObjectMapTag. Unlike the internal template-based
IO types used within @ref dom::LazyObjectImpl, this type uses
`std::function` for type erasure, allowing it to be used in
explicit template instantiations.

@see dom::LazyObjectImpl
@see dom::LazyObjectMapTag
*/
using LazyObjectIOType = dom::detail::TypeErasedLazyObjectIO<DomCorpus const*>;

} // mrdocs

#endif // MRDOCS_API_DOM_LAZYOBJECT_HPP
33 changes: 16 additions & 17 deletions include/mrdocs/Metadata/DocComment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <mrdocs/Platform.hpp>
#include <mrdocs/ADT/Polymorphic.hpp>
#include <mrdocs/Metadata/DocComment/Block.hpp>
#include <mrdocs/Support/Describe.hpp>
#include <mrdocs/Support/MapReflectedType.hpp>

namespace mrdocs {

Expand Down Expand Up @@ -170,6 +172,14 @@ struct MRDOCS_DECL DocComment {
append(DocComment&& other);
};

MRDOCS_DESCRIBE_STRUCT(
DocComment,
(),
(Document, brief, returns, params, tparams,
exceptions, sees, preconditions, postconditions,
relates, related)
)

/** Append blocks from `other` into `I`, preserving order.
*/
inline
Expand All @@ -190,31 +200,20 @@ void merge(DocComment& I, DocComment&& other)
}
}

/** Map the @ref DocComment to a @ref dom::Object.

@param io The output object.
@param I The DocComment to map.
@param domCorpus The DOM corpus, or nullptr.
*/
template <class IO>
void
tag_invoke(
dom::LazyObjectMapTag,
IO& io,
DocComment const& I,
DomCorpus const* domCorpus);

/** Return the @ref DocComment as a @ref dom::Value object.
/** Return an optional @ref DocComment as a @ref dom::Value object.
*/
inline
void
tag_invoke(
dom::ValueFromTag,
dom::Value& v,
DocComment const& I,
Optional<DocComment> const& opt,
DomCorpus const* domCorpus)
{
v = dom::LazyObject(I, domCorpus);
if (opt)
{
v = dom::LazyObject(*opt, domCorpus);
}
}

/** Concept to check if a type represents a DocComment node.
Expand Down
38 changes: 6 additions & 32 deletions include/mrdocs/Metadata/DocComment/Block/AdmonitionBlock.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <mrdocs/Metadata/DocComment/Block/AdmonitionKind.hpp>
#include <mrdocs/Metadata/DocComment/Block/BlockBase.hpp>
#include <mrdocs/Metadata/DocComment/Block/ParagraphBlock.hpp>
#include <mrdocs/Support/Describe.hpp>
#include <string>

namespace mrdocs::doc {
Expand Down Expand Up @@ -64,38 +65,11 @@ struct AdmonitionBlock final
bool operator==(AdmonitionBlock const&) const noexcept = default;
};

/** Map the @ref AdmonitionBlock to a @ref dom::Object.

@param t The tag.
@param io The output object.
@param I The input object.
@param domCorpus The DOM corpus, or nullptr if not part of a corpus.
*/
template <class IO>
void
tag_invoke(
dom::LazyObjectMapTag t,
IO& io,
AdmonitionBlock const& I,
DomCorpus const* domCorpus)
{
tag_invoke(t, io, dynamic_cast<Block const&>(I), domCorpus);
tag_invoke(t, io, dynamic_cast<BlockContainer const&>(I), domCorpus);
io.map("admonish", I.admonish);
}

/** Return the @ref AdmonitionBlock as a @ref dom::Value object.
*/
inline
void
tag_invoke(
dom::ValueFromTag,
dom::Value& v,
AdmonitionBlock const& I,
DomCorpus const* domCorpus)
{
v = dom::LazyObject(I, domCorpus);
}
MRDOCS_DESCRIBE_STRUCT(
AdmonitionBlock,
(BlockCommonBase<BlockKind::Admonition>, BlockContainer),
(admonish)
)

} // mrdocs::doc

Expand Down
17 changes: 5 additions & 12 deletions include/mrdocs/Metadata/DocComment/Block/AdmonitionKind.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <mrdocs/Platform.hpp>
#include <mrdocs/Dom.hpp>
#include <mrdocs/Support/Describe.hpp>

namespace mrdocs::doc {

Expand All @@ -37,24 +38,16 @@ enum class AdmonitionKind
warning
};

MRDOCS_DESCRIBE_ENUM(
AdmonitionKind,
none, note, tip, important, caution, warning)

/** Return the name of the Admonish as a string.
*/
MRDOCS_DECL
dom::String
toString(AdmonitionKind kind) noexcept;

/** Return the Admonish from a @ref dom::Value string.
*/
inline
void
tag_invoke(
dom::ValueFromTag,
dom::Value& v,
AdmonitionKind const kind)
{
v = toString(kind);
}

} // mrdocs::doc

#endif // MRDOCS_API_METADATA_DOCCOMMENT_BLOCK_ADMONITIONKIND_HPP
Loading
Loading