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

@ -130,16 +130,17 @@ pub:
pub struct FnDecl { pub struct FnDecl {
pub: pub:
name string name string
stmts []Stmt stmts []Stmt
typ table.Type typ table.Type
args []Arg args []Arg
is_pub bool is_deprecated bool
is_variadic bool is_pub bool
receiver Field is_variadic bool
is_method bool receiver Field
rec_mut bool // is receiver mutable is_method bool
is_c bool rec_mut bool // is receiver mutable
is_c bool
} }
pub struct BranchStmt { pub struct BranchStmt {

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

@ -24,7 +24,7 @@ pub fn (p mut Parser) call_expr(is_c bool, mod string) ast.CallExpr {
args: args args: args
muts: muts muts: muts
// tok: tok // tok: tok
pos: tok.position() pos: tok.position()
is_c: is_c is_c: is_c
or_block: ast.OrExpr{ or_block: ast.OrExpr{
@ -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
@ -221,10 +222,10 @@ pub fn (p mut Parser) top_stmt() ast.Stmt {
p.error('wrong pub keyword usage') p.error('wrong pub keyword usage')
return ast.Stmt{} return 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
} }