Skip to content

Commit

Permalink
vdoc: fix parsing of static functions (#19876)
Browse files Browse the repository at this point in the history
  • Loading branch information
Delta456 committed Nov 15, 2023
1 parent 83b4167 commit f2ef89a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 5 additions & 1 deletion vlib/v/doc/doc.v
Expand Up @@ -284,7 +284,11 @@ pub fn (mut d Doc) stmt(mut stmt ast.Stmt, filename string) !DocNode {
if stmt.receiver.typ !in [0, 1] {
method_parent := d.type_to_str(stmt.receiver.typ)
node.kind = .method
node.parent_name = method_parent
if !stmt.is_static_type_method {
node.parent_name = method_parent
} else {
node.parent_name = ''
}
}
if d.extract_vars {
for param in stmt.params {
Expand Down
9 changes: 8 additions & 1 deletion vlib/v/doc/utils.v
Expand Up @@ -131,9 +131,16 @@ pub fn (mut d Doc) stmt_signature(stmt ast.Stmt) string {
// stmt_name returns the name of a given `ast.Stmt` node.
pub fn (d Doc) stmt_name(stmt ast.Stmt) string {
match stmt {
ast.FnDecl, ast.StructDecl, ast.EnumDecl, ast.InterfaceDecl {
ast.StructDecl, ast.EnumDecl, ast.InterfaceDecl {
return stmt.name
}
ast.FnDecl {
if stmt.is_static_type_method {
return stmt.name.replace('__static__', '.')
} else {
return stmt.name
}
}
ast.TypeDecl {
match stmt {
ast.FnTypeDecl, ast.AliasTypeDecl, ast.SumTypeDecl { return stmt.name }
Expand Down

0 comments on commit f2ef89a

Please sign in to comment.