vdoc: don't show deprecated functions

pull/3935/head
Alexander Medvednikov 2020-03-05 16:13:14 +01:00 committed by GitHub
parent 6659f1751e
commit 9c1e50b1aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 16 deletions

View File

@ -134,6 +134,7 @@ pub:
stmts []Stmt stmts []Stmt
typ table.Type typ table.Type
args []Arg args []Arg
is_deprecated bool
is_pub bool is_pub bool
is_variadic bool is_variadic bool
receiver Field receiver Field

View File

@ -100,9 +100,9 @@ fn (d Doc) get_fn_signatures(filter_fn FilterFn) []string {
} }
fn is_pub_method(node ast.FnDecl) bool { fn is_pub_method(node ast.FnDecl) bool {
return node.is_pub && node.is_method return node.is_pub && node.is_method && !node.is_deprecated
} }
fn is_pub_function(node ast.FnDecl) bool { fn is_pub_function(node ast.FnDecl) bool {
return node.is_pub && !node.is_method return node.is_pub && !node.is_method && !node.is_deprecated
} }

View File

@ -58,6 +58,7 @@ pub fn (p mut Parser) call_args() ([]ast.Expr,[]bool) {
fn (p mut Parser) fn_decl() ast.FnDecl { fn (p mut Parser) fn_decl() ast.FnDecl {
// p.table.clear_vars() // p.table.clear_vars()
p.open_scope() p.open_scope()
is_deprecated := p.attr == 'deprecated'
is_pub := p.tok.kind == .key_pub is_pub := p.tok.kind == .key_pub
if is_pub { if is_pub {
p.next() p.next()
@ -158,11 +159,13 @@ fn (p mut Parser) fn_decl() ast.FnDecl {
stmts = p.parse_block() stmts = p.parse_block()
} }
p.close_scope() p.close_scope()
p.attr = ''
return ast.FnDecl{ return ast.FnDecl{
name: name name: name
stmts: stmts stmts: stmts
typ: typ typ: typ
args: ast_args args: ast_args
is_deprecated: is_deprecated
is_pub: is_pub is_pub: is_pub
is_variadic: is_variadic is_variadic: is_variadic
receiver: ast.Field{ receiver: ast.Field{

View File

@ -40,6 +40,7 @@ mut:
pref &pref.Preferences // Preferences shared from V struct pref &pref.Preferences // Preferences shared from V struct
builtin_mod bool builtin_mod bool
mod string mod string
attr string
expr_mod string expr_mod string
scope &ast.Scope scope &ast.Scope
imports map[string]string imports map[string]string
@ -224,7 +225,7 @@ pub fn (p mut Parser) top_stmt() ast.Stmt {
} }
} }
.lsbr { .lsbr {
return p.attr() return p.attribute()
} }
.key_module { .key_module {
return p.module_decl() return p.module_decl()
@ -373,13 +374,14 @@ pub fn (p mut Parser) assign_expr(left ast.Expr) ast.AssignExpr {
return node return node
} }
fn (p mut Parser) attr() ast.Attr { fn (p mut Parser) attribute() ast.Attr {
p.check(.lsbr) p.check(.lsbr)
if p.tok.kind == .key_if { if p.tok.kind == .key_if {
p.next() p.next()
} }
name := p.check_name() name := p.check_name()
p.check(.rsbr) p.check(.rsbr)
p.attr = name
return ast.Attr{ return ast.Attr{
name: name name: name
} }