From 8cd75828658cfacb866dcb97217fb770140da0d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Mon, 4 Mar 2019 14:29:48 +0100 Subject: [PATCH 1/6] Use a central script instead of one per package --- bin/generate-docs.sh | 3 +++ 1 file changed, 3 insertions(+) create mode 100755 bin/generate-docs.sh diff --git a/bin/generate-docs.sh b/bin/generate-docs.sh new file mode 100755 index 00000000000000..c7ec1314d9b519 --- /dev/null +++ b/bin/generate-docs.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +npx docgen packages/e2e-test-utils/src/index.js --output packages/e2e-test-utils/README.md --to-token From 2ba80d1499cfa062f34ca71783d5ec72e441ea9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Mon, 4 Mar 2019 14:53:11 +0100 Subject: [PATCH 2/6] Prepare to add more packages --- bin/generate-docs.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/generate-docs.sh b/bin/generate-docs.sh index c7ec1314d9b519..afdebea2977d40 100755 --- a/bin/generate-docs.sh +++ b/bin/generate-docs.sh @@ -1,3 +1,10 @@ #!/bin/bash -npx docgen packages/e2e-test-utils/src/index.js --output packages/e2e-test-utils/README.md --to-token +declare -a packages=( + "e2e-test-utils" +) + +for package in "${packages[@]}" +do + npx docgen packages/${package}/src/index.js --output packages/${package}/README.md --to-token; +done From e4c8b46503345a2464a3d6f3557b6b9effeeb9bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Mon, 4 Mar 2019 19:06:08 +0100 Subject: [PATCH 3/6] Merge docs:build and docs:generate --- bin/generate-docs.sh | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100755 bin/generate-docs.sh diff --git a/bin/generate-docs.sh b/bin/generate-docs.sh deleted file mode 100755 index afdebea2977d40..00000000000000 --- a/bin/generate-docs.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/bash - -declare -a packages=( - "e2e-test-utils" -) - -for package in "${packages[@]}" -do - npx docgen packages/${package}/src/index.js --output packages/${package}/README.md --to-token; -done From 27aade558ed2176b71072dd0128f3e112f7b53e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Fri, 1 Mar 2019 20:33:31 +0100 Subject: [PATCH 4/6] Autogenerated docs and setup for redux-routine --- packages/redux-routine/README.md | 30 ++++++++++++++++++++++++----- packages/redux-routine/package.json | 6 ++++++ 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/packages/redux-routine/README.md b/packages/redux-routine/README.md index 5484b7ec35c576..b34651cffb4a1f 100644 --- a/packages/redux-routine/README.md +++ b/packages/redux-routine/README.md @@ -57,9 +57,29 @@ request has completed does the action creator procede to return the `SET_TEMPERA ## API -### `createMiddleware( controls: ?Object )` + -Create a Redux middleware, given an object of controls where each key is an action type for which to act upon, the value a function which returns either a promise which is to resolve when evaluation of the action should continue, or a value. The value or resolved promise value is assigned on the return value of the yield assignment. If the control handler returns undefined, the execution is not continued. +### default + +[src/index.js#L19-L30](src/index.js#L19-L30) + +Creates a Redux middleware, given an object of controls where each key is an +action type for which to act upon, the value a function which returns either +a promise which is to resolve when evaluation of the action should continue, +or a value. The value or resolved promise value is assigned on the return +value of the yield assignment. If the control handler returns undefined, the +execution is not continued. + +**Parameters** + +- **controls** `Object`: Object of control handlers. + +**Returns** + +`Function` Co-routine runtime + + + ## Motivation @@ -67,9 +87,9 @@ Create a Redux middleware, given an object of controls where each key is an acti The primary motivations include, among others: -- **Testability**: Since an action creator yields plain action objects, the behavior of their resolution can be easily substituted in tests. -- **Controlled flexibility**: Control flows can be implemented without sacrificing the expressiveness and intentionality of an action type. Other solutions like thunks or promises promote ultimate flexibility, but at the expense of maintainability manifested through deep coupling between action types and incidental implementation. -- A **common domain language** for expressing data flows: Since controls are centrally defined, it requires the conscious decision on the part of a development team to decide when and how new control handlers are added. +- **Testability**: Since an action creator yields plain action objects, the behavior of their resolution can be easily substituted in tests. +- **Controlled flexibility**: Control flows can be implemented without sacrificing the expressiveness and intentionality of an action type. Other solutions like thunks or promises promote ultimate flexibility, but at the expense of maintainability manifested through deep coupling between action types and incidental implementation. +- A **common domain language** for expressing data flows: Since controls are centrally defined, it requires the conscious decision on the part of a development team to decide when and how new control handlers are added. ## Testing diff --git a/packages/redux-routine/package.json b/packages/redux-routine/package.json index bbeb56eca1cb46..55ac35262e1228 100644 --- a/packages/redux-routine/package.json +++ b/packages/redux-routine/package.json @@ -27,7 +27,13 @@ "is-promise": "^2.1.0", "rungen": "^0.3.2" }, + "devDependencies": { + "@wordpress/docgen": "file:../docgen" + }, "publishConfig": { "access": "public" + }, + "scripts": { + "docs:generate": "docgen ./src/index.js --output ./README.md --to-token" } } From 3f448c49e87acf90c411f5de3ffc05119e974118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Tue, 5 Mar 2019 02:52:23 +0100 Subject: [PATCH 5/6] Use new script --- bin/update-readmes.js | 2 +- packages/redux-routine/package.json | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/bin/update-readmes.js b/bin/update-readmes.js index c3cbef224c0f45..b715fb018b6ef9 100755 --- a/bin/update-readmes.js +++ b/bin/update-readmes.js @@ -27,7 +27,7 @@ const packages = [ 'keycodes', //'plugins', 'priority-queue', - //'redux-routine', + 'redux-routine', 'rich-text', 'shortcode', //'url', diff --git a/packages/redux-routine/package.json b/packages/redux-routine/package.json index 55ac35262e1228..bbeb56eca1cb46 100644 --- a/packages/redux-routine/package.json +++ b/packages/redux-routine/package.json @@ -27,13 +27,7 @@ "is-promise": "^2.1.0", "rungen": "^0.3.2" }, - "devDependencies": { - "@wordpress/docgen": "file:../docgen" - }, "publishConfig": { "access": "public" - }, - "scripts": { - "docs:generate": "docgen ./src/index.js --output ./README.md --to-token" } } From 7217357758aa625107354b4e8b512596c313b0f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Tue, 5 Mar 2019 12:20:55 +0100 Subject: [PATCH 6/6] Update output --- packages/redux-routine/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/redux-routine/README.md b/packages/redux-routine/README.md index b34651cffb4a1f..46c9b299b31040 100644 --- a/packages/redux-routine/README.md +++ b/packages/redux-routine/README.md @@ -76,7 +76,7 @@ execution is not continued. **Returns** -`Function` Co-routine runtime +`Function`: Co-routine runtime