Add subPackageName and get rid of hard-coded 0x.js in sourceLink

This commit is contained in:
Fabio Berger
2017-11-28 15:42:27 -06:00
parent 15ce862334
commit 629a0fa3a5
6 changed files with 17 additions and 2 deletions

View File

@@ -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: {

View File

@@ -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;

View File

@@ -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 &&

View File

@@ -95,6 +95,7 @@ export class MethodBlock extends React.Component<MethodBlockProps, MethodBlockSt
version={this.props.libraryVersion}
source={(method as TypescriptMethod).source}
baseUrl={this.props.docsInfo.packageUrl}
subPackageName={this.props.docsInfo.subPackageName}
/>
}
{method.comment &&

View File

@@ -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 (
<div className="pt2" style={{fontSize: 14}}>
<a

View File

@@ -682,6 +682,7 @@ export interface DocsInfoConfig {
sectionNameToMarkdown: {[sectionName: string]: string};
visibleConstructors: string[];
convertToDocAgnosticFormatFn: (docObj: DoxityDocObj|TypeDocNode, docsInfo?: any) => DocAgnosticFormat;
subPackageName?: string;
publicTypes?: string[];
sectionNameToModulePath?: {[sectionName: string]: string[]};
menuSubsectionToVersionWhenIntroduced?: {[sectionName: string]: string};