mirror of
https://codeberg.org/ProgramSnail/lang.git
synced 2025-12-07 15:38:49 +00:00
doc builders (no annotation check support)
This commit is contained in:
parent
696a9c3a1a
commit
6682e0beb1
5 changed files with 76 additions and 20 deletions
|
|
@ -1,52 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace nodes {
|
||||
|
||||
class SymbolDocs {
|
||||
public:
|
||||
SymbolDocs(std::string &&description)
|
||||
: description_(std::move(description)) {}
|
||||
|
||||
SymbolDocs(const std::string &description) : description_(description) {}
|
||||
|
||||
template <typename T>
|
||||
bool add_annotation_info(const std::string &annotation, T &&info) {
|
||||
if (annotations_info_.count(annotation) == 0) {
|
||||
annotations_info_[annotation] = std::forward<T>(info);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string *get_description() { return &description_; }
|
||||
|
||||
const std::string *get_description() const { return &description_; }
|
||||
|
||||
std::optional<std::string *>
|
||||
get_annotation_info(const std::string &annotation) {
|
||||
auto info_iterator = annotations_info_.find(annotation);
|
||||
if (info_iterator != annotations_info_.end()) {
|
||||
return &info_iterator->second;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
std::optional<const std::string *>
|
||||
get_annotation_info(const std::string &annotation) const {
|
||||
auto info_iterator = annotations_info_.find(annotation);
|
||||
if (info_iterator != annotations_info_.end()) {
|
||||
return &info_iterator->second;
|
||||
}
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string description_;
|
||||
std::unordered_map<std::string, std::string> annotations_info_;
|
||||
};
|
||||
|
||||
} // namespace nodes
|
||||
Loading…
Add table
Add a link
Reference in a new issue