Skip to content

Commit efe82f7

Browse files
authored
docs: add EvaluationDetail table documentation (#93)
It's quite awkward to document ad-hoc tables in Lua created via the C API. Prior to this PR, the `EvaluationDetail` table returned from `*variationDetail` methods didn't have any explanation. This PR adds documentation of the various fields. Since there's no actual table to document (it's created via C API), the docs are just sort of floating in the file as a comment.
1 parent d5c3ed2 commit efe82f7

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

launchdarkly-server-sdk-redis.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***
2-
Server-side SDK for LaunchDarkly Redis store.
2+
Redis Data Source for LaunchDarkly Lua Server SDK.
33
@module launchdarkly-server-sdk-redis
44
*/
55

launchdarkly-server-sdk.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1416,6 +1416,19 @@ LuaLDContextPrivateAttributes(lua_State *const l)
14161416
return 1;
14171417
}
14181418

1419+
/**
1420+
EvaluationDetail contains extra information related to evaluation of a flag.
1421+
1422+
@field kind string, one of: "OFF","FALLTHROUGH", "TARGET_MATCH", "RULE_MATCH",
1423+
"PREREQUISITE_FAILED", "ERROR", "UNKNOWN".
1424+
@field errorKind string, only present if 'kind' is "ERROR"; one of: "CLIENT_NOT_READY",
1425+
"FLAG_NOT_FOUND", "USER_NOT_SPECIFIED", "MALFORMED_FLAG", "WRONG_TYPE",
1426+
"MALFORMED_FLAG", "EXCEPTION", "UNKNOWN".
1427+
@field inExperiment bool, whether the flag was part of an experiment.
1428+
@field variationIndex int, only present if the evaluation was successful. The zero-based index of the variation.
1429+
@field value LDJSON, the value of the flag.
1430+
@table EvaluationDetail
1431+
*/
14191432

14201433
/**
14211434
Evaluate a boolean flag
@@ -1459,7 +1472,7 @@ Evaluate a boolean flag and return an explanation
14591472
@tparam context context An opaque context object from @{makeUser} or @{makeContext}
14601473
@tparam string key The key of the flag to evaluate.
14611474
@tparam boolean fallback The value to return on error
1462-
@treturn table The evaluation explanation
1475+
@return @{EvaluationDetail}
14631476
*/
14641477
static int
14651478
LuaLDClientBoolVariationDetail(lua_State *const l)
@@ -1523,7 +1536,7 @@ Evaluate an integer flag and return an explanation
15231536
@tparam context context An opaque context object from @{makeUser} or @{makeContext}
15241537
@tparam string key The key of the flag to evaluate.
15251538
@tparam int fallback The value to return on error
1526-
@treturn table The evaluation explanation
1539+
@return @{EvaluationDetail}
15271540
*/
15281541
static int
15291542
LuaLDClientIntVariationDetail(lua_State *const l)
@@ -1587,7 +1600,7 @@ Evaluate a double flag and return an explanation
15871600
@tparam context context An opaque context object from @{makeUser} or @{makeContext}
15881601
@tparam string key The key of the flag to evaluate.
15891602
@tparam number fallback The value to return on error
1590-
@treturn table The evaluation explanation
1603+
@return @{EvaluationDetail}
15911604
*/
15921605
static int
15931606
LuaLDClientDoubleVariationDetail(lua_State *const l)
@@ -1654,7 +1667,7 @@ Evaluate a string flag and return an explanation
16541667
@tparam context context An opaque context object from @{makeUser} or @{makeContext}
16551668
@tparam string key The key of the flag to evaluate.
16561669
@tparam string fallback The value to return on error
1657-
@treturn table The evaluation explanation
1670+
@return @{EvaluationDetail}
16581671
*/
16591672
static int
16601673
LuaLDClientStringVariationDetail(lua_State *const l)
@@ -1724,7 +1737,7 @@ Evaluate a json flag and return an explanation
17241737
@tparam context context An opaque context object from @{makeUser} or @{makeContext}
17251738
@tparam string key The key of the flag to evaluate.
17261739
@tparam table fallback The value to return on error
1727-
@treturn table The evaluation explanation
1740+
@return @{EvaluationDetail}
17281741
*/
17291742
static int
17301743
LuaLDClientJSONVariationDetail(lua_State *const l)

scripts/build-docs.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ mkdir "$DOCS_BUILD_DIR"
1818
cp launchdarkly-server-sdk.c "$DOCS_BUILD_DIR"
1919
cp launchdarkly-server-sdk-redis.c "$DOCS_BUILD_DIR"
2020

21-
ldoc -d "$DOCS_RELEASE_DIR" "$DOCS_BUILD_DIR"
21+
ldoc -d "$DOCS_RELEASE_DIR" "$DOCS_BUILD_DIR" -p "LaunchDarkly Lua Server SDK"

0 commit comments

Comments
 (0)