Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
812: docs(Reference): Combine front-end and dgeni parsing for api reference. r=davemneo a=afragapane

### Description of the Change
Combine front-end and dgeni parsing to create working API reference.  

### Test Plan
View website and confirm things look as expected.

### Applicable Issues
#702

841: chore(deps): update babel monorepo r=davemneo a=renovate[bot]

This PR contains the following updates:

| Package | Type | Update | Change | References |
|---|---|---|---|---|
| @​babel/core | devDependencies | patch | `7.2.0` -> `7.2.2` | [homepage](https://babeljs.io/), [source](https://renovatebot.com/gh/babel/babel) |
| @​babel/preset-env | devDependencies | patch | `7.2.0` -> `7.2.3` | [homepage](https://babeljs.io/), [source](https://renovatebot.com/gh/babel/babel) |

---

### Release Notes

<details>
<summary>babel/babel</summary>

### [`v7.2.2`](https://renovatebot.com/gh/babel/babel/releases/v7.2.2)

[Compare Source](https://renovatebot.com/gh/babel/babel/compare/v7.2.0...v7.2.2)

#### v7.2.2 (2018-12-15)

Mostrly bug fixes and internal changes.
Thanks to [@&#8203;paleite](https://renovatebot.com/gh/paleite), [@&#8203;saschanaz](https://renovatebot.com/gh/saschanaz) and [@&#8203;joeldenning](https://renovatebot.com/gh/joeldenning) for their first PRs!

##### 🐛 Bug Fix

-   `babel-plugin-transform-destructuring`, `babel-plugin-transform-spread`
    -   [#&#8203;9108](https://renovatebot.com/gh/babel/babel/pull/9108) Correctly transform spreads to use proper concat method. ([@&#8203;danez](https://renovatebot.com/gh/danez))
-   `babel-parser`
    -   [#&#8203;9168](https://renovatebot.com/gh/babel/babel/pull/9168) [parser] Handle flow comments with leading spaces. ([@&#8203;vikr01](https://renovatebot.com/gh/vikr01))
-   `babel-helper-module-transforms`, `babel-plugin-transform-modules-commonjs`
    -   [#&#8203;9171](https://renovatebot.com/gh/babel/babel/pull/9171) Fix transforming empty export statement. ([@&#8203;danez](https://renovatebot.com/gh/danez))
-   `babel-node`
    -   [#&#8203;9148](https://renovatebot.com/gh/babel/babel/pull/9148) Fix --root-mode option in babel-node. ([@&#8203;nicolo-ribaudo](https://renovatebot.com/gh/nicolo-ribaudo))
-   `babel-plugin-transform-classes`
    -   [#&#8203;9135](https://renovatebot.com/gh/babel/babel/pull/9135) Inherit properties in function from method in loose mode. ([@&#8203;rubennorte](https://renovatebot.com/gh/rubennorte))
-   `babel-preset-env`
    -   [#&#8203;9140](https://renovatebot.com/gh/babel/babel/pull/9140) Disable parameter-destructuring in Edge 18. ([@&#8203;saschanaz](https://renovatebot.com/gh/saschanaz))
-   `babel-plugin-transform-arrow-functions`, `babel-traverse`
    -   [#&#8203;9060](https://renovatebot.com/gh/babel/babel/pull/9060) Not depending on return value of super(). Closes [#&#8203;9020](https://renovatebot.com/gh/babel/babel/issues/9020).. ([@&#8203;joeldenning](https://renovatebot.com/gh/joeldenning))

##### 🏠 Internal

-   `babel-helper-create-class-features-plugin`, `babel-plugin-proposal-nullish-coalescing-operator`, `babel-plugin-syntax-bigint`, `babel-plugin-transform-dotall-regex`
    -   [#&#8203;9176](https://renovatebot.com/gh/babel/babel/pull/9176) Fix package.json repository URLs. ([@&#8203;paleite](https://renovatebot.com/gh/paleite))
-   Other
    -   [#&#8203;9158](https://renovatebot.com/gh/babel/babel/pull/9158) add triage label to new issues [skip ci]. ([@&#8203;danez](https://renovatebot.com/gh/danez))
    -   [#&#8203;9143](https://renovatebot.com/gh/babel/babel/pull/9143) Fix a typo from the issue template for bugs. ([@&#8203;saschanaz](https://renovatebot.com/gh/saschanaz))
    -   [#&#8203;9133](https://renovatebot.com/gh/babel/babel/pull/9133) Move to travis vm based builds. ([@&#8203;danez](https://renovatebot.com/gh/danez))
    -   [#&#8203;9132](https://renovatebot.com/gh/babel/babel/pull/9132) Ensure we always use repository versions of babel dependencies in tests. ([@&#8203;danez](https://renovatebot.com/gh/danez))
    -   [#&#8203;9131](https://renovatebot.com/gh/babel/babel/pull/9131) Update issue templates [skip ci]. ([@&#8203;hzoo](https://renovatebot.com/gh/hzoo))
-   `babel-helper-create-class-features-plugin`, `babel-plugin-proposal-class-properties`, `babel-plugin-proposal-decorators`
    -   [#&#8203;9059](https://renovatebot.com/gh/babel/babel/pull/9059) Move decorators transform to [@&#8203;babel/helper-create-class-features-plugin](https://renovatebot.com/gh/babel/helper-create-class-features-plugin). ([@&#8203;nicolo-ribaudo](https://renovatebot.com/gh/nicolo-ribaudo))
-   `babel-core`, `babel-parser`, `babel-template`
    -   [#&#8203;9128](https://renovatebot.com/gh/babel/babel/pull/9128) Fix running flow on travis and update flow. ([@&#8203;danez](https://renovatebot.com/gh/danez))

##### Committers: 10

-   Brian Ng ([existentialism](https://renovatebot.com/gh/existentialism))
-   Daniel Tschinder ([danez](https://renovatebot.com/gh/danez))
-   Henry Zhu ([hzoo](https://renovatebot.com/gh/hzoo))
-   Joel Denning ([joeldenning](https://renovatebot.com/gh/joeldenning))
-   Kagami Sascha Rosylight ([saschanaz](https://renovatebot.com/gh/saschanaz))
-   Nicolò Ribaudo ([nicolo-ribaudo](https://renovatebot.com/gh/nicolo-ribaudo))
-   Patrick Eriksson ([paleite](https://renovatebot.com/gh/paleite))
-   Rubén Norte ([rubennorte](https://renovatebot.com/gh/rubennorte))
-   Thiago Arrais ([thiagoarrais](https://renovatebot.com/gh/thiagoarrais))
-   Vikram Rangaraj ([vikr01](https://renovatebot.com/gh/vikr01))

</details>

---

### Renovate configuration

:date: **Schedule**: At any time (no schedule defined).

:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

:recycle: **Rebasing**: Whenever PR becomes conflicted, or if you modify the PR title to begin with "`rebase!`".

:ghost: **Immortal**: This PR will be recreated if closed unmerged. Get [config help](https://renovatebot.com/gh/renovatebot/config-help/issues) if that's undesired.

---

 - [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://renovatebot.com/gh/marketplace/renovate). View repository job log [here](https://renovatebot.com/dashboard#neo-one-suite/neo-one).

848: docs(Reference): Give object parameters a name if they will be includ… r=davemneo a=afragapane

With dgeni typescript parsing, function parameters display awkwardly if they are unnamed objects.
Giving them a name like "options" fixes the issue and displays them properly.

#702

876: chore(deps): update dependency rxjs-tslint-rules to v4.14.3 r=davemneo a=renovate[bot]

This PR contains the following updates:

| Package | Type | Update | Change | References |
|---|---|---|---|---|
| rxjs-tslint-rules | devDependencies | patch | `4.14.1` -> `4.14.3` | [source](https://renovatebot.com/gh/cartant/rxjs-tslint-rules) |

---

### Release Notes

<details>
<summary>cartant/rxjs-tslint-rules</summary>

### [`v4.14.3`](https://renovatebot.com/gh/cartant/rxjs-tslint-rules/blob/master/CHANGELOG.md#&#8203;4143httpsgithubcomcartantrxjs-tslint-rulescomparev4142v4143-2018-12-25)

[Compare Source](https://renovatebot.com/gh/cartant/rxjs-tslint-rules/compare/v4.14.2...v4.14.3)

### [`v4.14.2`](https://renovatebot.com/gh/cartant/rxjs-tslint-rules/blob/master/CHANGELOG.md#&#8203;4143httpsgithubcomcartantrxjs-tslint-rulescomparev4142v4143-2018-12-25)

[Compare Source](https://renovatebot.com/gh/cartant/rxjs-tslint-rules/compare/v4.14.1...v4.14.2)

</details>

---

### Renovate configuration

:date: **Schedule**: At any time (no schedule defined).

:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

:recycle: **Rebasing**: Whenever PR becomes conflicted, or if you modify the PR title to begin with "`rebase!`".

:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://renovatebot.com/gh/marketplace/renovate). View repository job log [here](https://renovatebot.com/dashboard#neo-one-suite/neo-one).

877: chore(deps): update dependency terser-webpack-plugin to v1.2.1 r=davemneo a=renovate[bot]

This PR contains the following updates:

| Package | Type | Update | Change | References |
|---|---|---|---|---|
| terser-webpack-plugin | devDependencies | minor | `1.1.0` -> `1.2.1` | [source](https://renovatebot.com/gh/webpack-contrib/terser-webpack-plugin) |

---

### Release Notes

<details>
<summary>webpack-contrib/terser-webpack-plugin</summary>

### [`v1.2.1`](https://renovatebot.com/gh/webpack-contrib/terser-webpack-plugin/blob/master/CHANGELOG.md#&#8203;121httpsgithubcomwebpack-contribterser-webpack-plugincomparev120v121-2018-12-27)

[Compare Source](https://renovatebot.com/gh/webpack-contrib/terser-webpack-plugin/compare/v1.2.0...v1.2.1)

##### Bug Fixes

-   don't crash when no extracted comments ([#&#8203;49](https://renovatebot.com/gh/webpack-contrib/terser-webpack-plugin/issues/49)) ([efad586](https://renovatebot.com/gh/webpack-contrib/terser-webpack-plugin/commit/efad586))

### [`v1.2.0`](https://renovatebot.com/gh/webpack-contrib/terser-webpack-plugin/blob/master/CHANGELOG.md#&#8203;120httpsgithubcomwebpack-contribterser-webpack-plugincomparev110v120-2018-12-22)

[Compare Source](https://renovatebot.com/gh/webpack-contrib/terser-webpack-plugin/compare/v1.1.0...v1.2.0)

##### Bug Fixes

-   `chunks` is a `Set` in webpack@5 ([#&#8203;19](https://renovatebot.com/gh/webpack-contrib/terser-webpack-plugin/issues/19)) ([df8c425](https://renovatebot.com/gh/webpack-contrib/terser-webpack-plugin/commit/df8c425))
-   catch `work-farm` errors ([#&#8203;35](https://renovatebot.com/gh/webpack-contrib/terser-webpack-plugin/issues/35)) ([2bdcd38](https://renovatebot.com/gh/webpack-contrib/terser-webpack-plugin/commit/2bdcd38))
-   dedupe extracted comments ([#&#8203;40](https://renovatebot.com/gh/webpack-contrib/terser-webpack-plugin/issues/40)) ([7f4a159](https://renovatebot.com/gh/webpack-contrib/terser-webpack-plugin/commit/7f4a159))
-   more consistent cache ([#&#8203;43](https://renovatebot.com/gh/webpack-contrib/terser-webpack-plugin/issues/43)) ([36f5f3c](https://renovatebot.com/gh/webpack-contrib/terser-webpack-plugin/commit/36f5f3c))
-   regenerate `contenthash` when assets was uglified ([#&#8203;44](https://renovatebot.com/gh/webpack-contrib/terser-webpack-plugin/issues/44)) ([7e6f8b1](https://renovatebot.com/gh/webpack-contrib/terser-webpack-plugin/commit/7e6f8b1))

##### Features

-   `chunkFilter` option for filtering chunks ([#&#8203;38](https://renovatebot.com/gh/webpack-contrib/terser-webpack-plugin/issues/38)) ([7ffe57c](https://renovatebot.com/gh/webpack-contrib/terser-webpack-plugin/commit/7ffe57c))
-   uglify `mjs` by default ([#&#8203;39](https://renovatebot.com/gh/webpack-contrib/terser-webpack-plugin/issues/39)) ([1644620](https://renovatebot.com/gh/webpack-contrib/terser-webpack-plugin/commit/1644620))

</details>

---

### Renovate configuration

:date: **Schedule**: At any time (no schedule defined).

:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

:recycle: **Rebasing**: Whenever PR becomes conflicted, or if you modify the PR title to begin with "`rebase!`".

:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://renovatebot.com/gh/marketplace/renovate). View repository job log [here](https://renovatebot.com/dashboard#neo-one-suite/neo-one).

878: chore(deps): update dependency levelup to v4 r=davemneo a=renovate[bot]

This PR contains the following updates:

| Package | Type | Update | Change | References |
|---|---|---|---|---|
| levelup | devDependencies | major | `3.1.1` -> `4.0.0` | [source](https://renovatebot.com/gh/level/levelup) |

---

### Release Notes

<details>
<summary>level/levelup</summary>

### [`v4.0.0`](https://renovatebot.com/gh/level/levelup/blob/master/CHANGELOG.md#&#8203;400---2018-12-22)

[Compare Source](https://renovatebot.com/gh/level/levelup/compare/v3.1.1...v4.0.0)

##### Changed

-   Upgrade `nyc` devDependency from `~12.0.2` to `~13.1.0` ([@&#8203;ralphtheninja](https://renovatebot.com/gh/ralphtheninja))
-   Upgrade `deferred-leveldown` dependency from `~4.0.0` to `~5.0.0` ([@&#8203;vweevers](https://renovatebot.com/gh/vweevers))
-   Upgrade `concat-stream` devDependency from `~1.6.0` to `~2.0.0` ([@&#8203;ralphtheninja](https://renovatebot.com/gh/ralphtheninja))
-   Upgrade `level-iterator-stream` dependency from `~3.0.0` to `~4.0.0` ([@&#8203;ralphtheninja](https://renovatebot.com/gh/ralphtheninja))
-   Replace `remark-cli` with `hallmark` ([#&#8203;621](https://renovatebot.com/gh/level/levelup/issues/621)) ([@&#8203;vweevers](https://renovatebot.com/gh/vweevers))
-   Upgrade `standard` devDependency from `^11.0.0` to `^12.0.0` ([@&#8203;ralphtheninja](https://renovatebot.com/gh/ralphtheninja))
-   Add `.nyc_output/` to `.npmignore` ([@&#8203;ralphtheninja](https://renovatebot.com/gh/ralphtheninja))

##### Removed

-   Remove `IE10` from `airtap` ([#&#8203;625](https://renovatebot.com/gh/level/levelup/issues/625)) ([@&#8203;ralphtheninja](https://renovatebot.com/gh/ralphtheninja))

</details>

---

### Renovate configuration

:date: **Schedule**: At any time (no schedule defined).

:vertical_traffic_light: **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

:recycle: **Rebasing**: Whenever PR becomes conflicted, or if you modify the PR title to begin with "`rebase!`".

:no_bell: **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- renovate-rebase -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://renovatebot.com/gh/marketplace/renovate). View repository job log [here](https://renovatebot.com/dashboard#neo-one-suite/neo-one).

Co-authored-by: afragapane <ahfragapane@gmail.com>
Co-authored-by: Renovate Bot <bot@renovateapp.com>
  • Loading branch information
3 people committed Jan 3, 2019
7 parents a3e0251 + 5de2b6d + 76a5503 + 497041a + f0d1875 + 04f492f + 356f88a commit 63b31b7
Show file tree
Hide file tree
Showing 28 changed files with 626 additions and 504 deletions.
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,14 @@
}
},
"devDependencies": {
"@babel/core": "7.2.0",
"@babel/core": "7.2.2",
"@babel/plugin-proposal-async-generator-functions": "7.2.0",
"@babel/plugin-proposal-object-rest-spread": "7.2.0",
"@babel/plugin-syntax-dynamic-import": "7.2.0",
"@babel/plugin-syntax-numeric-separator": "7.2.0",
"@babel/plugin-syntax-optional-catch-binding": "7.2.0",
"@babel/plugin-syntax-typescript": "7.2.0",
"@babel/preset-env": "7.2.0",
"@babel/preset-env": "7.2.3",
"@babel/preset-react": "7.0.0",
"@cypress/webpack-preprocessor": "4.0.2",
"@reactivex/ix-esnext-esm": "2.3.5",
Expand Down Expand Up @@ -221,7 +221,7 @@
"rollup-plugin-string": "2.0.2",
"rollup-plugin-typescript2": "0.18.1",
"rxjs": "6.3.3",
"rxjs-tslint-rules": "4.14.1",
"rxjs-tslint-rules": "4.14.3",
"source-map": "0.7.3",
"stats-webpack-plugin": "0.7.0",
"style-loader": "0.23.1",
Expand All @@ -230,7 +230,7 @@
"stylelint-config-standard": "18.2.0",
"stylelint-config-styled-components": "0.1.1",
"stylelint-processor-styled-components": "1.5.1",
"terser-webpack-plugin": "1.1.0",
"terser-webpack-plugin": "1.2.1",
"thread-loader": "2.1.1",
"through2": "3.0.0",
"tmp": "0.0.33",
Expand Down
13 changes: 5 additions & 8 deletions packages/neo-one-client-common/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,12 @@ export function isNEP2(encryptedKey: string): boolean {
* @param privateKey hex-encoded private key
* @returns NEP-2 format encrypted key
*/
export async function encryptNEP2({
password,
privateKey,
}: {
export async function encryptNEP2(options: {
readonly password: string;
readonly privateKey: PrivateKeyString;
}): Promise<string> {
const { password, privateKey } = options;

return crypto.encryptNEP2({
addressVersion: common.NEO_ADDRESS_VERSION,
privateKey: common.stringToPrivateKey(privateKey),
Expand All @@ -144,13 +143,11 @@ export async function encryptNEP2({
* @param encryptedKey NEP-2 format encrypted key
* @returns hex-encoded private key
*/
export async function decryptNEP2({
password,
encryptedKey,
}: {
export async function decryptNEP2(options: {
readonly password: string;
readonly encryptedKey: string;
}): Promise<PrivateKeyString> {
const { password, encryptedKey } = options;
const privateKey = await crypto.decryptNEP2({
addressVersion: common.NEO_ADDRESS_VERSION,
encryptedKey,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,8 @@ export class NEOONEOneDataProvider implements DeveloperProvider {
private readonly iterBlocksFetchTimeoutMS: number | undefined;
private readonly iterBlocksBatchSize: number | undefined;

public constructor({
network,
projectID,
port,
iterBlocksFetchTimeoutMS,
iterBlocksBatchSize,
}: NEOONEOneDataProviderOptions) {
public constructor(options: NEOONEOneDataProviderOptions) {
const { network, projectID, port, iterBlocksFetchTimeoutMS, iterBlocksBatchSize } = options;
this.network = network;
this.projectID = projectID;
this.port = port;
Expand Down
3 changes: 2 additions & 1 deletion packages/neo-one-client-core/src/provider/NEOONEProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export class NEOONEProvider implements Provider {
return this.networksInternal$.getValue();
}

public addNetwork({ network, rpcURL }: { readonly network: NetworkType; readonly rpcURL: string }): void {
public addNetwork(options: { readonly network: NetworkType; readonly rpcURL: string }): void {
const { network, rpcURL } = options;
this.mutableProviders[network] = new NEOONEDataProvider({ network, rpcURL });
const networks = this.networksInternal$.value.filter((net) => network !== net).concat([network]);
this.networksInternal$.next(networks);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ export class LocalUserAccountProvider<TKeyStore extends KeyStore, TProvider exte
protected readonly mutableUsedOutputs: Set<string>;
protected mutableBlockCount: number;

public constructor({ keystore, provider }: { readonly keystore: TKeyStore; readonly provider: TProvider }) {
public constructor(constructorOptions: { readonly keystore: TKeyStore; readonly provider: TProvider }) {
const { keystore, provider } = constructorOptions;
this.keystore = keystore;
this.provider = provider;

Expand Down
2 changes: 1 addition & 1 deletion packages/neo-one-node-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@types/levelup": "^3.1.0",
"@types/memdown": "^3.0.0",
"level-js": "^4.0.0",
"levelup": "^3.1.1",
"levelup": "^4.0.0",
"memdown": "^3.0.0",
"rxjs": "^6.3.3",
"tslib": "^1.9.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/neo-one-node-storage-levelup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"@neo-one/node-storage-common": "^1.0.1",
"@neo-one/types": "^1.0.1",
"@neo-one/utils": "^1.0.1",
"levelup": "^3.1.1",
"levelup": "^4.0.0",
"rxjs": "^6.3.3",
"tslib": "^1.9.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/neo-one-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@types/node-cron": "^2.0.0",
"abstract-leveldown": "^6.0.0",
"leveldown": "^4.0.1",
"levelup": "^3.1.1",
"levelup": "^4.0.0",
"node-cron": "^2.0.3",
"rxjs": "^6.3.3",
"tslib": "^1.9.3"
Expand Down
2 changes: 1 addition & 1 deletion packages/neo-one-smart-contract-compiler/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"@types/memdown": "3.0.0",
"app-root-dir": "1.0.2",
"bignumber.js": "8.0.1",
"levelup": "3.1.1",
"levelup": "4.0.0",
"memdown": "3.0.0"
},
"sideEffects": false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const { useState } = React;
const ReferenceLayout = styled(Box)`
display: grid;
min-width: 0;
grid-template-columns: repeat(auto-fill, 240px);
grid-template-columns: repeat(auto-fill, 400px);
grid-gap: 8px;
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ const IconBox = styled(Box)<{ readonly bg: TypeFilterOptions; readonly fullIcon:
background-color: ${switchProp('bg', {
All: 'transparent',
Class: prop('theme.primary'),
Const: prop('theme.secondary'),
Function: prop('theme.accent'),
Interface: prop('theme.error'),
Enum: prop('theme.warning'),
Decorator: prop('theme.gray3'),
'Type Alias': prop('theme.gray6'),
Const: prop('theme.gray6'),
Function: prop('theme.warning'),
Interface: prop('theme.accent'),
Enum: prop('theme.gray3'),
Decorator: prop('theme.error'),
'Type Alias': prop('theme.secondary'),
})};
color: ${switchProp(
'bg',
Expand Down
40 changes: 30 additions & 10 deletions packages/neo-one-website/src/components/reference/common/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,51 @@ import { Prism } from '../../../common';
import { RouterLink } from '../../RouterLink';
import { WordTokens } from '../types';

const ReferenceLink = styled(Link.withComponent(RouterLink))<{ readonly code?: boolean }>`
const PUNCTUATION: ReadonlyArray<string> = ['.', ',', '(', ')', '[', ']', '{', '}', '<', '>', ';', ':'];

const checkPunctuation = (idx: number, example: WordTokens, value: string) =>
PUNCTUATION.includes(value) || (idx !== example.length - 1 && PUNCTUATION.includes(example[idx + 1].value))
? `${value}`
: `${value} `;

const StyledReferenceLink = styled(Link.withComponent(RouterLink))<{ readonly code?: boolean }>`
font-family: ${ifProp('code', "Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace")};
${ifProp('code', prop('theme.fontStyles.subheading'))};
${prop('theme.fontStyles.subheading')};
`;

interface Props {
readonly to: string;
readonly value: string;
readonly idx: number;
readonly example: WordTokens;
readonly code?: boolean;
}

const ReferenceLink = ({ to, value, idx, example, code = false, ...props }: Props) => (
<StyledReferenceLink to={to} linkColor="accent" code={code} key={idx} {...props}>
{checkPunctuation(idx, example, value)}
</StyledReferenceLink>
);

export const buildExample = (example: WordTokens) =>
example.map((token, idx) =>
token.slug === undefined ? (
<span key={idx}>
{new Parser().parse(Prism.highlight(`${token.value} `, Prism.languages.typescript, 'typescript'), 'text/xml')}
{new Parser().parse(
Prism.highlight(checkPunctuation(idx, example, token.value), Prism.languages.typescript, 'typescript'),
'text/xml',
)}
</span>
) : (
<ReferenceLink to={token.slug} linkColor="accent" code key={idx}>
{`${token.value} `}
</ReferenceLink>
<ReferenceLink to={token.slug} code idx={idx} value={token.value} example={example} />
),
);

export const buildText = (example: WordTokens) =>
example.map((token, idx) =>
token.slug === undefined ? (
<span key={idx}>{`${token.value} `}</span>
<span key={idx}>{checkPunctuation(idx, example, token.value)}</span>
) : (
<ReferenceLink to={token.slug} linkColor="accent" key={idx}>
{`${token.value} `}
</ReferenceLink>
<ReferenceLink to={token.slug} idx={idx} value={token.value} example={example} />
),
);
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// tslint:disable no-null-keyword
import { Box } from '@neo-one/react-common';
import * as React from 'react';
import styled from 'styled-components';
Expand All @@ -21,7 +22,7 @@ interface Props {

export const Extra = ({ data, ...props }: Props) => (
<Wrapper {...props}>
{data.title === undefined ? undefined : <Title>{data.title}</Title>}
{data.title === undefined ? null : <Title>{data.title}</Title>}
{data.code ? <Example example={data.data} /> : <Text text={data.data} />}
</Wrapper>
);
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// tslint:disable no-null-keyword
import { Box } from '@neo-one/react-common';
import _ from 'lodash';
import * as React from 'react';
import styled from 'styled-components';
import { prop } from 'styled-tools';
Expand All @@ -24,15 +26,18 @@ const Wrapper = styled(Box)`

export const InterfaceClassItems = ({ data, ...props }: Props) => (
<Wrapper {...props}>
{data.constructorDefinition === undefined ? (
undefined
) : (
{data.constructorDefinition === undefined ? null : (
<Wrapper>
<Title>Constructor</Title>
<MethodItem method={data.constructorDefinition} />
</Wrapper>
)}
{data.properties === undefined ? undefined : <ParameterPropertyList values={data.properties} title="Properties" />}
{data.methods === undefined ? undefined : <MethodList methods={data.methods} />}
{data.properties === undefined || _.isEmpty(data.properties) ? null : (
<ParameterPropertyList values={data.properties} title="Properties" />
)}
{data.staticMethods === undefined || _.isEmpty(data.staticMethods) ? null : (
<MethodList methods={data.staticMethods} staticMethods />
)}
{data.methods === undefined || _.isEmpty(data.methods) ? null : <MethodList methods={data.methods} />}
</Wrapper>
);
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
// tslint:disable no-null-keyword
import { Box } from '@neo-one/react-common';
import * as React from 'react';
import styled from 'styled-components';
import { prop } from 'styled-tools';
import { Example, Text, Title } from '../common';
import { Method } from '../types';
import { Extra } from './Extra';
import { ParameterReturns } from './ParameterReturns';

export interface Props {
Expand Down Expand Up @@ -43,9 +45,10 @@ export const MethodItem = ({ method, ...props }: Props) => (
<Layout {...props}>
<StyledTitle subheading>{method.title}</StyledTitle>
<Wrapper>
{method.description === undefined ? undefined : <Text text={method.description} />}
{method.description === undefined ? null : <Text text={method.description} />}
<Example example={method.definition} />
<ParameterReturns functionData={method.functionData} subheading />
{method.extra === undefined ? null : method.extra.map((extra) => <Extra data={extra} key={extra.title} />)}
</Wrapper>
</Layout>
);
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ const ParameterLayout = styled(Box)`

interface Props {
readonly methods: ReadonlyArray<Method>;
readonly staticMethods?: boolean;
}

export const MethodList = ({ methods, ...props }: Props) => (
export const MethodList = ({ methods, staticMethods, ...props }: Props) => (
<ParameterLayout {...props}>
<Title>Methods</Title>
<Title>{staticMethods ? 'Static Methods' : 'Methods'}</Title>
{methods.map((method) => (
<MethodItem key={method.title} method={method} />
))}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// tslint:disable no-null-keyword
import { Box } from '@neo-one/react-common';
import * as React from 'react';
import styled from 'styled-components';
Expand Down Expand Up @@ -27,7 +28,7 @@ interface Props {
export const ParameterPropertyItem = ({ value, ...props }: Props) => (
<ParameterLayout {...props}>
<Name>{value.name}</Name>
{value.type === undefined ? undefined : <Text text={value.type} />}
{value.type === undefined ? null : <Text text={value.type} />}
<Text text={value.description} />
</ParameterLayout>
);
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// tslint:disable no-null-keyword
import { Box } from '@neo-one/react-common';
import _ from 'lodash';
import * as React from 'react';
import styled from 'styled-components';
import { prop } from 'styled-tools';
Expand All @@ -23,14 +25,10 @@ const Wrapper = styled(Box)`

export const ParameterReturns = ({ functionData, subheading, ...props }: Props) => (
<Wrapper {...props}>
{functionData.parameters === undefined ? (
undefined
) : (
{functionData.parameters === undefined || _.isEmpty(functionData.parameters) ? null : (
<ParameterPropertyList values={functionData.parameters} title="Parameters" subheading={subheading} />
)}
{functionData.returns === undefined ? (
undefined
) : (
{functionData.returns === undefined || _.isEmpty(functionData.returns) ? null : (
<TextSection title="Returns" text={functionData.returns} subheading={subheading} />
)}
</Wrapper>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// tslint:disable no-null-keyword
import { Box } from '@neo-one/react-common';
import * as React from 'react';
import styled from 'styled-components';
Expand Down Expand Up @@ -25,14 +26,13 @@ const PageLayout = styled(Box)`
export const ReferencePage = ({ content, ...props }: Props) => (
<PageLayout {...props}>
<ReferenceHeader type={content.type} description={content.description} definition={content.definition} />
{content.functionData === undefined ? undefined : <ParameterReturns functionData={content.functionData} />}
{content.classData === undefined ? undefined : <InterfaceClassItems data={content.classData} />}
{content.enumData === undefined ? (
undefined
) : (
{content.functionData === undefined ? null : <ParameterReturns functionData={content.functionData} />}
{content.classData === undefined ? null : <InterfaceClassItems data={content.classData} />}
{content.enumData === undefined ? null : (
<ParameterPropertyList values={content.enumData.members} title="Members" />
)}
{content.interfaceData === undefined ? undefined : <InterfaceClassItems data={content.interfaceData} />}
{content.extra === undefined ? undefined : content.extra.map((extra) => <Extra data={extra} key={extra.title} />)}
{content.constData === undefined ? null : <InterfaceClassItems data={content.constData} />}
{content.interfaceData === undefined ? null : <InterfaceClassItems data={content.interfaceData} />}
{content.extra === undefined ? null : content.extra.map((extra) => <Extra data={extra} key={extra.title} />)}
</PageLayout>
);
Loading

0 comments on commit 63b31b7

Please sign in to comment.