1
0
mirror of https://github.com/oceanprotocol/docs.git synced 2024-11-26 19:49:26 +01:00
docs/README.md

356 lines
14 KiB
Markdown
Raw Normal View History

2018-11-09 22:59:22 +01:00
[![banner](https://raw.githubusercontent.com/oceanprotocol/art/master/github/repo-banner%402x.png)](https://docs.oceanprotocol.com)
2018-11-07 11:25:05 +01:00
<h1 align="center">docs</h1>
> 🐍 Ocean Protocol's official documentation.
2018-11-07 11:25:05 +01:00
[![Build Status](https://travis-ci.com/oceanprotocol/docs.svg?token=3psqw6c8KMDqfdGQ2x6d&branch=master)](https://travis-ci.com/oceanprotocol/docs)
2018-11-07 12:24:53 +01:00
[![js oceanprotocol](https://img.shields.io/badge/js-oceanprotocol-7b1173.svg)](https://github.com/oceanprotocol/eslint-config-oceanprotocol)
2018-11-10 15:04:16 +01:00
[![css bigchaindb](https://img.shields.io/badge/css-bigchaindb-39BA91.svg)](https://github.com/bigchaindb/stylelint-config-bigchaindb)
2018-11-07 12:24:53 +01:00
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-7b1173.svg?style=flat-square)](https://github.com/prettier/prettier)
2018-11-07 13:05:13 +01:00
[![Greenkeeper badge](https://badges.greenkeeper.io/oceanprotocol/docs.svg?token=2757ede2de02f4679c4dfc6597a331a26f2f206fed53bfeb708c64cbe3d5f55f&ts=1541590505792)](https://greenkeeper.io/)
2018-11-07 12:24:53 +01:00
---
2018-11-09 12:46:43 +01:00
**These docs are meant to be viewed on [docs.oceanprotocol.com](https://docs.oceanprotocol.com). You can still browse them here but links or images might not work in some places.**
2018-11-11 11:25:14 +01:00
**If you want to contribute to these docs, then keep reading.**
2018-11-11 04:02:34 +01:00
2018-11-09 12:46:43 +01:00
---
2018-11-07 11:25:05 +01:00
- [Content](#content)
2018-11-11 11:32:47 +01:00
- [Content Files](#content-files)
2018-11-15 16:17:26 +01:00
- [External Content Files](#external-content-files)
2018-11-11 11:25:14 +01:00
- [Markdown File Requirements](#markdown-file-requirements)
2018-11-11 11:32:47 +01:00
- [Adding Docs](#adding-docs)
- [Editing Docs](#editing-docs)
2018-11-11 11:25:14 +01:00
- [Repositories](#repositories)
2018-11-07 11:25:05 +01:00
- [Development](#development)
- [Using npm](#using-npm)
- [Using Docker](#use-docker)
- [Linting & Formatting](#linting--formatting)
- [Editor Setup: VS Code](#editor-setup-vs-code)
- [GitHub GraphQL API](#github-graphql-api)
2018-11-16 11:12:28 +01:00
- [Deployment](#deployment)
2018-11-07 11:25:05 +01:00
- [Authors](#authors)
- [License](#license)
## Content
2018-11-11 04:02:34 +01:00
The documentation is split in multiple sections whose content lives in this repo:
2018-11-07 11:25:05 +01:00
2018-11-11 11:25:14 +01:00
- **Core concepts**: high-level explanation of concepts, assumptions, and components
- **Setup**: getting started for various stakeholders and use cases
- **Tutorials**: detailed tutorials
2018-11-11 04:02:34 +01:00
Those sections are defined in the [`/data/sections.yml`](data/sections.yml) file.
2018-11-11 11:25:14 +01:00
### Content Files
2018-11-11 11:25:14 +01:00
Some content files live in the [`/content`](content/) & [`/data`](data/) folders, and is written using Markdown and YAML.
2018-11-15 16:17:26 +01:00
That content is organized into subfolders corresponding to the sections mentioned above. The subfolder names, along with the filenames, define the final URL of a given piece of content.
2018-11-11 11:25:14 +01:00
The final navigational organization of the content is driven through the sidebar files under [`/data/sidebars`](data/sidebars/).
2018-11-15 16:17:26 +01:00
2018-11-11 11:25:14 +01:00
Some global values used throughout the site can be set in [`config.js`](config.js).
2018-11-07 12:24:53 +01:00
2018-11-15 16:17:26 +01:00
#### External Content Files
Additionally, some content files live in other repositories and are maintained there. They are pulled into the site at build time.
At the moment, this is setup for the following repositories:
- [dev-ocean](https://github.com/oceanprotocol/dev-ocean)
For including a document from any of the above repositories, 4 values are required in a document's YAML frontmatter. If found, a page will be generated automatically, accessible under the defined `slug`.
This will NOT include this page in the doc's sidebar navigation, this needs to be done manually in the docs repo in one of the sidebar files. This is so you can check out everything before exposing it to visitors, and to ensure editorial workflow of the categorization.
TODO: In a later stage, we will include more documentation in this site, e.g.:
2018-11-11 11:25:14 +01:00
- API references
- Component docs
- Maybe more
### Markdown File Requirements
All Markdown files should use
2018-11-15 16:17:26 +01:00
[GitHub Flavored Markdown](https://help.github.com/articles/about-writing-and-formatting-on-github/) and must satisfy some extra requirements:
2018-11-11 11:25:14 +01:00
2018-11-15 16:17:26 +01:00
1. The file must begin with a section called YAML frontmatter that looks like this:
2018-11-11 11:25:14 +01:00
2018-11-16 13:49:46 +01:00
```md
---
2018-11-15 16:17:26 +01:00
title: This is the Title in Title Case
description: A short description of the page.
2018-11-11 11:25:14 +01:00
---
2018-11-16 13:49:46 +01:00
2018-11-15 16:17:26 +01:00
Markdown content begins here.
```
For external documents in other repos, defining the `slug` and `section` is required:
2018-11-16 13:49:46 +01:00
```md
---
2018-11-11 11:25:14 +01:00
title: This is the Title in Title Case
description: A short description of the page.
2018-11-15 16:17:26 +01:00
slug: /concepts/architecture/
section: concepts
2018-11-11 11:25:14 +01:00
---
2018-11-16 13:49:46 +01:00
2018-11-11 11:25:14 +01:00
Markdown content begins here.
```
2018-11-15 16:17:26 +01:00
Note: The `description` value will be rendered on-page below the title, and it will also be used for description tags in the HTML head.
2018-11-12 12:45:10 +01:00
2018-11-15 16:17:26 +01:00
2. Don't include the page title or description in the Markdown section. That is, don't begin the Markdown content with `# This is the Title in Title Case`. Just write as if that were already there.
3. start your heading levels with `h2`, so `## My heading`
4. Internal links to other docs pages should be:
- to a absolute URL without the host, that looks like `/concepts/terminology/` with slashes on the beginning and end, and with no `.md` or `.html` at the end (before the last slash).
2018-11-16 13:49:46 +01:00
- when linking from external repos, to the _full absolute URL_, such as `https://docs.oceanprotocol.com/hello/you-are-awesome/`
2018-11-15 16:17:26 +01:00
5. no TOC please, this will be generated automatically from all headings
6. for images and media, you can keep them in the original repo. Images will be automatically grabbed by the docs site on querying. When doing that, docs site will generate all sorts of image sizes to handle proper responsive images, so no need to keep an eye on image dimensions or file sizes
2018-11-07 12:24:53 +01:00
2018-11-15 16:17:26 +01:00
**Have a look at [docs.oceanprotocol.com/test/](https://docs.oceanprotocol.com/test/) to see what content elements can be used in all markdown files included in docs site.**
2018-11-11 11:25:14 +01:00
### Adding Docs
2018-11-07 12:24:53 +01:00
2018-11-11 11:25:14 +01:00
1. Add new Markdown file under one of the folders under [`/content`](content/)
2. Add new path to one of the sidebars in [`/data/sidebars`](data/sidebars/)
3. ...
2018-11-07 12:24:53 +01:00
2018-11-11 11:25:14 +01:00
### Editing Docs
2018-11-07 11:25:05 +01:00
2018-11-10 21:08:10 +01:00
Every article on [docs.oceanprotocol.com](https://docs.oceanprotocol.com) ends with an _Edit this page on GitHub_ link. Clicking that will put you to the right place in the repository from where you can hit the _Edit_ pencil icon on GitHub.
GitHub will automatically fork the repository if you are not part of the `oceanprotocol` organisation on GitHub. Members can simply push to a new branch on the original repo.
The editing workflow is as follows:
1. Make your changes
2. Push your changes to a new branch in the repo, or in your fork
3. Open a pull request against `master`, automatically asking for review
2018-11-10 21:08:10 +01:00
4. Wait for review, possibly make requested changes
5. Wait for all checks to pass
6. Merge!
### Repositories
The repositories list is currently sourced from the [`/data/repositories.yml`](data/repositories.yml) file, defining the grouping, the display order, and which repos to include.
2018-11-10 21:08:10 +01:00
Including a repo requires only the `name` key and value, and it needs to be exactly the same as the repo name on GitHub:
```yaml
2018-11-10 22:21:04 +01:00
- name: pleuston
```
2018-11-10 21:08:10 +01:00
Additional information about a repo will then be fetched automatically via [GitHub's GraphQL API](https://developer.github.com/v4/) on build time, and re-fetched every 5 minutes on client side. You can also add a private repo to prepare for a release, it will show up as soon as it is made public on GitHub.
The above example will result in:
<img width="547" alt="screen shot 2018-11-10 at 22 43 41" src="https://user-images.githubusercontent.com/90316/48306511-164fea00-e53a-11e8-97d6-c481ea087c7d.png">
2018-11-10 21:08:10 +01:00
2018-11-11 04:02:34 +01:00
This repository component can also be used within any Markdown content like so:
2018-11-11 11:25:14 +01:00
```html
2018-11-11 04:02:34 +01:00
<repo name="pleuston"></repo>
```
2018-11-10 22:21:04 +01:00
Additionally, you can attach multiple links to a repo. The GitHub link is automatically added for every repository and will always be displayed. Add more links like so:
```yaml
- name: keeper-contracts
links:
2018-11-12 12:39:11 +01:00
- name: Documentation
url: https://github.com/oceanprotocol/keeper-contracts/tree/develop/doc
```
2018-11-11 11:25:14 +01:00
in [`/data/repositories.yml`](data/repositories.yml).
2018-11-07 11:25:05 +01:00
## Development
2018-11-11 11:25:14 +01:00
The site is a React app built with [Gatsby](https://www.gatsbyjs.org).
2018-11-07 12:24:53 +01:00
This Git repo has [Git submodules](https://git-scm.com/book/en/v2/Git-Tools-Submodules). They are the subdirectories of `external/`. Each one is basically another Git repo, i.e. an external Git repo that just _looks_ like it's part of this Git repo. It's very easy to get Git into a confusing state when there are submodules. If you follow the following tips, you should probably be okay:
1. Clone this repo using:
```bash
git clone --recurse-submodules git@github.com:oceanprotocol/docs.git
```
1. Don't edit anything in the submodules (i.e. in `external/`). Instead, edit it over in the other Git repository and merge your changes over there.
1. Get all the submodules up-to-date using:
```bash
git submodule update --remote --recursive
```
That will get each submodule up-to-date with the HEAD commit of some branch in a remote repository. Which branch? That's set in the `.gitmodules` file. You can check the current commit hashes of all the submodules using `git submodule status`
1. Before doing any `git checkout ...` or other normal Git operations, do this:
```bash
git config --global submodule.recurse true
```
That's like adding the `--recurse-submodules` option to all those Git commands (except for `git clone`) so you don't have to.
### Using npm
As a prerequisite, you'll need the following on your machine:
2018-11-10 14:47:09 +01:00
2018-11-11 11:25:14 +01:00
- Node.js
- npm
- Your `GITHUB_TOKEN`, see [GitHub GraphQL API](#github-graphql-api)
2018-11-10 14:47:09 +01:00
Clone this repo, install all dependencies, and start the development server:
2018-11-07 12:24:53 +01:00
2018-11-07 11:25:05 +01:00
```bash
git clone --recurse-submodules git@github.com:oceanprotocol/docs.git
2018-11-07 12:24:53 +01:00
cd docs/
2018-11-11 04:02:34 +01:00
# add GITHUB_TOKEN
cp .env.sample .env
vi .env
2018-11-07 11:25:05 +01:00
npm i
npm start
```
2018-11-07 12:24:53 +01:00
This will start a hot-reloading local server exposed under [localhost:8000](http://localhost:8000).
### Using Docker
2018-11-10 14:47:09 +01:00
Alternatively, you can use Docker for which you need to have installed on your machine:
2018-11-11 11:25:14 +01:00
- [Docker](https://www.docker.com)
- [Docker Compose](https://docs.docker.com/compose/)
- Your `GITHUB_TOKEN`, see [GitHub GraphQL API](#github-graphql-api)
2018-11-10 14:47:09 +01:00
2018-11-11 11:25:14 +01:00
Then use Docker Compose to bring everything up:
2018-11-10 14:47:09 +01:00
```bash
git clone --recurse-submodules git@github.com:oceanprotocol/docs.git
cd docs/
# add GITHUB_TOKEN
cp .env.sample .env
vi .env
2018-11-10 14:47:09 +01:00
docker-compose up
```
This will expose a hot-reloading server under [localhost:8000](http://localhost:8000).
## Linting & Formatting
2018-11-12 12:39:11 +01:00
To enforce a consistent code style, linting is setup for pretty much every file. Linting is part of the test suite, meaning builds on Travis will fail in case of linting errors.
In this repo the following tools are setup for that:
2018-11-12 12:45:10 +01:00
- ESLint with [eslint-config-oceanprotocol](https://github.com/oceanprotocol/eslint-config-oceanprotocol)
- Stylelint with [stylelint-config-bigchaindb](https://github.com/bigchaindb/stylelint-config-bigchaindb)
2018-11-12 12:39:11 +01:00
- [markdownlint](https://github.com/DavidAnson/markdownlint)
- [Prettier](https://prettier.io)
```bash
# only run linting checks
npm run lint
# auto-formatting of all js, css, md, yml files
npm run format
```
### Editor Setup: VS Code
2018-11-12 13:00:41 +01:00
If you use VS Code as your editor, you can install those extensions to get linting as you type, and auto-formatting as you save:
- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint)
- [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)
- [stylelint](https://marketplace.visualstudio.com/items?itemName=shinnn.stylelint)
- [markdownlint](https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint)
## GitHub GraphQL API
The GitHub GraphQL API integration is done through [gatsby-source-graphql](https://www.gatsbyjs.org/packages/gatsby-source-graphql/) and requires authorization.
An environment variable `GITHUB_TOKEN` needs to present, filled with a [personal access token](https://github.com/settings/tokens) with the scope `public_repo`.
2018-11-10 21:08:10 +01:00
For local development, you can simply [create a personal access token](https://github.com/settings/tokens) and use it in your local .env file:
```bash
2018-11-11 01:32:05 +01:00
cp .env.sample .env
vi .env
2018-11-11 04:02:34 +01:00
# GITHUB_TOKEN=add_your_token_here
```
2018-11-10 21:08:10 +01:00
When running the site locally, you can use the GraphiQL client running under [localhost:8000/\_\_\_graphql](http://localhost:8000/___graphql) to explore the whole GraphQL layer of the site (not just the GitHub infos).
2018-11-10 19:27:27 +01:00
<img width="982" alt="screen shot 2018-11-10 at 18 41 45" src="https://user-images.githubusercontent.com/90316/48304718-66b94e80-e51e-11e8-8333-e5cadbf4d4b8.png">
2018-11-10 21:08:10 +01:00
This query should get you started to explore what information you can get from GitHub:
2018-11-10 19:27:27 +01:00
```graphql
query {
2018-11-12 12:39:11 +01:00
github {
organization(login: "oceanprotocol") {
repositories(first: 100) {
edges {
node {
name
description
url
}
2018-11-10 19:27:27 +01:00
}
2018-11-12 12:39:11 +01:00
}
2018-11-10 19:27:27 +01:00
}
2018-11-12 12:39:11 +01:00
}
2018-11-10 19:27:27 +01:00
}
```
2018-11-16 11:12:28 +01:00
## Deployment
Automatic deployments are triggered upon successful tests & builds on Travis:
- push to `master` initiates a live deployment
2018-11-16 12:55:41 +01:00
-> [docs.oceanprotocol.com](https://docs.oceanprotocol.com)
2018-11-16 11:12:28 +01:00
- any Pull Request, and subsequent pushes to it, initiates a beta deployment
2018-11-16 17:39:13 +01:00
-> [betadocs.oceanprotocol.com](https://betadocs.oceanprotocol.com)
2018-11-16 11:12:28 +01:00
The deploy command simply calls the [`scripts/deploy.sh`](scripts/deploy.sh) script, syncing the contents of the `public/` folder to S3:
```bash
npm run deploy
```
Requires authorization against AWS with [one of the various ways](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-credentials-node.html), on Travis this is done with those environment variables:
- `AWS_ACCESS_KEY_ID`
- `AWS_SECRET_ACCESS_KEY`
- `AWS_DEFAULT_REGION`
2018-11-07 11:25:05 +01:00
## Authors
2018-11-11 11:25:14 +01:00
- Troy McConaghy ([@ttmc](https://github.com/ttmc)) - [Ocean Protocol](https://oceanprotocol.com)
- Matthias Kretschmann ([@kremalicious](https://github.com/kremalicious)) - [Ocean Protocol](https://oceanprotocol.com)
2018-11-07 11:25:05 +01:00
## License
2018-11-11 11:25:14 +01:00
```text
2018-11-07 11:25:05 +01:00
Copyright 2018 Ocean Protocol Foundation Ltd.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
2018-11-07 12:24:53 +01:00
```