Merge branch 'development' into extractDocs

* development:
  Also show staging 0x.js docs on development
  Fix source links in docs with a hack to support old and new versions of the TypeDoc JSON files
  remove from devDeps
  Remove date for now
  Add ethers typescript typings to 0x.js deps. The library works without this atm since another dep of 0x.js has it as a dep. But it's more robust to have it here.
  Add  missing instructions to add external types to tsconfig.json after installing the package
This commit is contained in:
Fabio Berger
2018-03-06 11:11:35 +01:00
12 changed files with 95 additions and 6 deletions

View File

@@ -14,11 +14,13 @@ 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 isDevelopment = configs.ENVIRONMENT === Environments.DEVELOPMENT;
const docIdToS3BucketName: { [id: string]: string } = {
[DocPackages.ZeroExJs]: '0xjs-docs-jsons',
[DocPackages.ZeroExJs]: isDevelopment ? 'staging-0xjs-docs-jsons' : '0xjs-docs-jsons',
[DocPackages.SmartContracts]: 'smart-contracts-docs-json',
[DocPackages.Connect]:
configs.ENVIRONMENT === Environments.DEVELOPMENT ? 'staging-connect-docs-jsons' : 'connect-docs-jsons',
[DocPackages.Connect]: isDevelopment ? 'staging-connect-docs-jsons' : 'connect-docs-jsons',
};
const docIdToSubpackageName: { [id: string]: string } = {
@@ -121,13 +123,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;
}
}