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

Language-agnostic documentation layer: read [[=welder::doc(...)]] annotations off reflected entities and assemble them into a docstring under a pluggable style. More...

#include <array>
#include <concepts>
#include <meta>
#include <span>
#include <string>
#include <string_view>
#include <vector>
#include <welder/concepts.hpp>
Include dependency graph for doc.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  welder::detail::tparam_doc
 One documented template parameter of an entity: the parameter's name (as spelled in the tparam annotation) and its doc text. More...
struct  welder::detail::param_doc
 One function parameter's documentation: its identifier (nullptr if unnamed) and its doc text (nullptr if undocumented). More...
struct  welder::detail::function_doc
 The raw documentation pieces of a function, handed to a style to assemble. More...

Namespaces

namespace  welder
namespace  welder::detail
 The stored forms of the annotation vocabulary.

Functions

consteval std::string welder::cleandoc (std::string_view text)
 Normalize a docstring the way Python's inspect.cleandoc (PEP 257) does, so a multiline doc/returns can be indented to line up with the surrounding C++ source without that indentation reaching the target language's docstring.
template<std::meta::info Ent, std::meta::info SpecTmpl>
consteval const char * welder::annotation_text_of ()
 The text of the annotation on Ent whose class template is SpecTmpl, or nullptr if it carries none.
template<std::meta::info Ent>
consteval const char * welder::doc_of ()
 The doc text on Ent (a class, namespace, function, or parameter), or nullptr.
template<std::meta::info Fn>
consteval const char * welder::return_doc_of ()
 The returns text on function Fn (documentation of its return value), or nullptr.
template<std::meta::info Ent>
consteval size_type welder::tparam_count ()
 How many tparam annotations Ent carries.
template<std::meta::info Ent>
consteval auto welder::tparam_docs ()
 The template-parameter docs declared on Ent via [[=welder::tparam("T","…")]], in annotation order.
template<std::meta::info Fn>
consteval auto welder::param_docs ()
 The parameter docs of function Fn, in declaration order.
template<std::meta::info Fn, doc_style Style>
std::string welder::function_docstring ()
 The complete docstring for function Fn under Style.

Detailed Description

Language-agnostic documentation layer: read [[=welder::doc(...)]] annotations off reflected entities and assemble them into a docstring under a pluggable style.

Backends consume doc_of / function_docstring and never re-derive the annotation semantics — a new backend reuses this, picking whichever style fits its target language.

Note
Like <welder/reflect.hpp>, this depends on the welder vocabulary (welder::detail::doc_spec, detail::fixed_string) but deliberately does NOT include <welder/annotations.hpp>. Provide the vocabulary first — #include <welder/vocabulary.hpp> — then this header.

Definition in file doc.hpp.