diff options
| author | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-07-29 21:04:17 -0400 |
|---|---|---|
| committer | Brad Lewis <22850972+BradLewis@users.noreply.github.com> | 2025-07-29 21:04:17 -0400 |
| commit | 7ce24730de1677b2ab5de77ccf0a4fa6c3373fda (patch) | |
| tree | bd2d5979eee9da7ecadfe868c99fdbd7c4c696e3 /src/server/documentation.odin | |
| parent | 6c769f52ffd2cd40def26f758498ca4a8b2bce2b (diff) | |
Fix issue with constructing docs on indexed symbols
Diffstat (limited to 'src/server/documentation.odin')
| -rw-r--r-- | src/server/documentation.odin | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/server/documentation.odin b/src/server/documentation.odin index c57e078..e365e2e 100644 --- a/src/server/documentation.odin +++ b/src/server/documentation.odin @@ -105,6 +105,7 @@ keywords_docs: map[string]bool = { } // Adds signature and docs information to the provided symbol +// This should only be used for a symbol created with the temp allocator build_documentation :: proc(ast_context: ^AstContext, symbol: ^Symbol, short_signature := true) { if short_signature { symbol.signature = get_short_signature(ast_context, symbol) @@ -116,7 +117,7 @@ build_documentation :: proc(ast_context: ^AstContext, symbol: ^Symbol, short_sig return } - symbol.doc = construct_symbol_docs(symbol.doc, symbol.comment) + symbol.doc = construct_symbol_docs(symbol, allocator = ast_context.allocator) } // Adds signature and docs information for a bit field field @@ -124,20 +125,20 @@ build_bit_field_field_documentation :: proc( ast_context: ^AstContext, symbol: ^Symbol, value: SymbolBitFieldValue, index: int, allocator := context.temp_allocator ) { symbol.signature = get_bit_field_field_signature(value, index, allocator) - symbol.doc = construct_symbol_docs(symbol.doc, symbol.comment) + symbol.doc = construct_symbol_docs(symbol) } -construct_symbol_docs :: proc(docs, comment: string, allocator := context.temp_allocator) -> string { - sb := strings.builder_make(allocator = context.temp_allocator) - if docs != "" { - strings.write_string(&sb, docs) - if comment != "" { +construct_symbol_docs :: proc(symbol: ^Symbol, allocator := context.temp_allocator) -> string { + sb := strings.builder_make(allocator = allocator) + if symbol.doc != "" { + strings.write_string(&sb, symbol.doc) + if symbol.comment != "" { strings.write_string(&sb, "\n") } } - if comment != "" { - fmt.sbprintf(&sb, "\n```odin\n%s\n```", comment) + if symbol.comment != "" { + fmt.sbprintf(&sb, "\n```odin\n%s\n```", symbol.comment) } return strings.to_string(sb) |