Updated ToC / usage doc
This commit is contained in:
committed by
fabioberger
parent
8e45d5e137
commit
b2e2c27775
@@ -1,3 +1,5 @@
|
||||
## Sol-coverage
|
||||
|
||||
Sol-coverage uses transaction traces in order to figure out which lines of Solidity source code have been covered by your tests. In order for it to gather these traces, you must add the `CoverageSubprovider` to the [ProviderEngine](https://github.com/MetaMask/provider-engine) instance you use when running your Solidity tests. If you're unfamiliar with `ProviderEngine`, please read the [Web3 Provider explained](https://0x.org/wiki#Web3-Provider-Explained) wiki article.
|
||||
|
||||
The CoverageSubprovider eavesdrops on the `eth_sendTransaction` and `eth_call` RPC calls and collects traces after each call using `debug_traceTransaction`. `eth_call`'s' don't generate traces - so we take a snapshot, re-submit it as a transaction, get the trace and then revert the snapshot.
|
||||
@@ -6,7 +8,7 @@ Coverage subprovider needs some info about your contracts (`srcMap`, `bytecode`)
|
||||
|
||||
In order to use `CoverageSubprovider` with your favorite framework you need to pass an `artifactsAdapter` to it.
|
||||
|
||||
### Sol-compiler
|
||||
## Sol-compiler
|
||||
|
||||
If you are generating your artifacts with [@0x/sol-compiler](https://0x.org/docs/sol-compiler) you can use the `SolCompilerArtifactAdapter` we've implemented for you.
|
||||
|
||||
@@ -16,7 +18,7 @@ import { SolCompilerArtifactAdapter } from '@0x/sol-coverage';
|
||||
const artifactAdapter = new SolCompilerArtifactAdapter(artifactsDir, contractsDir);
|
||||
```
|
||||
|
||||
### Truffle
|
||||
## Truffle
|
||||
|
||||
If your project is using [Truffle](https://truffleframework.com/), we've written a `TruffleArtifactsAdapter`for you.
|
||||
|
||||
@@ -70,7 +72,7 @@ class YourCustomArtifactsAdapter extends AbstractArtifactAdapter {...};
|
||||
const artifactAdapter = new YourCustomArtifactsAdapter(...);
|
||||
```
|
||||
|
||||
### Usage
|
||||
## Usage
|
||||
|
||||
```typescript
|
||||
import { CoverageSubprovider } from '@0x/sol-coverage';
|
||||
@@ -106,7 +108,7 @@ istanbul report html
|
||||
open coverage/index.html
|
||||
```
|
||||
|
||||
### Notifications
|
||||
## Notifications
|
||||
|
||||
<Notification>This is a standard notification</Notification>
|
||||
<Notification type="alert">Something isn’t quite right</Notification>
|
||||
@@ -126,7 +128,7 @@ open coverage/index.html
|
||||
|
||||
### Tabs
|
||||
|
||||
### Separator
|
||||
## Separator
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -1,62 +1,10 @@
|
||||
import React from 'react';
|
||||
|
||||
// import { Link } from '@0x/react-shared';
|
||||
|
||||
import { colors } from 'ts/style/colors';
|
||||
import { styled } from 'ts/style/theme';
|
||||
|
||||
interface IGroupProps {
|
||||
heading: string;
|
||||
name: string;
|
||||
filters: IFilterProps[];
|
||||
}
|
||||
|
||||
interface IFilterProps {
|
||||
value: string;
|
||||
label: string;
|
||||
}
|
||||
|
||||
const groups: IGroupProps[] = [
|
||||
{
|
||||
heading: 'Topic',
|
||||
name: 'topic',
|
||||
filters: [
|
||||
{
|
||||
value: 'mesh',
|
||||
label: 'Mesh',
|
||||
},
|
||||
{
|
||||
value: 'testing',
|
||||
label: 'Testing',
|
||||
},
|
||||
{
|
||||
value: 'mesh',
|
||||
label: 'Mesh',
|
||||
},
|
||||
{
|
||||
value: 'testing',
|
||||
label: 'Testing',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
heading: 'Level',
|
||||
name: 'level',
|
||||
filters: [
|
||||
{
|
||||
value: 'beginner',
|
||||
label: 'Beginner',
|
||||
},
|
||||
{
|
||||
value: 'intermediate',
|
||||
label: 'Intermediate',
|
||||
},
|
||||
{
|
||||
value: 'advanced',
|
||||
label: 'Advanced',
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
interface ITableOfContentsProps {
|
||||
contents: IContents[];
|
||||
}
|
||||
@@ -68,92 +16,36 @@ export interface IContents {
|
||||
title: string;
|
||||
}
|
||||
|
||||
const Level: React.FC<{ data: IContents[] }> = ({ data }) => {
|
||||
return (
|
||||
<ChapterLinksWrapper>
|
||||
{data.map((m, index) => {
|
||||
return (
|
||||
<>
|
||||
<ChapterLink key={index} level={m.level}>
|
||||
<a href={`#${m.id}`}>{m.title}</a>
|
||||
</ChapterLink>
|
||||
{m.children.length > 0 && <Level data={m.children} />}
|
||||
</>
|
||||
);
|
||||
})}
|
||||
</ChapterLinksWrapper>
|
||||
);
|
||||
};
|
||||
|
||||
export const TableOfContents: React.FC<ITableOfContentsProps> = ({ contents }) => {
|
||||
console.log('contents', contents);
|
||||
return (
|
||||
<>
|
||||
<Level data={contents} />
|
||||
{/* {groups.map(({ heading, name, filters }: IGroupProps, groupIndex) => (
|
||||
<ChapterGroupWrapper key={`filter-group-${groupIndex}`}>
|
||||
<ChapterLink href="#index" hasChildren={filters.length > 0}>
|
||||
{heading}
|
||||
</ChapterLink>
|
||||
<ChapterChildren>
|
||||
{filters.map(({ value, label }: IFilterProps, filterIndex) => (
|
||||
<ChapterSublink
|
||||
href={`#filter-${name}-${filterIndex}`}
|
||||
key={`filter-${name}-${filterIndex}`}
|
||||
data-level="2"
|
||||
>
|
||||
{label}
|
||||
</ChapterSublink>
|
||||
))}
|
||||
</ChapterChildren>
|
||||
</ChapterGroupWrapper>
|
||||
))} */}
|
||||
</>
|
||||
<ul>
|
||||
{contents.map(content => {
|
||||
const { children, id, title } = content;
|
||||
return (
|
||||
<li key={id}>
|
||||
<ContentLink href={`#${id}`}>{title}</ContentLink>
|
||||
{children.length > 0 && <TableOfContents contents={children} />}
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
);
|
||||
};
|
||||
|
||||
const ChapterLinksWrapper = styled.ul`
|
||||
position: relative;
|
||||
`;
|
||||
|
||||
const ChapterGroupWrapper = styled.li`
|
||||
margin-bottom: 1.111em;
|
||||
`;
|
||||
|
||||
const ChapterLink = styled.p<{ level: number }>`
|
||||
padding-bottom: 1rem;
|
||||
color: ${colors.textDarkSecondary};
|
||||
const ContentLink = styled.a`
|
||||
display: block;
|
||||
font-size: 0.8333rem;
|
||||
color: ${colors.textDarkSecondary};
|
||||
margin-bottom: 1rem;
|
||||
|
||||
& + ul p {
|
||||
& + ul {
|
||||
border-left: 1px solid #e3e3e3;
|
||||
padding-left: 0.7rem;
|
||||
font-size: 0.7222rem;
|
||||
|
||||
&:last-of-type {
|
||||
padding-bottom: 0;
|
||||
p {
|
||||
font-size: 0.7222rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const ChapterSublink = styled(ChapterLink)`
|
||||
font-size: 0.7222rem;
|
||||
line-height: 1.45;
|
||||
|
||||
&:not(:first-child) {
|
||||
margin-top: 0.555555556rem;
|
||||
}
|
||||
`;
|
||||
|
||||
// const ChapterGroupWrapper = styled(Heading)`
|
||||
// color: ${colors.textDarkPrimary};
|
||||
// font-size: 1rem !important;
|
||||
// font-weight: 400 !important;
|
||||
// margin-bottom: 1em !important;
|
||||
// `;
|
||||
|
||||
const ChapterChildren = styled.div`
|
||||
border-left: 1px solid #e3e3e3;
|
||||
padding-left: 0.7rem;
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user