aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-03-06 16:33:35 +0800
committerFabio Berger <me@fabioberger.com>2018-03-06 16:33:35 +0800
commitb4b664e97acd25b8a00c7fae3b6eacd9fbf74585 (patch)
treefcda4f8518c772056671dce3d2d5c618974f71b0 /packages/website/ts
parent994935b5da0b15796958a32c5bab0a25b9430b5a (diff)
downloaddexon-sol-tools-b4b664e97acd25b8a00c7fae3b6eacd9fbf74585.tar.gz
dexon-sol-tools-b4b664e97acd25b8a00c7fae3b6eacd9fbf74585.tar.zst
dexon-sol-tools-b4b664e97acd25b8a00c7fae3b6eacd9fbf74585.zip
Fix source links in docs with a hack to support old and new versions of the TypeDoc JSON files
Diffstat (limited to 'packages/website/ts')
-rw-r--r--packages/website/ts/pages/documentation/doc_page.tsx15
1 files changed, 13 insertions, 2 deletions
diff --git a/packages/website/ts/pages/documentation/doc_page.tsx b/packages/website/ts/pages/documentation/doc_page.tsx
index 2c8f1c103..85fd9bf33 100644
--- a/packages/website/ts/pages/documentation/doc_page.tsx
+++ b/packages/website/ts/pages/documentation/doc_page.tsx
@@ -13,6 +13,8 @@ import { constants } from 'ts/utils/constants';
import { docUtils } from 'ts/utils/doc_utils';
import { Translate } from 'ts/utils/translate';
+const ZERO_EX_JS_VERSION_MISSING_TOPLEVEL_PATH = '0.32.4';
+
const docIdToS3BucketName: { [id: string]: string } = {
[DocPackages.ZeroExJs]: '0xjs-docs-jsons',
[DocPackages.SmartContracts]: 'smart-contracts-docs-json',
@@ -120,13 +122,22 @@ export class DocPage extends React.Component<DocPageProps, DocPageState> {
}
private _getSourceUrl() {
const url = this.props.docsInfo.packageUrl;
- const pkg = docIdToSubpackageName[this.props.docsInfo.id];
+ let pkg = docIdToSubpackageName[this.props.docsInfo.id];
let tagPrefix = pkg;
const packagesWithNamespace = ['connect'];
if (_.includes(packagesWithNamespace, pkg)) {
tagPrefix = `@0xproject/${pkg}`;
}
- const sourceUrl = `${url}/blob/${tagPrefix}%40${this.props.docsVersion}/packages/${pkg}`;
+ // HACK: The following three lines exist for backward compatibility reasons
+ // Before exporting types from other packages as part of the 0x.js interface,
+ // all TypeDoc generated paths omitted the topLevel `0x.js` segment. Now it
+ // adds it, and for that reason, we need to make sure we don't add it twice in
+ // the source links we generate.
+ const semvers = semverSort.desc([this.props.docsVersion, ZERO_EX_JS_VERSION_MISSING_TOPLEVEL_PATH]);
+ const isVersionAfterTopLevelPathChange = semvers[0] !== ZERO_EX_JS_VERSION_MISSING_TOPLEVEL_PATH;
+ pkg = this.props.docsInfo.id === DocPackages.ZeroExJs && isVersionAfterTopLevelPathChange ? '' : `/${pkg}`;
+
+ const sourceUrl = `${url}/blob/${tagPrefix}%40${this.props.docsVersion}/packages${pkg}`;
return sourceUrl;
}
}