Correctly handle end comment for doc generation

This commit is contained in:
gingerBill
2023-03-21 15:22:11 +00:00
parent 05434daa69
commit b3e712e0b8
2 changed files with 19 additions and 6 deletions
+7 -5
View File
@@ -915,18 +915,20 @@ gb_internal void odin_doc_update_entities(OdinDocWriter *w) {
auto entities = array_make<Entity *>(heap_allocator(), 0, w->entity_cache.count); auto entities = array_make<Entity *>(heap_allocator(), 0, w->entity_cache.count);
defer (array_free(&entities)); defer (array_free(&entities));
for (auto const &entry : w->entity_cache) { ffor (u32 i = 0; i < w->entity_cache.count; i++) {
array_add(&entities, entry.key); Entity *e = w->entity_cache.entries[i].key;
array_add(&entities, e);
} }
for (Entity *e : entities) { for (Entity *e : entities) {
GB_ASSERT(e != nullptr);
OdinDocTypeIndex type_index = odin_doc_type(w, e->type); OdinDocTypeIndex type_index = odin_doc_type(w, e->type);
gb_unused(type_index); gb_unused(type_index);
} }
} }
for (auto const &entry : w->entity_cache) { for (u32 i = 0; i < w->entity_cache.count; i++) {
Entity *e = entry.key; Entity *e = w->entity_cache.entries[i].key;
OdinDocEntityIndex entity_index = entry.value; OdinDocEntityIndex entity_index = w->entity_cache.entries[i].value;
OdinDocTypeIndex type_index = odin_doc_type(w, e->type); OdinDocTypeIndex type_index = odin_doc_type(w, e->type);
OdinDocEntityIndex foreign_library = 0; OdinDocEntityIndex foreign_library = 0;
+12 -1
View File
@@ -3191,6 +3191,15 @@ gb_internal Ast *parse_foreign_block(AstFile *f, Token token) {
return decl; return decl;
} }
gb_internal void print_comment_group(CommentGroup *group) {
if (group) {
for (Token const &token : group->list) {
gb_printf_err("%.*s\n", LIT(token.string));
}
gb_printf_err("\n");
}
}
gb_internal Ast *parse_value_decl(AstFile *f, Array<Ast *> names, CommentGroup *docs) { gb_internal Ast *parse_value_decl(AstFile *f, Array<Ast *> names, CommentGroup *docs) {
bool is_mutable = true; bool is_mutable = true;
@@ -3232,6 +3241,8 @@ gb_internal Ast *parse_value_decl(AstFile *f, Array<Ast *> names, CommentGroup *
values.allocator = heap_allocator(); values.allocator = heap_allocator();
} }
CommentGroup *end_comment = f->lead_comment;
if (f->expr_level >= 0) { if (f->expr_level >= 0) {
if (f->curr_token.kind == Token_CloseBrace && if (f->curr_token.kind == Token_CloseBrace &&
f->curr_token.pos.line == f->prev_token.pos.line) { f->curr_token.pos.line == f->prev_token.pos.line) {
@@ -3252,7 +3263,7 @@ gb_internal Ast *parse_value_decl(AstFile *f, Array<Ast *> names, CommentGroup *
} }
} }
return ast_value_decl(f, names, type, values, is_mutable, docs, f->line_comment); return ast_value_decl(f, names, type, values, is_mutable, docs, end_comment);
} }
gb_internal Ast *parse_simple_stmt(AstFile *f, u32 flags) { gb_internal Ast *parse_simple_stmt(AstFile *f, u32 flags) {