25namespace welder::inline v0 {
45consteval std::string
cleandoc(std::string_view text) {
46 std::vector<std::string> lines{};
57 auto leading = [](
const std::string& s) {
58 std::string::size_type n{0};
59 while (n < s.size() && (s[n] ==
' ' || s[n] ==
'\t'))
63 auto blank = [](
const std::string& s) {
65 if (c !=
' ' && c !=
'\t' && c !=
'\r')
72 bool have_margin{
false};
73 std::string::size_type margin{0};
74 for (std::string::size_type i{1}; i < lines.size(); ++i)
75 if (!blank(lines[i])) {
76 const auto ind{leading(lines[i])};
77 if (!have_margin || ind < margin) {
84 lines[0].erase(0, leading(lines[0]));
86 for (std::string::size_type i{1}; i < lines.size(); ++i)
87 lines[i].erase(0, margin);
89 while (!lines.empty() && blank(lines.back()))
91 while (!lines.empty() && blank(lines.front()))
92 lines.erase(lines.begin());
95 for (std::string::size_type i{0}; i < lines.size(); ++i) {
117template <std::meta::info Ent, std::meta::info SpecTmpl>
119 template for (
constexpr auto a :
120 std::define_static_array(std::meta::annotations_of(Ent))) {
121 constexpr std::meta::info t{std::meta::type_of(a)};
122 if constexpr (std::meta::has_template_arguments(t) &&
123 std::meta::template_of(t) == SpecTmpl) {
124 using spec_type = [:t:];
125 constexpr auto spec{std::meta::extract<spec_type>(a)};
126 return std::define_static_string(
cleandoc(spec.text.data));
137template <std::meta::info Ent>
147template <std::meta::info Fn>
168template <std::meta::info Ent>
171 for (
auto a : std::meta::annotations_of(Ent)) {
172 auto t{std::meta::type_of(a)};
173 if (std::meta::has_template_arguments(t) &&
192template <std::meta::info Ent>
194 std::array<detail::tparam_doc, tparam_count<Ent>()> out{};
196 template for (
constexpr auto a :
197 std::define_static_array(std::meta::annotations_of(Ent))) {
198 constexpr std::meta::info t{std::meta::type_of(a)};
199 if constexpr (std::meta::has_template_arguments(t) &&
201 using spec_type = [:t:];
202 constexpr auto spec{std::meta::extract<spec_type>(a)};
204 std::define_static_string(spec.text.data)};
226template <std::meta::info Fn>
228 constexpr size_type n{std::meta::parameters_of(Fn).size()};
229 std::array<detail::param_doc, n> out{};
234 template for (
constexpr auto p :
235 std::define_static_array(std::meta::parameters_of(Fn))) {
236 const char* name{std::meta::has_identifier(p)
237 ? std::define_static_string(std::meta::identifier_of(p))
275template <std::meta::info Fn, doc_style Style>
279 std::span<const detail::param_doc>{pds},
The core interface concepts welder's static polymorphism rests on, gathered in one catalogue: the cus...
consteval auto param_docs()
The parameter docs of function Fn, in declaration order.
consteval const char * annotation_text_of()
The text of the annotation on Ent whose class template is SpecTmpl, or nullptr if it carries none.
consteval std::string cleandoc(std::string_view text)
Normalize a docstring the way Python's inspect.cleandoc (PEP 257) does, so a multiline doc/returns ca...
consteval auto tparam_docs()
The template-parameter docs declared on Ent via [[=welder::tparam("T","…")]], in annotation order.
consteval const char * return_doc_of()
The returns text on function Fn (documentation of its return value), or nullptr.
std::string function_docstring()
The complete docstring for function Fn under Style.
consteval const char * doc_of()
The doc text on Ent (a class, namespace, function, or parameter), or nullptr.
consteval size_type tparam_count()
How many tparam annotations Ent carries.
decltype(sizeof(0)) size_type
std::size_t named without a standard-library include, keeping this vocabulary header std-free (see th...
The raw documentation pieces of a function, handed to a style to assemble.
std::span< const param_doc > params
Per-parameter doc, declaration order.
const char * returns
The function's returns.
const char * summary
The function's own doc.
One function parameter's documentation: its identifier (nullptr if unnamed) and its doc text (nullptr...
const char * name
The parameter's identifier, or nullptr.
const char * text
Its doc text, or nullptr.
One documented template parameter of an entity: the parameter's name (as spelled in the tparam annota...
const char * name
The template parameter's name.
const char * text
Its documentation.
The stored form of a tparam annotation: one template parameter's doc.