From 2a98e0c3566322e868e6de042524e57a042524aa Mon Sep 17 00:00:00 2001 From: Valentin Knabel Date: Thu, 17 Feb 2022 20:34:19 +0100 Subject: [PATCH] fix: `docs` of `docs.ExternFunctionDocs` has always been empty --- ast/decl-extern-func.go | 5 +++++ parser/parse-decl-extern.go | 1 + runtime/external-docs.go | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ast/decl-extern-func.go b/ast/decl-extern-func.go index 795034c..bb1871b 100644 --- a/ast/decl-extern-func.go +++ b/ast/decl-extern-func.go @@ -6,6 +6,7 @@ type DeclExternFunc struct { Name Identifier Parameters []DeclParameter + Docs *Docs MetaInfo *MetaDecl } @@ -28,3 +29,7 @@ func MakeDeclExternFunc(name Identifier, params []DeclParameter, source *Source) MetaInfo: &MetaDecl{source}, } } + +func (decl DeclExternFunc) ProvidedDocs() *Docs { + return decl.Docs +} diff --git a/parser/parse-decl-extern.go b/parser/parse-decl-extern.go index 0e64cff..a141fcc 100644 --- a/parser/parse-decl-extern.go +++ b/parser/parse-decl-extern.go @@ -15,6 +15,7 @@ func (fp *FileParser) ParseExternDeclaration() (*ast.Decl, []SyntaxError) { return nil, errs } funcDecl := ast.MakeDeclExternFunc(name, params, fp.AstSource()) + funcDecl.Docs = fp.ConsumeDocs() decl = *funcDecl return &decl, nil } diff --git a/runtime/external-docs.go b/runtime/external-docs.go index 41c363a..dcb9d01 100644 --- a/runtime/external-docs.go +++ b/runtime/external-docs.go @@ -197,7 +197,7 @@ func docsInspectValue(value RuntimeValue, env *Environment) (RuntimeValue, *Runt } return env.MakeDataRuntimeValue("ExternFunctionDocs", map[string]Evaluatable{ "name": NewConstantRuntimeValue(PreludeString(value.Decl.Name)), - "docs": NewConstantRuntimeValue(PreludeString("")), + "docs": NewConstantRuntimeValue(PreludeString(value.Decl.Docs.Content)), "params": NewConstantRuntimeValue(paramsList), }) case RxVariableType: