mirror of
https://codeberg.org/ProgramSnail/lang.git
synced 2025-12-25 08:18:45 +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
36
src/doc_builders.cpp
Normal file
36
src/doc_builders.cpp
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
#include "../include/doc_builders.hpp"
|
||||
#include "basic_builders.hpp"
|
||||
|
||||
namespace builders {
|
||||
|
||||
// TODO: check, that all annotations are exist in function definition
|
||||
nodes::SymbolDocs buildSymbolDocs(
|
||||
parser::ParseTree::Node description_parser_node,
|
||||
const std::vector<parser::ParseTree::Node> &annotation_parser_nodes) {
|
||||
std::string description = description_parser_node.get_value();
|
||||
|
||||
// remove newline delimeters (": " at each new line
|
||||
size_t j = 0;
|
||||
for (size_t i = 0; i < description.size(); ++i, ++j) {
|
||||
if (j != i) {
|
||||
description[j] = description[i];
|
||||
}
|
||||
|
||||
if (description[i] == '\n') {
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
description.resize(j);
|
||||
|
||||
nodes::SymbolDocs docs(description);
|
||||
|
||||
for (auto &annotation_parser_node : annotation_parser_nodes) {
|
||||
docs.add_annotation_info(
|
||||
buildAnnotation(annotation_parser_node.nth_child(0)),
|
||||
annotation_parser_node.nth_child(1));
|
||||
}
|
||||
|
||||
return docs;
|
||||
}
|
||||
|
||||
} // namespace builders
|
||||
Loading…
Add table
Add a link
Reference in a new issue