aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--packages/monorepo-scripts/src/doc_gen_configs.ts33
-rw-r--r--packages/monorepo-scripts/src/types.ts16
-rw-r--r--packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts57
3 files changed, 59 insertions, 47 deletions
diff --git a/packages/monorepo-scripts/src/doc_gen_configs.ts b/packages/monorepo-scripts/src/doc_gen_configs.ts
new file mode 100644
index 000000000..fd95863c3
--- /dev/null
+++ b/packages/monorepo-scripts/src/doc_gen_configs.ts
@@ -0,0 +1,33 @@
+import { DocGenConfigs } from './types';
+
+export const docGenConfigs: DocGenConfigs = {
+ DOC_JSON_VERSION: '0.0.1',
+ EXTERNAL_TYPE_TO_LINK: {
+ BigNumber: 'http://mikemcl.github.io/bignumber.js',
+ Error: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error',
+ Buffer: 'https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/v9/index.d.ts#L262',
+ 'solc.StandardContractOutput':
+ 'https://solidity.readthedocs.io/en/v0.4.24/using-the-compiler.html#output-description',
+ 'solc.CompilerSettings': 'https://solidity.readthedocs.io/en/v0.4.24/using-the-compiler.html#input-description',
+ Schema:
+ 'https://github.com/tdegrunt/jsonschema/blob/5c2edd4baba149964aec0f23c87ad12c25a50dfb/lib/index.d.ts#L49',
+ },
+ /**
+ * If a 0x package re-exports an external package, we should add a link to it's exported items here
+ */
+ EXTERNAL_EXPORT_TO_LINK: {
+ Web3ProviderEngine: 'https://www.npmjs.com/package/web3-provider-engine',
+ BigNumber: 'https://www.npmjs.com/package/bignumber.js',
+ Schema: 'https://github.com/tdegrunt/jsonschema/blob/v1.2.4/lib/index.d.ts#L49',
+ ValidatorResult: 'https://github.com/tdegrunt/jsonschema/blob/v1.2.4/lib/helpers.js#L31',
+ },
+ CLASSES_WITH_HIDDEN_CONSTRUCTORS: [
+ 'ERC20ProxyWrapper',
+ 'ERC20TokenWrapper',
+ 'ERC721ProxyWrapper',
+ 'ERC721TokenWrapper',
+ 'EtherTokenWrapper',
+ 'ExchangeWrapper',
+ 'ForwarderWrapper',
+ ],
+};
diff --git a/packages/monorepo-scripts/src/types.ts b/packages/monorepo-scripts/src/types.ts
index 4d4600abf..5f6a6c707 100644
--- a/packages/monorepo-scripts/src/types.ts
+++ b/packages/monorepo-scripts/src/types.ts
@@ -50,6 +50,22 @@ export interface Package {
packageJson: PackageJSON;
}
+export interface DocGenConfigs {
+ DOC_JSON_VERSION: string;
+ EXTERNAL_TYPE_TO_LINK: { [externalType: string]: string };
+ EXTERNAL_EXPORT_TO_LINK: { [externalExport: string]: string };
+ CLASSES_WITH_HIDDEN_CONSTRUCTORS: string[];
+}
+
export interface ExportPathToExportedItems {
[pkgName: string]: string[];
}
+
+export interface ExportInfo {
+ exportPathToExportedItems: ExportPathToExportedItems;
+ exportPathOrder: string[];
+}
+
+export interface ExportNameToTypedocNames {
+ [exportName: string]: string[];
+}
diff --git a/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts b/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts
index b4911c84b..0d9c47932 100644
--- a/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts
+++ b/packages/monorepo-scripts/src/utils/doc_generate_and_upload_utils.ts
@@ -5,51 +5,11 @@ import { exec as execAsync } from 'promisify-child-process';
import * as ts from 'typescript';
import { constants } from '../constants';
-import { ExportPathToExportedItems } from '../types';
+import { docGenConfigs } from '../doc_gen_configs';
+import { ExportInfo, ExportNameToTypedocNames, ExportPathToExportedItems } from '../types';
import { utils } from './utils';
-interface ExportInfo {
- exportPathToExportedItems: ExportPathToExportedItems;
- exportPathOrder: string[];
-}
-
-interface ExportNameToTypedocNames {
- [exportName: string]: string[];
-}
-
-const DOC_JSON_VERSION = '0.0.1';
-
-const EXTERNAL_TYPE_TO_LINK: { [externalType: string]: string } = {
- BigNumber: 'http://mikemcl.github.io/bignumber.js',
- Error: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error',
- Buffer: 'https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/node/v9/index.d.ts#L262',
- 'solc.StandardContractOutput':
- 'https://solidity.readthedocs.io/en/v0.4.24/using-the-compiler.html#output-description',
- 'solc.CompilerSettings': 'https://solidity.readthedocs.io/en/v0.4.24/using-the-compiler.html#input-description',
- Schema: 'https://github.com/tdegrunt/jsonschema/blob/5c2edd4baba149964aec0f23c87ad12c25a50dfb/lib/index.d.ts#L49',
-};
-
-/**
- * If a 0x package re-exports an external package, we should add a link to it's exported items here
- */
-const EXTERNAL_EXPORT_TO_LINK: { [externalExport: string]: string } = {
- Web3ProviderEngine: 'https://www.npmjs.com/package/web3-provider-engine',
- BigNumber: 'https://www.npmjs.com/package/bignumber.js',
- Schema: 'https://github.com/tdegrunt/jsonschema/blob/v1.2.4/lib/index.d.ts#L49',
- ValidatorResult: 'https://github.com/tdegrunt/jsonschema/blob/v1.2.4/lib/helpers.js#L31',
-};
-
-const CLASSES_WITH_HIDDEN_CONSTRUCTORS: string[] = [
- 'ERC20ProxyWrapper',
- 'ERC20TokenWrapper',
- 'ERC721ProxyWrapper',
- 'ERC721TokenWrapper',
- 'EtherTokenWrapper',
- 'ExchangeWrapper',
- 'ForwarderWrapper',
-];
-
export async function generateAndUploadDocsAsync(packageName: string, isStaging: boolean): Promise<void> {
const monorepoPackages = utils.getPackages(constants.monorepoRootPath);
const pkg = _.find(monorepoPackages, monorepoPackage => {
@@ -178,7 +138,7 @@ export async function generateAndUploadDocsAsync(packageName: string, isStaging:
_.each(innerChildren, (innerChild, k) => {
const isHiddenConstructor =
child.kindString === 'Class' &&
- _.includes(CLASSES_WITH_HIDDEN_CONSTRUCTORS, child.name) &&
+ _.includes(docGenConfigs.CLASSES_WITH_HIDDEN_CONSTRUCTORS, child.name) &&
innerChild.kindString === 'Constructor';
const isPrivate = _.startsWith(innerChild.name, '_');
if (isHiddenConstructor || isPrivate) {
@@ -209,7 +169,10 @@ export async function generateAndUploadDocsAsync(packageName: string, isStaging:
const missingReferences: string[] = [];
_.each(referenceNames, referenceName => {
- if (!_.includes(allExportedItems, referenceName) && _.isUndefined(EXTERNAL_TYPE_TO_LINK[referenceName])) {
+ if (
+ !_.includes(allExportedItems, referenceName) &&
+ _.isUndefined(docGenConfigs.EXTERNAL_TYPE_TO_LINK[referenceName])
+ ) {
missingReferences.push(referenceName);
}
});
@@ -224,7 +187,7 @@ export async function generateAndUploadDocsAsync(packageName: string, isStaging:
const externalExportToLink: { [externalExport: string]: string } = {};
const externalExportsWithoutLinks: string[] = [];
_.each(externalExports, externalExport => {
- const linkIfExists = EXTERNAL_EXPORT_TO_LINK[externalExport];
+ const linkIfExists = docGenConfigs.EXTERNAL_EXPORT_TO_LINK[externalExport];
if (_.isUndefined(linkIfExists)) {
externalExportsWithoutLinks.push(externalExport);
return;
@@ -241,11 +204,11 @@ export async function generateAndUploadDocsAsync(packageName: string, isStaging:
// Since we need additional metadata included in the doc JSON, we nest the TypeDoc JSON
const docJson = {
- version: DOC_JSON_VERSION,
+ version: docGenConfigs.DOC_JSON_VERSION,
metadata: {
exportPathToTypedocNames,
exportPathOrder,
- externalTypeToLink: EXTERNAL_TYPE_TO_LINK,
+ externalTypeToLink: docGenConfigs.EXTERNAL_TYPE_TO_LINK,
externalExportToLink,
},
typedocJson: finalTypeDocOutput,