welder 0.1.0
Bindings for annotated C++ types, from C++26 reflection
Loading...
Searching...
No Matches
document.hpp File Reference

The LuaCATS document assembler: how a ---@meta stub is built up in memory. More...

#include <algorithm>
#include <array>
#include <cstddef>
#include <meta>
#include <string>
#include <string_view>
#include <type_traits>
#include <utility>
#include <vector>
#include <welder/rods/lua/luacats/type_map.hpp>
#include <welder/bind_traits.hpp>
#include <welder/doc.hpp>
Include dependency graph for document.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  welder::rods::luacats::func_overload
 One overload of a callee, pre-rendered into the pieces a group needs: the summary doc, the ---@param block, the ---@return line, the function argument list, and the fun(…) signature for a ---@overload line. More...
struct  welder::rods::luacats::table_decl
 A module/submodule table to declare (prefix = {}), with its optional doc. More...
struct  welder::rods::luacats::document
 The growing LuaCATS document shared by every writer handle. More...
struct  welder::rods::luacats::module_writer
 A module handle: the shared document plus this (sub)module's dotted table path. More...
struct  welder::rods::luacats::class_writer
 A class handle. More...
struct  welder::rods::luacats::enum_writer
 An enum handle: the value table text accumulated by add_enumerator, flushed as a ---@enum block by RAII (same rationale as class_writer). More...

Namespaces

namespace  welder
namespace  welder::rods
namespace  welder::rods::luacats

Functions

template<std::meta::info Fn>
consteval auto welder::rods::luacats::param_lua_types ()
 The LuaCATS type name of each parameter of Fn, as a splice-ready array parallel to param_docs<Fn>().
template<std::meta::info Fn>
std::string welder::rods::luacats::arg_list ()
 The comma-joined argument-name list for Fn's declaration line (an unnamed parameter becomes arg<N>).
template<std::meta::info Fn>
void welder::rods::luacats::emit_params (std::string &out)
 Emit the ---@param lines for Fn (name, LuaCATS type, and its doc).
template<std::meta::info Fn>
std::string welder::rods::luacats::fun_signature (const std::string &ret_override)
 The fun(<name>: <type>, …): <ret> signature of Fn, for a ---@overload line.
template<std::meta::info Fn>
func_overload welder::rods::luacats::build_overload (const std::string &ret_override)
 Build the func_overload for function/constructor Fn.
template<auto Grp, std::size_t... I>
void welder::rods::luacats::collect_overloads (std::vector< func_overload > &out, std::index_sequence< I... >)
 Append build_overload for each member of overload group Grp to out.
void welder::rods::luacats::render_overload_group (std::string &out, const std::string &callee, const std::vector< func_overload > &sigs)
 Emit one documented function <callee>(…) for overload group sigs, with a ---@overload fun(…) line per additional signature — the idiomatic LuaCATS shape (one symbol, several signatures), rather than repeated function defs.
std::string welder::rods::luacats::apply_type_renames (std::string_view text, const std::vector< std::pair< std::string, std::string > > &renames)
 Rewrite every whole dotted-name token of text that is a key in renames to its mapped value.

Detailed Description

The LuaCATS document assembler: how a ---@meta stub is built up in memory.

Two layers sit here, both above the type map (<welder/rods/lua/luacats/type_map.hpp>) and below the backend:

  • signature rendering — turning a reflected function/constructor into its ---@param/---@return lines and fun(…) signature, and grouping overloads into the idiomatic one-symbol/---@overload shape;
  • the writer/handle types (welder::rods::luacats::document and the per-entity *_writers) the backend's module_type/class-handle/enum-handle deduce to, which accumulate text and flush it (RAII, since the driver has no explicit "finish" hook).

Kept out of backend.hpp so those handle types and their shared rendering read as their own unit rather than as free functions surrounding the backend struct.

Requires the welder vocabulary first (#include <welder/vocabulary.hpp>), like the rest of the reflection layer.

Definition in file document.hpp.