luau/Analysis/include/Luau/Documentation.h

64 lines
1.7 KiB
C
Raw Normal View History

2022-09-09 05:44:50 +08:00
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
#pragma once
#include "Luau/DenseHash.h"
#include "Luau/Variant.h"
#include <string>
#include <vector>
namespace Luau
{
struct FunctionDocumentation;
struct TableDocumentation;
struct OverloadedFunctionDocumentation;
2021-11-19 06:21:07 +08:00
struct BasicDocumentation;
2021-11-19 06:21:07 +08:00
using Documentation = Luau::Variant<BasicDocumentation, FunctionDocumentation, TableDocumentation, OverloadedFunctionDocumentation>;
using DocumentationSymbol = std::string;
2021-11-19 06:21:07 +08:00
struct BasicDocumentation
{
std::string documentation;
std::string learnMoreLink;
2022-02-18 08:41:20 +08:00
std::string codeSample;
2021-11-19 06:21:07 +08:00
};
struct FunctionParameterDocumentation
{
std::string name;
DocumentationSymbol documentation;
};
// Represents documentation for anything callable. This could be a method or a
// callback or a free function.
struct FunctionDocumentation
{
std::string documentation;
std::vector<FunctionParameterDocumentation> parameters;
std::vector<DocumentationSymbol> returns;
2021-11-19 06:21:07 +08:00
std::string learnMoreLink;
2022-02-18 08:41:20 +08:00
std::string codeSample;
};
struct OverloadedFunctionDocumentation
{
// This is a map of function signature to overload symbol name.
Luau::DenseHashMap<std::string, DocumentationSymbol> overloads;
};
// Represents documentation for a table-like item, meaning "anything with keys".
// This could be a table or a class.
struct TableDocumentation
{
std::string documentation;
Luau::DenseHashMap<std::string, DocumentationSymbol> keys;
2021-11-19 06:21:07 +08:00
std::string learnMoreLink;
2022-02-18 08:41:20 +08:00
std::string codeSample;
};
using DocumentationDatabase = Luau::DenseHashMap<DocumentationSymbol, Documentation>;
} // namespace Luau