mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-19 04:50:29 +00:00
Update doc format to allow for aliases
This commit is contained in:
@@ -819,6 +819,7 @@ OdinDocEntityIndex odin_doc_add_entity(OdinDocWriter *w, Entity *e) {
|
||||
if (!docs) { docs = e->Constant.docs; }
|
||||
}
|
||||
|
||||
String name = e->token.string;
|
||||
String link_name = {};
|
||||
|
||||
OdinDocEntityKind kind = OdinDocEntity_Invalid;
|
||||
@@ -834,6 +835,7 @@ OdinDocEntityIndex odin_doc_add_entity(OdinDocWriter *w, Entity *e) {
|
||||
case Entity_ProcGroup: kind = OdinDocEntity_ProcGroup; break;
|
||||
case Entity_ImportName: kind = OdinDocEntity_ImportName; break;
|
||||
case Entity_LibraryName: kind = OdinDocEntity_LibraryName; break;
|
||||
case Entity_Builtin: kind = OdinDocEntity_Builtin; break;
|
||||
}
|
||||
|
||||
switch (e->kind) {
|
||||
@@ -899,7 +901,7 @@ OdinDocEntityIndex odin_doc_add_entity(OdinDocWriter *w, Entity *e) {
|
||||
doc_entity.kind = kind;
|
||||
doc_entity.flags = flags;
|
||||
doc_entity.pos = odin_doc_token_pos_cast(w, e->token.pos);
|
||||
doc_entity.name = odin_doc_write_string(w, e->token.string);
|
||||
doc_entity.name = odin_doc_write_string(w, name);
|
||||
doc_entity.type = 0; // Set later
|
||||
doc_entity.init_string = init_string;
|
||||
doc_entity.comment = odin_doc_comment_group_string(w, comment);
|
||||
@@ -976,7 +978,7 @@ void odin_doc_update_entities(OdinDocWriter *w) {
|
||||
|
||||
|
||||
|
||||
OdinDocArray<OdinDocEntityIndex> odin_doc_add_pkg_entities(OdinDocWriter *w, AstPackage *pkg) {
|
||||
OdinDocArray<OdinDocScopeEntry> odin_doc_add_pkg_entries(OdinDocWriter *w, AstPackage *pkg) {
|
||||
if (pkg->scope == nullptr) {
|
||||
return {};
|
||||
}
|
||||
@@ -984,14 +986,14 @@ OdinDocArray<OdinDocEntityIndex> odin_doc_add_pkg_entities(OdinDocWriter *w, Ast
|
||||
return {};
|
||||
}
|
||||
|
||||
auto entities = array_make<Entity *>(heap_allocator(), 0, pkg->scope->elements.entries.count);
|
||||
defer (array_free(&entities));
|
||||
auto entries = array_make<OdinDocScopeEntry>(heap_allocator(), 0, w->entity_cache.entries.count);
|
||||
defer (array_free(&entries));
|
||||
|
||||
for_array(i, pkg->scope->elements.entries) {
|
||||
String name = pkg->scope->elements.entries[i].key.string;
|
||||
Entity *e = pkg->scope->elements.entries[i].value;
|
||||
switch (e->kind) {
|
||||
case Entity_Invalid:
|
||||
case Entity_Builtin:
|
||||
case Entity_Nil:
|
||||
case Entity_Label:
|
||||
continue;
|
||||
@@ -1002,18 +1004,10 @@ OdinDocArray<OdinDocEntityIndex> odin_doc_add_pkg_entities(OdinDocWriter *w, Ast
|
||||
case Entity_ProcGroup:
|
||||
case Entity_ImportName:
|
||||
case Entity_LibraryName:
|
||||
case Entity_Builtin:
|
||||
// Fine
|
||||
break;
|
||||
}
|
||||
array_add(&entities, e);
|
||||
}
|
||||
gb_sort_array(entities.data, entities.count, cmp_entities_for_printing);
|
||||
|
||||
auto entity_indices = array_make<OdinDocEntityIndex>(heap_allocator(), 0, w->entity_cache.entries.count);
|
||||
defer (array_free(&entity_indices));
|
||||
|
||||
for_array(i, entities) {
|
||||
Entity *e = entities[i];
|
||||
if (e->pkg != pkg) {
|
||||
continue;
|
||||
}
|
||||
@@ -1024,12 +1018,13 @@ OdinDocArray<OdinDocEntityIndex> odin_doc_add_pkg_entities(OdinDocWriter *w, Ast
|
||||
continue;
|
||||
}
|
||||
|
||||
OdinDocEntityIndex doc_entity_index = 0;
|
||||
doc_entity_index = odin_doc_add_entity(w, e);
|
||||
array_add(&entity_indices, doc_entity_index);
|
||||
OdinDocScopeEntry entry = {};
|
||||
entry.name = odin_doc_write_string(w, name);
|
||||
entry.entity = odin_doc_add_entity(w, e);
|
||||
array_add(&entries, entry);
|
||||
}
|
||||
|
||||
return odin_write_slice(w, entity_indices.data, entity_indices.count);
|
||||
return odin_write_slice(w, entries.data, entries.count);
|
||||
}
|
||||
|
||||
|
||||
@@ -1097,7 +1092,7 @@ void odin_doc_write_docs(OdinDocWriter *w) {
|
||||
}
|
||||
|
||||
doc_pkg.files = odin_write_slice(w, file_indices.data, file_indices.count);
|
||||
doc_pkg.entities = odin_doc_add_pkg_entities(w, pkg);
|
||||
doc_pkg.entries = odin_doc_add_pkg_entries(w, pkg);
|
||||
|
||||
if (dst) {
|
||||
*dst = doc_pkg;
|
||||
|
||||
Reference in New Issue
Block a user