aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/clickhouse/src/Common/FunctionDocumentation.cpp
blob: 2aad23b90b7a6dad144dd7b825430b5f9f113d60 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <Common/FunctionDocumentation.h>

namespace DB
{

std::string FunctionDocumentation::argumentsAsString() const
{
    std::string res;
    for (const auto & [name, desc] : arguments)
    {
        res += "- " + name + ":" + desc + "\n";
    }
    return res;
}

std::string FunctionDocumentation::examplesAsString() const
{
    std::string res;
    for (const auto & [name, query, result] : examples)
    {
        res += name + ":\n\n";
        res += "``` sql\n";
        res += query + "\n";
        res += "```\n\n";
        res += "``` text\n";
        res += result + "\n";
        res += "```\n";
    }
    return res;
}

std::string FunctionDocumentation::categoriesAsString() const
{
    if (categories.empty())
        return "";

    auto it = categories.begin();
    std::string res = *it;
    for (; it != categories.end(); ++it)
        res += ", " + *it;
    return res;
}

}