Skip to content
This repository was archived by the owner on Jul 29, 2024. It is now read-only.

Commit e676a60

Browse files
authored
chore(docgen): fix docgen for 5.1 (#4048)
Also added the ability to run `generate-docs.sh` against a custom branch/tag/commit by doing `./scripts/generate-docs.sh branch_name`. Still defaults to the version from package.json though. Also updated release.md to tell people to check that doc generation/the website is working BEFORE doing a release. Needing a change in the codebase is more likely now that we're compiling down to es5 only this one time, and ideally any changes to the codebase would happen before release. Also including a minor change in the codebase where we wrap a promise from blocking proxy in a webdriver promise. This probably should have been done the whole time, but is unlikely to matter either way at runtime, since blocking proxy wouldn't be returning a webdriver promise regardless. Mostly did I did this to fix typechecking.
1 parent 1468c50 commit e676a60

File tree

4 files changed

+40
-28
lines changed

4 files changed

+40
-28
lines changed

Diff for: lib/browser.ts

+11-14
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,14 @@ export interface AbstractExtendedWebDriver extends ExtendedWebDriver {}
5656
*/
5757
function ptorMixin(to: any, from: any, fnName: string, setupFn?: Function) {
5858
to[fnName] = function() {
59-
for (let i = 0; i < arguments.length; i++) {
60-
if (arguments[i] instanceof ElementFinder) {
61-
arguments[i] = arguments[i].getWebElement();
59+
const args = arguments;
60+
for (let i = 0; i < args.length; i++) {
61+
if (args[i] instanceof ElementFinder) {
62+
args[i] = args[i].getWebElement();
6263
}
6364
}
6465
const run = () => {
65-
return from[fnName].apply(from, arguments);
66+
return from[fnName].apply(from, args);
6667
};
6768
if (setupFn) {
6869
const setupResult = setupFn();
@@ -201,7 +202,9 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
201202
return wdpromise.when(value).then((value: string) => {
202203
this.internalRootEl = value;
203204
if (this.bpClient) {
204-
return this.bpClient.setWaitParams(value).then(() => this.internalRootEl);
205+
const bpCommandPromise = this.bpClient.setWaitParams(value);
206+
// Convert to webdriver promise as best as possible
207+
return wdpromise.when(bpCommandPromise as any).then(() => this.internalRootEl);
205208
}
206209
return this.internalRootEl;
207210
});
@@ -420,9 +423,9 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
420423
return wdpromise.when(enabled).then((enabled: boolean) => {
421424
if (this.bpClient) {
422425
logger.debug('Setting waitForAngular' + !enabled);
423-
return this.bpClient.setWaitEnabled(enabled).then(() => {
424-
return enabled;
425-
});
426+
const bpCommandPromise = this.bpClient.setWaitEnabled(enabled);
427+
// Convert to webdriver promise as best as possible
428+
return wdpromise.when(bpCommandPromise as any).then(() => enabled);
426429
}
427430
});
428431
}, `Set proxy synchronization enabled to ${enabled}`);
@@ -454,7 +457,6 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
454457
* var fork = browser.forkNewDriverInstance();
455458
* fork.get('page1'); // 'page1' gotten by forked browser
456459
*
457-
* @example
458460
* // Running with control flow disabled
459461
* var forked = await browser.forkNewDriverInstance().ready;
460462
* await forked.get('page1'); // 'page1' gotten by forked browser
@@ -493,13 +495,11 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
493495
* browser.restart();
494496
* browser.get('page2'); // 'page2' gotten by restarted browser
495497
*
496-
* @example
497498
* // Running against global browser, with control flow disabled
498499
* await browser.get('page1');
499500
* await browser.restart();
500501
* await browser.get('page2'); // 'page2' gotten by restarted browser
501502
*
502-
* @example
503503
* // Running against forked browsers, with the control flow enabled
504504
* // In this case, you may prefer `restartSync` (documented below)
505505
* var forked = browser.forkNewDriverInstance();
@@ -508,14 +508,12 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
508508
* fork.get('page2'); // 'page2' gotten by restarted fork
509509
* });
510510
*
511-
* @example
512511
* // Running against forked browsers, with the control flow disabled
513512
* var forked = await browser.forkNewDriverInstance().ready;
514513
* await fork.get('page1');
515514
* fork = await fork.restart();
516515
* await fork.get('page2'); // 'page2' gotten by restarted fork
517516
*
518-
* @example
519517
* // Unexpected behavior can occur if you save references to the global `browser`
520518
* var savedBrowser = browser;
521519
* browser.get('foo').then(function() {
@@ -540,7 +538,6 @@ export class ProtractorBrowser extends AbstractExtendedWebDriver {
540538
* browser.restartSync();
541539
* browser.get('page2'); // 'page2' gotten by restarted browser
542540
*
543-
* @example
544541
* // Running against forked browsers
545542
* var forked = browser.forkNewDriverInstance();
546543
* fork.get('page1');

Diff for: release.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ Say the previous release was 0.0.J, the current release is 0.0.K, and the next r
1717

1818
- Make sure .gitignore and .npmignore are updated with any new files that need to be ignored.
1919

20+
- Make sure that the website and doc generation still work. Doing so now, before you update the package.json or CHANGELOG.md, will save you a big headache.
21+
- Run `./scripts/generate-docs.sh HEAD` to generate the docs against the current commit.
22+
- We have to compile down to es5 to get dgeni to work. `generate-docs.sh` can handle some of this but you may have to make minor changes to the codebase/build infrastructure.
23+
- Run the unit and e2e tests for the website.
24+
2025
- Update package.json with a version bump. If the changes are only bug fixes, increment the patch (e.g. 0.0.5 -> 0.0.6), otherwise increment the minor version.
2126

2227
- Update CHANGELOG.md.
@@ -41,9 +46,7 @@ Say the previous release was 0.0.J, the current release is 0.0.K, and the next r
4146
4247
- NPM publish
4348
44-
- Update the website. `./scripts/generate-docs.sh`. Run unit and e2e tests. Then switch to the
45-
`gh-pages` branch, edit the commit message with `git commit --amend`,
46-
and push the new website.
49+
- Update the website. Run `./scripts/generate-docs.sh`, then switch to the `gh-pages` branch, edit the commit message with `git commit --amend`, and push the new website.
4750
4851
- Run e2e test against the published website.
4952

Diff for: scripts/generate-docs.sh

+22-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/bin/sh
22
cd "$( dirname "${BASH_SOURCE[0]}" )/.."
33

4+
# Check number of parameters
5+
if [ "$#" -gt 1 ]; then
6+
echo "Usage: ./scripts/generate-docs.sh [commit_ref]"
7+
exit 1
8+
fi
9+
410
# Check that directory is clean
511
if [ $(git status --porcelain | wc -l) != "0" ]; then
612
echo -e "\033[0;31m" 1>&2 # Red
@@ -12,14 +18,25 @@ if [ $(git status --porcelain | wc -l) != "0" ]; then
1218
exit 1
1319
fi
1420

15-
echo "Switching to last release..."
16-
VERSION=$(node scripts/get-version.js)
21+
# If a commit ref is passed as a command line option, use that.
22+
# Otherwise, default to the tag corresponding to the version in package.json.
23+
if [ "$#" -eq 0 ]; then
24+
VERSION=$(node scripts/get-version.js)
25+
else
26+
VERSION=$1
27+
fi
1728
EXEC_BRANCH=$(git rev-parse --abbrev-ref HEAD)
29+
30+
echo "Switching to ${VERSION}..."
1831
git checkout "${VERSION}"
1932
if [ $? -ne 0 ]; then
2033
echo -e "\033[0;31m" 1>&2 # Red
21-
echo "The package.json file indicates that the current version is" 1>&2
22-
echo "\"${VERSION}\", but there is no corresponding git tag." 1>&2
34+
if [ "$#" -eq 0 ]; then
35+
echo "The package.json file indicates that the current version is" 1>&2
36+
echo "\"${VERSION}\", but there is no corresponding git tag." 1>&2
37+
else
38+
echo "Cannot checkout \"${VERSION}\"." 1>&2
39+
fi
2340
echo -e "\033[0m" 1>&2 # Normal Color
2441
git checkout "${EXEC_BRANCH}"
2542
exit 1
@@ -61,6 +78,7 @@ if [ $? -ne 0 ]; then
6178
echo -e "\033[0;31m" 1>&2 # Red
6279
echo "Couldn't compile for es5."
6380
echo -e "\033[0m" 1>&2 # Normal Color
81+
npm remove @types/es6-promise
6482
git checkout "${EXEC_BRANCH}"
6583
exit 1
6684
fi

Diff for: tsconfig.json

+1-7
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,7 @@
77
"declaration": true,
88
"removeComments": false,
99
"noImplicitAny": true,
10-
"outDir": "built/",
11-
"types": [
12-
"jasmine", "jasminewd2", "node",
13-
"chalk", "glob", "minimatch",
14-
"minimist", "optimist", "q",
15-
"selenium-webdriver"
16-
]
10+
"outDir": "built/"
1711
},
1812
"exclude": [
1913
"built",

0 commit comments

Comments
 (0)