From 629a0fa3a562a9df00eeeb5ce5b1bad853008ac3 Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Tue, 28 Nov 2017 15:42:27 -0600 Subject: Add subPackageName and get rid of hard-coded 0x.js in sourceLink --- packages/website/ts/containers/zero_ex_js_documentation.tsx | 1 + packages/website/ts/pages/documentation/docs_info.ts | 2 ++ packages/website/ts/pages/documentation/documentation.tsx | 1 + packages/website/ts/pages/documentation/method_block.tsx | 1 + packages/website/ts/pages/documentation/source_link.tsx | 13 +++++++++++-- packages/website/ts/types.ts | 1 + 6 files changed, 17 insertions(+), 2 deletions(-) diff --git a/packages/website/ts/containers/zero_ex_js_documentation.tsx b/packages/website/ts/containers/zero_ex_js_documentation.tsx index 15a137de1..cbb8fce5f 100644 --- a/packages/website/ts/containers/zero_ex_js_documentation.tsx +++ b/packages/website/ts/containers/zero_ex_js_documentation.tsx @@ -41,6 +41,7 @@ const zeroExJsDocSections = { const docsInfoConfig: DocsInfoConfig = { packageName: '0x.js', packageUrl: 'https://github.com/0xProject/0x.js', + subPackageName: '0x.js', websitePath: WebsitePaths.ZeroExJs, docsJsonRoot: 'https://s3.amazonaws.com/0xjs-docs-jsons', menu: { diff --git a/packages/website/ts/pages/documentation/docs_info.ts b/packages/website/ts/pages/documentation/docs_info.ts index f607c2185..fd8e9df74 100644 --- a/packages/website/ts/pages/documentation/docs_info.ts +++ b/packages/website/ts/pages/documentation/docs_info.ts @@ -13,6 +13,7 @@ import { export class DocsInfo { public packageName: string; public packageUrl: string; + public subPackageName?: string; public websitePath: string; public docsJsonRoot: string; public menu: DocsMenu; @@ -22,6 +23,7 @@ export class DocsInfo { constructor(config: DocsInfoConfig) { this.packageName = config.packageName; this.packageUrl = config.packageUrl; + this.subPackageName = config.subPackageName; this.websitePath = config.websitePath; this.docsJsonRoot = config.docsJsonRoot; this.sections = config.sections; diff --git a/packages/website/ts/pages/documentation/documentation.tsx b/packages/website/ts/pages/documentation/documentation.tsx index 288a8f79c..b56441bfe 100644 --- a/packages/website/ts/pages/documentation/documentation.tsx +++ b/packages/website/ts/pages/documentation/documentation.tsx @@ -335,6 +335,7 @@ export class Documentation extends version={this.props.docsVersion} source={property.source} baseUrl={this.props.docsInfo.packageUrl} + subPackageName={this.props.docsInfo.subPackageName} /> } {property.comment && diff --git a/packages/website/ts/pages/documentation/method_block.tsx b/packages/website/ts/pages/documentation/method_block.tsx index 3f4eb7164..44e549211 100644 --- a/packages/website/ts/pages/documentation/method_block.tsx +++ b/packages/website/ts/pages/documentation/method_block.tsx @@ -95,6 +95,7 @@ export class MethodBlock extends React.Component } {method.comment && diff --git a/packages/website/ts/pages/documentation/source_link.tsx b/packages/website/ts/pages/documentation/source_link.tsx index 408dcabc7..74fc6d4d5 100644 --- a/packages/website/ts/pages/documentation/source_link.tsx +++ b/packages/website/ts/pages/documentation/source_link.tsx @@ -1,3 +1,4 @@ +import * as _ from 'lodash'; import {colors} from 'material-ui/styles'; import * as React from 'react'; import {Source} from 'ts/types'; @@ -7,14 +8,22 @@ interface SourceLinkProps { source: Source; baseUrl: string; version: string; + subPackageName: string; } -const SUB_PKG = '0x.js'; +const packagesWithNamespace = [ + 'connect', +]; export function SourceLink(props: SourceLinkProps) { const src = props.source; const url = props.baseUrl; - const sourceCodeUrl = `${url}/blob/${SUB_PKG}%40${props.version}/packages/${SUB_PKG}/${src.fileName}#L${src.line}`; + const pkg = props.subPackageName; + let tagPrefix = pkg; + if (_.includes(packagesWithNamespace, pkg)) { + tagPrefix = `@0xproject/${pkg}`; + } + const sourceCodeUrl = `${url}/blob/${tagPrefix}%40${props.version}/packages/${pkg}/${src.fileName}#L${src.line}`; return (
DocAgnosticFormat; + subPackageName?: string; publicTypes?: string[]; sectionNameToModulePath?: {[sectionName: string]: string[]}; menuSubsectionToVersionWhenIntroduced?: {[sectionName: string]: string}; -- cgit v1.2.3