aboutsummaryrefslogtreecommitdiff
path: root/src/server/documentation.odin
diff options
context:
space:
mode:
authorLouis Dutton <louis@dutton.digital>2026-01-05 11:31:27 +0000
committerLouis Dutton <louis@dutton.digital>2026-01-17 21:20:38 +0000
commit3494339e5b56ca90356dac095918d2bf02832baa (patch)
tree1c19de0a88f56b8dfc7e58aa38c1208aea12d16b /src/server/documentation.odin
parent93cd45fd5077ae70158102fe7c3a1ead62e262cc (diff)
Improve hoverdoc formatting
Diffstat (limited to 'src/server/documentation.odin')
-rw-r--r--src/server/documentation.odin16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/server/documentation.odin b/src/server/documentation.odin
index 2fe8842..25e4140 100644
--- a/src/server/documentation.odin
+++ b/src/server/documentation.odin
@@ -6,6 +6,10 @@ import "core:odin/ast"
import path "core:path/slashpath"
import "core:strings"
+DOC_SECTION_DELIMITER :: "\n---\n" // The string separating each section of documentation
+DOC_FMT_ODIN :: "```odin\n%v\n```" // The format for wrapping odin code in a markdown codeblock
+DOC_FMT_MARKDOWN :: DOC_FMT_ODIN + DOC_SECTION_DELIMITER + "%v" // The format for presenting documentation on hover
+
// 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) {
@@ -20,21 +24,17 @@ build_documentation :: proc(ast_context: ^AstContext, symbol: ^Symbol, short_sig
}
}
-construct_symbol_docs :: proc(symbol: Symbol, markdown := true, allocator := context.temp_allocator) -> string {
+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 symbol.comment != "" {
- if markdown {
- fmt.sbprintf(&sb, "\n```odin\n%s\n```", symbol.comment)
- } else {
- fmt.sbprintf(&sb, "\n%s", symbol.comment)
+ if symbol.doc != "" {
+ strings.write_string(&sb, DOC_SECTION_DELIMITER)
}
+ strings.write_string(&sb, symbol.comment)
}
return strings.to_string(sb)