Improve documentation and examples.

This commit is contained in:
ArthurSonzogni
2021-08-13 00:30:05 +02:00
parent 5c1c60886b
commit 38a1c62037
2 changed files with 20 additions and 6 deletions

View File

@@ -44,6 +44,6 @@ int main(int argc, const char* argv[]) {
return 0;
}
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Copyright 2021 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.

View File

@@ -124,18 +124,32 @@ class GridBox : public Node {
std::vector<Elements> lines_;
};
/// @brief A container displaying elements horizontally one by one.
/// @param children The elements in the container
/// @brief A container displaying a grid of elements.
/// @param lines A list of lines, each line being a list of elements.
/// @return The container.
///
/// #### Example
///
/// ```cpp
/// hbox({
/// text("Left"),
/// text("Right"),
/// auto cell = [](const char* t) { return text(t) | border; };
/// auto document = gridbox({
/// {cell("north-west") , cell("north") , cell("north-east")} ,
/// {cell("west") , cell("center") , cell("east")} ,
/// {cell("south-west") , cell("south") , cell("south-east")} ,
/// });
/// ```
/// Output:
/// ```
///╭──────────╮╭──────╮╭──────────╮
///│north-west││north ││north-east│
///╰──────────╯╰──────╯╰──────────╯
///╭──────────╮╭──────╮╭──────────╮
///│west ││center││east │
///╰──────────╯╰──────╯╰──────────╯
///╭──────────╮╭──────╮╭──────────╮
///│south-west││south ││south-east│
///╰──────────╯╰──────╯╰──────────╯
/// ```
Element gridbox(std::vector<Elements> lines) {
return std::make_shared<GridBox>(std::move(lines));
}