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

Merge pull request #13 from oceanprotocol/feature/markdownlint

Linting and auto-formatting for everything
This commit is contained in:
Matthias Kretschmann 2018-11-12 13:22:33 +01:00 committed by GitHub
commit e8e9fe2759
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 188 additions and 165 deletions

View File

@ -8,5 +8,5 @@ indent_style = space
insert_final_newline = true insert_final_newline = true
trim_trailing_whitespace = true trim_trailing_whitespace = true
[*.{json,yml,yaml}] [*.{json,yml,yaml,md}]
indent_size = 2 indent_size = 2

14
.markdownlint.json Normal file
View File

@ -0,0 +1,14 @@
{
"default": true,
"whitespace": false,
"line-length": false,
"ul-start-left": false,
"ul-indent": false,
"no-inline-html": false,
"no-bare-urls": false,
"first-line-h1": false,
"first-heading-h1": false,
"no-trailing-punctuation": false,
"ol-prefix": false,
"ul-style": { "style": "dash" }
}

3
.prettierignore Normal file
View File

@ -0,0 +1,3 @@
node_modules
public
.cache

View File

@ -26,6 +26,8 @@
- [Repositories](#repositories) - [Repositories](#repositories)
- [Development](#development) - [Development](#development)
- [Use Docker](#use-docker) - [Use Docker](#use-docker)
- [Linting & formatting](#linting--formatting)
- [Editor setup: VS Code](#editor-setup-vs-code)
- [GitHub GraphQL API](#github-graphql-api) - [GitHub GraphQL API](#github-graphql-api)
- [Authors](#authors) - [Authors](#authors)
- [License](#license) - [License](#license)
@ -71,6 +73,7 @@ and must satisfy some extra requirements:
``` ```
Note: The `description` value will be rendered on-page below the title, and it will also be used for description tags in the HTML header. Note: The `description` value will be rendered on-page below the title, and it will also be used for description tags in the HTML header.
1. 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. 1. 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.
1. Internal links to other docs pages should be: 1. Internal links to other docs pages should be:
- to the _full absolute URL_, such as https://docs.oceanprotocol.com/hello/you-are-awesome/ or https://github.com/oceanprotocol/dev-ocean/blob/master/doc/development/style-guides.md or - to the _full absolute URL_, such as https://docs.oceanprotocol.com/hello/you-are-awesome/ or https://github.com/oceanprotocol/dev-ocean/blob/master/doc/development/style-guides.md or
@ -175,6 +178,34 @@ docker-compose up
This will expose a hot-reloading server under [localhost:8000](http://localhost:8000). This will expose a hot-reloading server under [localhost:8000](http://localhost:8000).
## Linting & formatting
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:
- ESLint with [eslint-config-oceanprotocol](https://github.com/oceanprotocol/eslint-config-oceanprotocol)
- Stylelint with [stylelint-config-bigchaindb](https://github.com/bigchaindb/stylelint-config-bigchaindb)
- [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
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 ## 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. The GitHub GraphQL API integration is done through [gatsby-source-graphql](https://www.gatsbyjs.org/packages/gatsby-source-graphql/) and requires authorization.

View File

@ -8,5 +8,3 @@ See the page about the [Ocean network components](/concepts/components/).
See the (somewhat-dated) diagram on the page https://github.com/oceanprotocol/dev-ocean/blob/master/doc/architecture.md See the (somewhat-dated) diagram on the page https://github.com/oceanprotocol/dev-ocean/blob/master/doc/architecture.md
![Ocean Protocol Components](images/components.png 'Ocean Protocol Components') ![Ocean Protocol Components](images/components.png 'Ocean Protocol Components')

View File

@ -7,23 +7,23 @@ For more complete info, see [John Gruber's original spec](http://daringfireball.
## Table of Contents ## Table of Contents
* [Headers](#headers) - [Headers](#headers)
* [Emphasis](#emphasis) - [Emphasis](#emphasis)
* [Lists](#lists) - [Lists](#lists)
* [Links](#links) - [Links](#links)
* [Images](#images) - [Images](#images)
* [Code and Syntax Highlighting](#code-and-syntax-highlighting) - [Code and Syntax Highlighting](#code-and-syntax-highlighting)
* [Tables](#tables) - [Tables](#tables)
* [Blockquotes](#blockquotes) - [Blockquotes](#blockquotes)
* [Inline HTML](#inline-html) - [Inline HTML](#inline-html)
* [Horizontal Rule](#horizontal-rule) - [Horizontal Rule](#horizontal-rule)
* [Line Breaks](#line-breaks) - [Line Breaks](#line-breaks)
* [Videos](#videos) - [Videos](#videos)
* [React Components in Markdown](#react-components-in-markdown) - [React Components in Markdown](#react-components-in-markdown)
## Headers ## Headers
``` ```text
# H1 # H1
## H2 ## H2
### H3 ### H3
@ -32,14 +32,18 @@ For more complete info, see [John Gruber's original spec](http://daringfireball.
``` ```
# H1 # H1
## H2 ## H2
### H3 ### H3
#### H4 #### H4
##### H5 ##### H5
## Emphasis ## Emphasis
``` ```text
Emphasis, aka italics, with *asterisks* or _underscores_. Emphasis, aka italics, with *asterisks* or _underscores_.
Strong emphasis, aka bold, with **asterisks** or __underscores__. Strong emphasis, aka bold, with **asterisks** or __underscores__.
@ -49,9 +53,9 @@ Combined emphasis with **asterisks and _underscores_**.
Strikethrough uses two tildes. ~~Scratch this.~~ Strikethrough uses two tildes. ~~Scratch this.~~
``` ```
Emphasis, aka italics, with *asterisks* or _underscores_. Emphasis, aka italics, with _asterisks_ or _underscores_.
Strong emphasis, aka bold, with **asterisks** or __underscores__. Strong emphasis, aka bold, with **asterisks** or **underscores**.
Combined emphasis with **asterisks and _underscores_**. Combined emphasis with **asterisks and _underscores_**.
@ -59,38 +63,32 @@ Strikethrough uses two tildes. ~~Scratch this.~~
## Lists ## Lists
``` ```text
1. First ordered list item 1. First ordered list item
2. Another item 2. Another item
* Unordered sub-list. - Unordered sub-list.
1. Actual numbers don't matter, just that it's a number 1. Actual numbers don't matter, just that it's a number
1. Ordered sub-list 1. Ordered sub-list
4. And another item. 4. And another item.
Some text that should be aligned with the above item. Some text that should be aligned with the above item.
* Unordered list can use asterisks
- Or minuses
+ Or pluses
``` ```
1. First ordered list item 1. First ordered list item
2. Another item 2. Another item
* Unordered sub-list. - Unordered sub-list.
1. Actual numbers don't matter, just that it's a number 3. Actual numbers don't matter, just that it's a number
1. Ordered sub-list 1. Ordered sub-list
4. And another item. 4. And another item.
Some text that should be aligned with the above item. Some text that should be aligned with the above item.
* Unordered list can use asterisks
- Or minuses
+ Or pluses
## Links ## Links
There are two ways to create links. There are two ways to create links.
``` ```markdown
[I'm an inline-style link](https://www.google.com) [I'm an inline-style link](https://www.google.com)
[I'm a reference-style link][Arbitrary case-insensitive reference text] [I'm a reference-style link][arbitrary case-insensitive reference text]
[You can use numbers for reference-style link definitions][1] [You can use numbers for reference-style link definitions][1]
@ -109,16 +107,20 @@ Some text to show that the reference links can follow later.
[I'm an inline-style link](https://www.google.com) [I'm an inline-style link](https://www.google.com)
[I'm a reference-style link][Arbitrary case-insensitive reference text] [I'm a reference-style link][arbitrary case-insensitive reference text]
[You can use numbers for reference-style link definitions][1] [You can use numbers for reference-style link definitions][1]
Or leave it empty and use the [link text itself] Or leave it empty and use the [link text itself]
<!-- markdownlint-disable no-bare-urls -->
URLs and URLs in angle brackets will automatically get turned into links. URLs and URLs in angle brackets will automatically get turned into links.
http://www.example.com or <http://www.example.com> and sometimes http://www.example.com or <http://www.example.com> and sometimes
example.com (but not on Github, for example). example.com (but not on Github, for example).
<!-- markdownlint-enable no-bare-urls -->
Some text to show that the reference links can follow later. Some text to show that the reference links can follow later.
[arbitrary case-insensitive reference text]: https://www.mozilla.org [arbitrary case-insensitive reference text]: https://www.mozilla.org
@ -127,20 +129,19 @@ Some text to show that the reference links can follow later.
## Images ## Images
``` ```markdown
![alt text](jellyfish-grid@2x.png "Ocean Protocol Jellyfish") ![alt text](jellyfish-grid@2x.png 'Ocean Protocol Jellyfish')
``` ```
Here's our jellyfish, with the title being output as caption: Here's our jellyfish, with the title being output as caption:
![alt text](../node_modules/@oceanprotocol/art/jellyfish/jellyfish-grid@2x.png "Ocean Protocol Jellyfish") ![alt text](../node_modules/@oceanprotocol/art/jellyfish/jellyfish-grid@2x.png 'Ocean Protocol Jellyfish')
## Code and Syntax Highlighting ## Code and Syntax Highlighting
Code blocks are part of the Markdown spec, but syntax highlighting isn't. However, many renderers -- like Github's and *Markdown Here* -- support syntax highlighting. Code blocks are part of the Markdown spec, but syntax highlighting isn't. However, many renderers -- like Github's and _Markdown Here_ -- support syntax highlighting.
``` ```text
Inline `code` has `back-ticks around` it. Inline `code` has `back-ticks around` it.
``` ```
@ -148,24 +149,6 @@ Inline `code` has `back-ticks around` it.
Blocks of code are either fenced by lines with three back-ticks, or are indented with four spaces. I recommend only using the fenced code blocks -- they're easier and only they support syntax highlighting. Blocks of code are either fenced by lines with three back-ticks, or are indented with four spaces. I recommend only using the fenced code blocks -- they're easier and only they support syntax highlighting.
<pre><code>```js
...
```
```python
...
```
```java
...
```
```
No language indicated, so no syntax highlighting.
But let's throw in a &lt;b&gt;tag&lt;/b&gt;.
```
</code></pre>
```bash ```bash
git clone https://github.com/oceanprotocol/docker-images.git git clone https://github.com/oceanprotocol/docker-images.git
cd docker-images/ cd docker-images/
@ -174,9 +157,8 @@ cd docker-images/
``` ```
```js ```js
const { Ocean, Logger } = require('@oceanprotocol/squid'); const { Ocean, Logger } = require('@oceanprotocol/squid')
;(async () => {
(async () => {
const ocean = await Ocean.getInstance({ const ocean = await Ocean.getInstance({
nodeUri: 'http://localhost:8545' nodeUri: 'http://localhost:8545'
}) })
@ -211,48 +193,47 @@ public interface FromJsonToModel {
} }
``` ```
``` ```text
No language indicated, so no syntax highlighting in Markdown Here (varies on Github). No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
But let's throw in a <b>tag</b>. But let's throw in a <b>tag</b>.
``` ```
## Tables ## Tables
Tables aren't part of the core Markdown spec, but they are part of GFM and *Markdown Here* supports them. They are an easy way of adding tables to your email -- a task that would otherwise require copy-pasting from another application. Tables aren't part of the core Markdown spec, but they are part of GFM and _Markdown Here_ supports them. They are an easy way of adding tables to your email -- a task that would otherwise require copy-pasting from another application.
```markdown ```markdown
Colons can be used to align columns. Colons can be used to align columns.
| Tables | Are | Cool | | Tables | Are | Cool |
| ------------- | :-----------: | ----: | | ------------- | :-----------: | -----: |
| col 3 is | right-aligned | $1600 | | col 3 is | right-aligned | \$1600 |
| col 2 is | centered | $12 | | col 2 is | centered | \$12 |
| zebra stripes | are neat | $1 | | zebra stripes | are neat | \$1 |
The outer pipes (|) are optional, and you don't need to make the raw Markdown line up prettily. You can also use inline Markdown. The outer pipes (|) are optional, and you don't need to make the raw Markdown line up prettily. You can also use inline Markdown.
| | Markdown | Less | Pretty | | | | Markdown | Less | Pretty | |
| | ------------- | --------------- | ---------- |------- | | | ------------- | --------------- | ---------- |------- |
| | *Still* | `renders` | **nicely** | | | | _Still_ | `renders` | **nicely** | |
| | 1 | 2 | 3 | | | | 1 | 2 | 3 | |
``` ```
Colons can be used to align columns. Colons can be used to align columns.
| Tables | Are | Cool | | Tables | Are | Cool |
| ------------- | :-----------: | ----: | | ------------- | :-----------: | -----: |
| col 3 is | right-aligned | $1600 | | col 3 is | right-aligned | \$1600 |
| col 2 is | centered | $12 | | col 2 is | centered | \$12 |
| zebra stripes | are neat | $1 | | zebra stripes | are neat | \$1 |
The outer pipes (|) are optional, and you don't need to make the raw Markdown line up prettily. You can also use inline Markdown. The outer pipes (|) are optional, and you don't need to make the raw Markdown line up prettily. You can also use inline Markdown.
| Markdown | Less | Pretty | | Markdown | Less | Pretty |
| -------- | --------- | ---------- | | -------- | --------- | ---------- |
| *Still* | `renders` | **nicely** | | _Still_ | `renders` | **nicely** |
| 1 | 2 | 3 | | 1 | 2 | 3 |
## Blockquotes ## Blockquotes
```markdown ```markdown
@ -261,7 +242,7 @@ The outer pipes (|) are optional, and you don't need to make the raw Markdown li
Quote break. Quote break.
> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote. > This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can _put_ **Markdown** into a blockquote.
``` ```
> Blockquotes are very handy in email to emulate reply text. > Blockquotes are very handy in email to emulate reply text.
@ -269,7 +250,7 @@ Quote break.
Quote break. Quote break.
> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote. > This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can _put_ **Markdown** into a blockquote.
## Inline HTML ## Inline HTML
@ -295,43 +276,25 @@ You can also use raw HTML in your Markdown, and it'll mostly work pretty well.
## Horizontal Rule ## Horizontal Rule
```text
Hypens
---
Hyphens
``` ```
Three or more...
Hypens
--- ---
Hyphens Hyphens
***
Asterisks
___
Underscores
```
Three or more...
---
Hyphens
***
Asterisks
___
Underscores
## Line Breaks ## Line Breaks
My basic recommendation for learning how line breaks work is to experiment and discover -- hit &lt;Enter&gt; once (i.e., insert one newline), then hit it twice (i.e., insert two newlines), see what happens. You'll soon learn to get what you want. "Markdown Toggle" is your friend. My basic recommendation for learning how line breaks work is to experiment and discover -- hit &lt;Enter&gt; once (i.e., insert one newline), then hit it twice (i.e., insert two newlines), see what happens. You'll soon learn to get what you want. "Markdown Toggle" is your friend.
Here are some things to try out: Here are some things to try out:
``` ```text
Here's a line for us to start with. Here's a line for us to start with.
This line is separated from the one above by two newlines, so it will be a *separate paragraph*. This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
@ -342,18 +305,18 @@ This line is only separated by a single newline, so it's a separate line in the
Here's a line for us to start with. Here's a line for us to start with.
This line is separated from the one above by two newlines, so it will be a *separate paragraph*. This line is separated from the one above by two newlines, so it will be a _separate paragraph_.
This line is also begins a separate paragraph, but... This line is also begins a separate paragraph, but...
This line is only separated by a single newline, so it's a separate line in the *same paragraph*. This line is only separated by a single newline, so it's a separate line in the _same paragraph_.
(Technical note: *Markdown Here* uses GFM line breaks, so there's no need to use MD's two-space line breaks.) (Technical note: _Markdown Here_ uses GFM line breaks, so there's no need to use MD's two-space line breaks.)
## Videos ## Videos
Videos can be embedded like so, works with YouTube, Vimeo, VideoPress, Twitch: Videos can be embedded like so, works with YouTube, Vimeo, VideoPress, Twitch:
``` ```text
`video: https://www.youtube.com/watch?v=6YRmyUZr2No` `video: https://www.youtube.com/watch?v=6YRmyUZr2No`
``` ```
@ -364,8 +327,17 @@ resulting in:
You can also add an image with a link to the video like this: You can also add an image with a link to the video like this:
```html ```html
<a href="http://www.youtube.com/watch?feature=player_embedded&v=6YRmyUZr2No" target="_blank"> <a
<img src="http://img.youtube.com/vi/6YRmyUZr2No/0.jpg" alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" /> href="http://www.youtube.com/watch?feature=player_embedded&v=6YRmyUZr2No"
target="_blank"
>
<img
src="http://img.youtube.com/vi/6YRmyUZr2No/0.jpg"
alt="IMAGE ALT TEXT HERE"
width="240"
height="180"
border="10"
/>
</a> </a>
``` ```
@ -387,11 +359,10 @@ Note that the component name in Markdown needs to be always in lowercase, and ha
The `Repository` component fetching and displaying information about a GitHub repo. Component can be used in Markdown as `<repo>`, it requires a `name` to be passed: The `Repository` component fetching and displaying information about a GitHub repo. Component can be used in Markdown as `<repo>`, it requires a `name` to be passed:
``` ```HTML
<repo name="pleuston"></repo> <repo name="pleuston"></repo>
``` ```
Resulting in: Resulting in:
<repo name="pleuston"></repo> <repo name="pleuston"></repo>

View File

@ -3,6 +3,23 @@
"description": "One site to rule all docs", "description": "One site to rule all docs",
"version": "0.0.1", "version": "0.0.1",
"author": "Ocean Protocol <devops@oceanprotocol.com>", "author": "Ocean Protocol <devops@oceanprotocol.com>",
"license": "Apache-2.0",
"scripts": {
"build": "gatsby build",
"start": "gatsby develop",
"ssr": "npm run build && serve -s public/",
"format:js": "prettier --write '**/*.{js,jsx}'",
"format:css": "prettier-stylelint --write --quiet 'src/**/*.{css,scss}'",
"format:md": "prettier --write '**/*.md'",
"format:yml": "prettier --write '**/*.{yml,yaml}'",
"format": "run-p format:js format:css format:md format:yml",
"lint:js": "eslint --ignore-path .gitignore --ignore-path .prettierignore --ext .js,.jsx .",
"lint:css": "stylelint './src/**/*.{css,scss}'",
"lint:md": "markdownlint './**/*.{md,markdown}' --ignore node_modules",
"lint:yml": "prettier '**/*.{yml,yaml}' --list-different",
"lint": "run-p --continue-on-error lint:js lint:css lint:md lint:yml",
"test": "npm run lint"
},
"dependencies": { "dependencies": {
"@oceanprotocol/art": "^1.0.2", "@oceanprotocol/art": "^1.0.2",
"classnames": "^2.2.6", "classnames": "^2.2.6",
@ -39,19 +56,6 @@
"react-helmet": "^5.2.0", "react-helmet": "^5.2.0",
"rehype-react": "^3.0.3" "rehype-react": "^3.0.3"
}, },
"license": "Apache-2.0",
"scripts": {
"build": "gatsby build",
"start": "gatsby develop",
"ssr": "npm run build && serve -s public/",
"format:js": "prettier --write 'src/**/*.{js,jsx}'",
"format:css": "prettier-stylelint --write --quiet 'src/**/*.{css,scss}'",
"format": "run-p format:js format:css",
"lint:js": "eslint ./gatsby-*.js && eslint ./src/**/*.{js,jsx}",
"lint:css": "stylelint ./src/**/*.{css,scss}",
"lint": "run-p lint:js lint:css",
"test": "npm run lint"
},
"devDependencies": { "devDependencies": {
"@svgr/webpack": "^4.0.2", "@svgr/webpack": "^4.0.2",
"dotenv": "^6.1.0", "dotenv": "^6.1.0",
@ -59,9 +63,11 @@
"eslint-config-oceanprotocol": "^1.3.0", "eslint-config-oceanprotocol": "^1.3.0",
"eslint-config-prettier": "^3.1.0", "eslint-config-prettier": "^3.1.0",
"eslint-plugin-prettier": "^3.0.0", "eslint-plugin-prettier": "^3.0.0",
"markdownlint-cli": "^0.13.0",
"npm-run-all": "^4.1.3", "npm-run-all": "^4.1.3",
"prettier": "^1.15.1", "prettier": "^1.15.1",
"prettier-stylelint": "^0.4.2", "prettier-stylelint": "^0.4.2",
"stylelint": "^9.8.0",
"stylelint-config-bigchaindb": "^1.2.1", "stylelint-config-bigchaindb": "^1.2.1",
"stylelint-config-css-modules": "^1.3.0", "stylelint-config-css-modules": "^1.3.0",
"stylelint-config-standard": "^18.2.0" "stylelint-config-standard": "^18.2.0"