From 7222a5a4284b8a7041e822fdff11ddc9e3627bca Mon Sep 17 00:00:00 2001 From: carsakiller Date: Wed, 9 Nov 2022 21:06:08 -0500 Subject: [PATCH 1/4] add: new annotations to completion --- script/core/completion/completion.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/script/core/completion/completion.lua b/script/core/completion/completion.lua index f87b55a6c..bd7c756fd 100644 --- a/script/core/completion/completion.lua +++ b/script/core/completion/completion.lua @@ -1683,6 +1683,9 @@ local function tryluaDocCate(word, results) 'operator', 'source', 'enum', + 'package', + 'private', + 'protected' } do if matchKey(word, docType) then results[#results+1] = { From 2a6af9cfd26c807a99293c97cb1268aaafc65244 Mon Sep 17 00:00:00 2001 From: carsakiller Date: Wed, 9 Nov 2022 21:10:57 -0500 Subject: [PATCH 2/4] add: en-us descriptions for access modifiers --- locale/en-us/script.lua | 78 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 76 insertions(+), 2 deletions(-) diff --git a/locale/en-us/script.lua b/locale/en-us/script.lua index 9fceac00b..0361ee77b 100644 --- a/locale/en-us/script.lua +++ b/locale/en-us/script.lua @@ -790,10 +790,11 @@ function getTags(item) end LUADOC_DESC_FIELD = [=[ Declare a field in a class/table. This allows you to provide more in-depth -documentation for a table. +documentation for a table. As of `v3.6.0`, you can mark a field as `private`, +`protected`, `public`, or `package`. ## Syntax -`---@field [description]` +`---@field [scope] [description]` ## Usage ``` @@ -1126,3 +1127,76 @@ local function setColor(color) end setColor(colors.green) ``` ]=] +LUADOC_DESC_PACKAGE = +[=[ +Mark a function as private to the file it is defined in. A packaged function +cannot be accessed from another file. + +## Syntax +`@package` + +## Usage +``` +---@class Animal +---@field private eyes integer +local Animal = {} + +---@package +---This cannot be accessed in another file +function Animal:eyesCount() + return self.eyes +end +``` +]=] +LUADOC_DESC_PRIVATE = +[=[ +Mark a function as private to a @class. Private functions can be accessed only +from within their class and are not accessable from child classes. + +## Syntax +`@private` + +## Usage +``` +---@class Animal +---@field private eyes integer +local Animal = {} + +---@private +function Animal:eyesCount() + return self.eyes +end + +---@class Dog:Animal +local myDog = {} + +---NOT PERMITTED! +myDog:eyesCount(); +``` +]=] +LUADOC_DESC_PROTECTED = +[=[ +Mark a function as protected within a @class. Protected functions can be +accessed only from within their class or from child classes. + +## Syntax +`@protected` + +## Usage +``` +---@class Animal +---@field private eyes integer +local Animal = {} + +---@protected +function Animal:eyesCount() + return self.eyes +end + +---@class Dog:Animal +local myDog = {} + +---Permitted because function is protected, not private. +myDog:eyesCount(); +``` +]=] From 4c6fae21ac5b92ef98e518184b3b9bf199b04a03 Mon Sep 17 00:00:00 2001 From: carsakiller Date: Wed, 9 Nov 2022 21:11:44 -0500 Subject: [PATCH 3/4] add: en-us descriptions for other locales --- locale/pt-br/script.lua | 73 +++++++++++++++++++++++++++++++++++++++++ locale/zh-cn/script.lua | 73 +++++++++++++++++++++++++++++++++++++++++ locale/zh-tw/script.lua | 73 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 219 insertions(+) diff --git a/locale/pt-br/script.lua b/locale/pt-br/script.lua index 2e0b0aa6b..b53463c38 100644 --- a/locale/pt-br/script.lua +++ b/locale/pt-br/script.lua @@ -1126,3 +1126,76 @@ local function setColor(color) end setColor(colors.green) ``` ]=] +LUADOC_DESC_PACKAGE = -- TODO: need translate! +[=[ +Mark a function as private to the file it is defined in. A packaged function +cannot be accessed from another file. + +## Syntax +`@package` + +## Usage +``` +---@class Animal +---@field private eyes integer +local Animal = {} + +---@package +---This cannot be accessed in another file +function Animal:eyesCount() + return self.eyes +end +``` +]=] +LUADOC_DESC_PRIVATE = -- TODO: need translate! +[=[ +Mark a function as private to a @class. Private functions can be accessed only +from within their class and are not accessable from child classes. + +## Syntax +`@private` + +## Usage +``` +---@class Animal +---@field private eyes integer +local Animal = {} + +---@private +function Animal:eyesCount() + return self.eyes +end + +---@class Dog:Animal +local myDog = {} + +---NOT PERMITTED! +myDog:eyesCount(); +``` +]=] +LUADOC_DESC_PROTECTED = -- TODO: need translate! +[=[ +Mark a function as protected within a @class. Protected functions can be +accessed only from within their class or from child classes. + +## Syntax +`@protected` + +## Usage +``` +---@class Animal +---@field private eyes integer +local Animal = {} + +---@protected +function Animal:eyesCount() + return self.eyes +end + +---@class Dog:Animal +local myDog = {} + +---Permitted because function is protected, not private. +myDog:eyesCount(); +``` +]=] diff --git a/locale/zh-cn/script.lua b/locale/zh-cn/script.lua index 5e451a513..409597deb 100644 --- a/locale/zh-cn/script.lua +++ b/locale/zh-cn/script.lua @@ -1126,3 +1126,76 @@ local function setColor(color) end setColor(colors.green) ``` ]=] +LUADOC_DESC_PACKAGE = -- TODO: need translate! +[=[ +Mark a function as private to the file it is defined in. A packaged function +cannot be accessed from another file. + +## Syntax +`@package` + +## Usage +``` +---@class Animal +---@field private eyes integer +local Animal = {} + +---@package +---This cannot be accessed in another file +function Animal:eyesCount() + return self.eyes +end +``` +]=] +LUADOC_DESC_PRIVATE = -- TODO: need translate! +[=[ +Mark a function as private to a @class. Private functions can be accessed only +from within their class and are not accessable from child classes. + +## Syntax +`@private` + +## Usage +``` +---@class Animal +---@field private eyes integer +local Animal = {} + +---@private +function Animal:eyesCount() + return self.eyes +end + +---@class Dog:Animal +local myDog = {} + +---NOT PERMITTED! +myDog:eyesCount(); +``` +]=] +LUADOC_DESC_PROTECTED = -- TODO: need translate! +[=[ +Mark a function as protected within a @class. Protected functions can be +accessed only from within their class or from child classes. + +## Syntax +`@protected` + +## Usage +``` +---@class Animal +---@field private eyes integer +local Animal = {} + +---@protected +function Animal:eyesCount() + return self.eyes +end + +---@class Dog:Animal +local myDog = {} + +---Permitted because function is protected, not private. +myDog:eyesCount(); +``` +]=] diff --git a/locale/zh-tw/script.lua b/locale/zh-tw/script.lua index a31c0d67c..84c23f8ad 100644 --- a/locale/zh-tw/script.lua +++ b/locale/zh-tw/script.lua @@ -1121,3 +1121,76 @@ local function setColor(color) end setColor(colors.green) ``` ]=] +LUADOC_DESC_PACKAGE = -- TODO: need translate! +[=[ +Mark a function as private to the file it is defined in. A packaged function +cannot be accessed from another file. + +## Syntax +`@package` + +## Usage +``` +---@class Animal +---@field private eyes integer +local Animal = {} + +---@package +---This cannot be accessed in another file +function Animal:eyesCount() + return self.eyes +end +``` +]=] +LUADOC_DESC_PRIVATE = -- TODO: need translate! +[=[ +Mark a function as private to a @class. Private functions can be accessed only +from within their class and are not accessable from child classes. + +## Syntax +`@private` + +## Usage +``` +---@class Animal +---@field private eyes integer +local Animal = {} + +---@private +function Animal:eyesCount() + return self.eyes +end + +---@class Dog:Animal +local myDog = {} + +---NOT PERMITTED! +myDog:eyesCount(); +``` +]=] +LUADOC_DESC_PROTECTED = -- TODO: need translate! +[=[ +Mark a function as protected within a @class. Protected functions can be +accessed only from within their class or from child classes. + +## Syntax +`@protected` + +## Usage +``` +---@class Animal +---@field private eyes integer +local Animal = {} + +---@protected +function Animal:eyesCount() + return self.eyes +end + +---@class Dog:Animal +local myDog = {} + +---Permitted because function is protected, not private. +myDog:eyesCount(); +``` +]=] From bce48e44fefc1461698bddccca5fe4780465a695 Mon Sep 17 00:00:00 2001 From: carsakiller Date: Wed, 9 Nov 2022 21:20:16 -0500 Subject: [PATCH 4/4] add: update @field description for pt-br and zh-cn --- locale/pt-br/script.lua | 3 ++- locale/zh-cn/script.lua | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/locale/pt-br/script.lua b/locale/pt-br/script.lua index b53463c38..0d0d09333 100644 --- a/locale/pt-br/script.lua +++ b/locale/pt-br/script.lua @@ -790,7 +790,8 @@ function getTags(item) end LUADOC_DESC_FIELD = -- TODO: need translate! [=[ Declare a field in a class/table. This allows you to provide more in-depth -documentation for a table. +documentation for a table. As of `v3.6.0`, you can mark a field as `private`, +`protected`, `public`, or `package`. ## Syntax `---@field [description]` diff --git a/locale/zh-cn/script.lua b/locale/zh-cn/script.lua index 409597deb..3c7a7fd28 100644 --- a/locale/zh-cn/script.lua +++ b/locale/zh-cn/script.lua @@ -790,7 +790,8 @@ function getTags(item) end LUADOC_DESC_FIELD = -- TODO: need translate! [=[ Declare a field in a class/table. This allows you to provide more in-depth -documentation for a table. +documentation for a table. As of `v3.6.0`, you can mark a field as `private`, +`protected`, `public`, or `package`. ## Syntax `---@field [description]`