forked from ViacomInc/data-point
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(data-point): Add versioning in Docusaurus
Added versioning support using Docusaurus 'version' command. Added version 6.x-canary. Added temporary DataPoint logo. Changed primary color to Viacom's blue. Closes ViacomInc#413
- Loading branch information
Christian Sarnataro
committed
Sep 3, 2019
1 parent
23cf880
commit aff140a
Showing
24 changed files
with
1,197 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
/** | ||
* Copyright (c) 2017-present, Facebook, Inc. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
const React = require("react"); | ||
|
||
const CompLibrary = require("../../core/CompLibrary"); | ||
|
||
const Container = CompLibrary.Container; | ||
|
||
const CWD = process.cwd(); | ||
|
||
const versions = require(`${CWD}/versions.json`); | ||
|
||
function Versions(props) { | ||
const { config: siteConfig } = props; | ||
const latestVersion = versions[0]; | ||
const repoUrl = `https://github.com/${siteConfig.organizationName}/${siteConfig.projectName}`; | ||
return ( | ||
<div className="docMainWrapper wrapper"> | ||
<Container className="mainContainer versionsContainer"> | ||
<div className="post"> | ||
<header className="postHeader"> | ||
<h1>{siteConfig.title} Versions</h1> | ||
</header> | ||
<h3 id="latest">Current version (Stable)</h3> | ||
<table className="versions"> | ||
<tbody> | ||
<tr> | ||
<th>{latestVersion}</th> | ||
<td> | ||
{/* You are supposed to change this href where appropriate | ||
Example: href="<baseUrl>/docs(/:language)/:id" */} | ||
<a | ||
href={`${siteConfig.baseUrl}${siteConfig.docsUrl}/${ | ||
props.language ? props.language + "/" : "" | ||
}getting-started`} | ||
> | ||
Documentation | ||
</a> | ||
</td> | ||
<td> | ||
<a href="">Release Notes</a> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<p> | ||
This is an unpublish canary version, in progress and expectedly | ||
unstable. You can find the latest stable version on{" "} | ||
<a href={repoUrl}>GitHub</a>. | ||
</p> | ||
{/* | ||
<h3 id="rc">Pre-release versions</h3> | ||
<table className="versions"> | ||
<tbody> | ||
<tr> | ||
<th>master</th> | ||
<td> | ||
{ / * You are supposed to change this href where appropriate | ||
Example: href="<baseUrl>/docs(/:language)/next/:id" * / } | ||
<a | ||
href={`${siteConfig.baseUrl}${siteConfig.docsUrl}/${ | ||
props.language ? props.language + '/' : '' | ||
}next/doc1`}> | ||
Documentation | ||
</a> | ||
</td> | ||
<td> | ||
<a href={repoUrl}>Source Code</a> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
*/} | ||
<p>Other text describing this section.</p> | ||
<h3 id="archive">Past Versions</h3> | ||
<p>Here you can find previous versions of the documentation.</p> | ||
<table className="versions"> | ||
<tbody> | ||
{versions.map( | ||
version => | ||
version !== latestVersion && ( | ||
<tr> | ||
<th>{version}</th> | ||
<td> | ||
{/* You are supposed to change this href where appropriate | ||
Example: href="<baseUrl>/docs(/:language)/:version/:id" */} | ||
<a | ||
href={`${siteConfig.baseUrl}${siteConfig.docsUrl}/${ | ||
props.language ? props.language + "/" : "" | ||
}${version}/getting-started`} | ||
> | ||
Documentation | ||
</a> | ||
</td> | ||
<td> | ||
<a href={`${repoUrl}/releases/tag/v${version}`}> | ||
Release Notes | ||
</a> | ||
</td> | ||
</tr> | ||
) | ||
)} | ||
</tbody> | ||
</table> | ||
<p> | ||
You can find past versions of this project on{" "} | ||
<a href={repoUrl}>GitHub</a>. | ||
</p> | ||
</div> | ||
</Container> | ||
</div> | ||
); | ||
} | ||
|
||
module.exports = Versions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+3.44 KB
(560%)
documentation/website/static/img/favicon.ico
100755 → 100644
Binary file not shown.
20 changes: 20 additions & 0 deletions
20
documentation/website/versioned_docs/version-6.x-canary/api/accumulator.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
id: version-6.x-canary-accumulator | ||
title: Accumulator | ||
sidebar_label: Accumulator | ||
original_id: accumulator | ||
--- | ||
|
||
This object is passed to [reducers](reducer-types.md) and cache callbacks; it has contextual information about the current transformation being resolved. | ||
|
||
Access to the accumulator object is made available through a [FunctionReducer](reducers/function-reducer). | ||
|
||
The `accumulator.value` property is the current **input data** being passed to the reducer. This property should be treated as a **read-only immutable object** which will ensure that your reducers are [pure functions](https://medium.com/javascript-scene/master-the-javascript-interview-what-is-a-pure-function-d1c076bec976#.r4iqvt9f0) that produce no side effects. | ||
|
||
**Properties exposed:** | ||
|
||
| Key | Type | Description | | ||
| :-------- | :------- | :------------------------------------------------------------------------------------------------------------ | | ||
| _value_ | `Object` | Value to be transformed. | | ||
| _locals_ | `Object` | Value passed from the `options` _argument_ when executing [dataPoint.resolve()](data-point#datapointresolve). | | ||
| _reducer_ | `Object` | Information relative to the current [Reducer](reducer-types.md) being executed. | |
122 changes: 122 additions & 0 deletions
122
documentation/website/versioned_docs/version-6.x-canary/api/basic-examples.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
--- | ||
id: version-6.x-canary-basic-examples | ||
title: Examples | ||
sidebar_label: Examples | ||
original_id: basic-examples | ||
--- | ||
|
||
## Hello World | ||
|
||
Trivial example of transforming a given **input** with a [function reducer](#function-reducer). | ||
|
||
```js | ||
const { DataPoint } = require("data-point"); | ||
|
||
const sayHello = input => { | ||
return `${input} World`; | ||
}; | ||
|
||
const dataPoint = DataPoint(); | ||
|
||
dataPoint.resolve("Hello", reducer).then(output => { | ||
// 'Hello World' | ||
console.log(output); | ||
}); | ||
``` | ||
|
||
## Fetching and agregation | ||
|
||
Based on an initial feed, fetch and aggregate results from multiple remote services. | ||
|
||
```js | ||
const DataPoint = require("data-point"); | ||
|
||
// create DataPoint instance | ||
const dataPoint = DataPoint.create(); | ||
|
||
const { Request, Model, Schema, map } = DataPoint; | ||
|
||
// schema to verify data input | ||
const PlanetSchema = Schema("PlanetSchema", { | ||
schema: { | ||
type: "object", | ||
properties: { | ||
planetId: { | ||
$id: "/properties/planet", | ||
type: "integer" | ||
} | ||
} | ||
} | ||
}); | ||
|
||
// remote service request | ||
const PlanetRequest = Request("Planet", { | ||
// {value.planetId} injects the | ||
// value from the accumulator | ||
// creates: https://swapi.co/api/planets/1/ | ||
url: "https://swapi.co/api/planets/{value.planetId}" | ||
}); | ||
|
||
const ResidentRequest = Request("Resident", { | ||
// check input is string | ||
inputType: "string", | ||
url: "{value}" | ||
}); | ||
|
||
// model entity to resolve a Planet | ||
const ResidentModel = Model("Resident", { | ||
inputType: "string", | ||
value: [ | ||
// hit request:Resident | ||
ResidentRequest, | ||
// extract data | ||
{ | ||
name: "$name", | ||
gender: "$gender", | ||
birthYear: "$birth_year" | ||
} | ||
] | ||
}); | ||
|
||
// model entity to resolve a Planet | ||
const PlanetModel = Model("Planet", { | ||
inputType: PlanetSchema, | ||
value: [ | ||
// hit request:Planet data source | ||
PlanetRequest, | ||
// map result to an object reducer | ||
{ | ||
// map name key | ||
name: "$name", | ||
population: "$population", | ||
// residents is an array of urls | ||
// eg. https://swapi.co/api/people/1/ | ||
// where each url gets mapped | ||
// to a model:Resident | ||
residents: ["$residents", map(ResidentModel)] | ||
} | ||
] | ||
}); | ||
|
||
const input = { | ||
planetId: 1 | ||
}; | ||
|
||
dataPoint.resolve(PlanetModel, input).then(output => { | ||
console.log(output); | ||
/* | ||
output -> | ||
{ | ||
name: 'Tatooine', | ||
population: 200000, | ||
residents: | ||
[ | ||
{ name: 'Luke Skywalker', gender: 'male', birthYear: '19BBY' }, | ||
{ name: 'C-3PO', gender: 'n/a', birthYear: '112BBY' }, | ||
{ name: 'Darth Vader', gender: 'male', birthYear: '41.9BBY' }, | ||
... | ||
] | ||
} | ||
*/ | ||
}); | ||
``` |
Oops, something went wrong.