Skip to content

Commit 7a437bf

Browse files
Improve variable docs (#375)
* Improve variable docs * Shorten the variable example
1 parent dc4f449 commit 7a437bf

File tree

6 files changed

+26
-1
lines changed

6 files changed

+26
-1
lines changed

src/actions/variable.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,28 @@ import {ExpressionQualifier} from "../qualifiers/expression/ExpressionQualifier"
88
* Defines a new user variable with the given value.
99
* @memberOf Actions
1010
* @namespace Variable
11+
* @example
12+
* import {Cloudinary} from "@cloudinary/base/instance/Cloudinary";
13+
* import {
14+
* set,
15+
* setAssetReference,
16+
* setFromContext,
17+
* setFromMetadata
18+
* } from "@cloudinary/base/actions/variable";
19+
* import {scale} from "@cloudinary/base/actions/resize";
20+
*
21+
* const yourCldInstance = new Cloudinary({cloud:{cloudName:'demo'}});
22+
*
23+
* const image = yourCldInstance.image('woman');
24+
* image
25+
* .addVariable(set('foo1', 100))
26+
* .addVariable(setAssetReference('foo2', 'val'))
27+
* .addVariable(setFromContext('foo3', 'val'))
28+
* .addVariable(setFromMetadata('foo4', 'val'))
29+
* .resize(scale().width('$foo1').height('$foo2'))
1130
*/
1231

32+
1333
/**
1434
* @summary action
1535
* @description Sets a new user variable with the given value.

src/actions/variable/SetAction.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import {ExpressionQualifier} from "../../qualifiers/expression/ExpressionQualifi
55
/**
66
* @description Sets a user-defined variable.
77
* @memberOf Actions.Variable
8-
* @extends {Variable.VariableAction}
8+
* @extends Variable.VariableAction
9+
* @see Visit {@link Actions.Variable|Variable} for an example
910
*/
1011
class SetAction extends VariableAction {
1112
constructor(name: string, value: number | string | string[] | number[] | ExpressionQualifier) {

src/actions/variable/SetAssetReferenceAction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import VariableAction from "./VariableAction";
44
* @description Sets a user-defined variable from a file reference.
55
* @memberOf Actions.Variable
66
* @extends {Variable.VariableAction}
7+
* @see Visit {@link Actions.Variable|Variable} for an example
78
*/
89
class SetAssetReferenceAction extends VariableAction {
910
constructor(name: string, value: string) {

src/actions/variable/SetFromContextAction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import VariableAction from "./VariableAction";
44
* @description Sets a user-defined variable from contextual metadata.
55
* @memberOf Actions.Variable
66
* @extends {Variable.VariableAction}
7+
* @see Visit {@link Actions.Variable|Variable} for an example
78
*/
89
class SetFromContextAction extends VariableAction {
910
constructor(name: string, value: string) {

src/actions/variable/SetFromMetadataAction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import VariableAction from "./VariableAction";
44
* @description Sets a user-defined variable from structured metadata.
55
* @memberOf Actions.Variable
66
* @extends {Variable.VariableAction}
7+
* @see Visit {@link Actions.Variable|Variable} for an example
78
*/
89
class SetFromMetadataAction extends VariableAction {
910
constructor(name: string, value: string) {

src/actions/variable/VariableAction.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ type TypeVariableValue = number | string | ExpressionQualifier;
99
* @description Defines an new user variable.
1010
* @memberOf Actions.Variable
1111
* @extends SDK.Action
12+
* @see Visit {@link Actions.Variable|Variable} for an example
1213
*/
1314
class VariableAction extends Action {
1415
private isFloat = false;

0 commit comments

Comments
 (0)