Skip to content

Commit

Permalink
Add settings to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jablko committed Mar 31, 2022
1 parent 82d3e40 commit 6a78b63
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 3 deletions.
7 changes: 7 additions & 0 deletions packages/remark-preset-lint-consistent/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Preset of [`remark-lint`][mono] rules to warn for inconsistencies.
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Rules](#rules)
* [Settings](#settings)
* [Install](#install)
* [Use](#use)
* [API](#api)
Expand Down Expand Up @@ -54,6 +55,10 @@ This preset configures [`remark-lint`][mono] with the following rules:
| [`remark-lint-strong-marker`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-strong-marker) | `'consistent'` |
| [`remark-lint-table-cell-padding`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-table-cell-padding) | `'consistent'` |

## Settings

It doesn't set any remark [settings][configure].

## Install

This package is [ESM only][esm].
Expand Down Expand Up @@ -183,6 +188,8 @@ abide by its terms.

[mono]: https://github.com/remarkjs/remark-lint

[configure]: https://github.com/remarkjs/remark-lint#configure

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

[skypack]: https://www.skypack.dev
Expand Down
22 changes: 22 additions & 0 deletions packages/remark-preset-lint-markdown-style-guide/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Preset of [`remark-lint`][mono] rules that follow an opinionated style guide.
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Rules](#rules)
* [Settings](#settings)
* [Install](#install)
* [Use](#use)
* [API](#api)
Expand Down Expand Up @@ -175,6 +176,25 @@ This preset configures [`remark-lint`][mono] with the following rules:
| [`remark-lint-no-emphasis-as-heading`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-emphasis-as-heading) | |
| [`remark-lint-no-literal-urls`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-literal-urls) | |

## Settings

It sets the following remark [settings][configure].
Settings are shared among all plugins --- particularly [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#options):

| Name | Value |
| - | - |
| `settings.bullet` | `'-'` |
| `settings.bulletOrdered` | `'.'` |
| `settings.emphasis` | `'*'` |
| `settings.fence` | ``'`'`` |
| `settings.fences` | `true` |
| `settings.incrementListMarker` | `false` |
| `settings.listItemIndent` | `'mixed'` |
| `settings.quote` | `'"'` |
| `settings.rule` | `'-'` |
| `settings.setext` | `false` |
| `settings.strong` | `'*'` |

## Install

This package is [ESM only][esm].
Expand Down Expand Up @@ -304,6 +324,8 @@ abide by its terms.

[mono]: https://github.com/remarkjs/remark-lint

[configure]: https://github.com/remarkjs/remark-lint#configure

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

[skypack]: https://www.skypack.dev
Expand Down
13 changes: 13 additions & 0 deletions packages/remark-preset-lint-recommended/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Preset of [`remark-lint`][mono] rules to warn for some likely problems.
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Rules](#rules)
* [Settings](#settings)
* [Install](#install)
* [Use](#use)
* [API](#api)
Expand Down Expand Up @@ -56,6 +57,16 @@ This preset configures [`remark-lint`][mono] with the following rules:
| [`remark-lint-no-undefined-references`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-undefined-references) | |
| [`remark-lint-no-unused-definitions`](https://github.com/remarkjs/remark-lint/tree/main/packages/remark-lint-no-unused-definitions) | |

## Settings

It sets the following remark [settings][configure].
Settings are shared among all plugins --- particularly [`remark-stringify`](https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#options):

| Name | Value |
| - | - |
| `settings.bulletOrdered` | `'.'` |
| `settings.listItemIndent` | `'tab'` |

## Install

This package is [ESM only][esm].
Expand Down Expand Up @@ -185,6 +196,8 @@ abide by its terms.

[mono]: https://github.com/remarkjs/remark-lint

[configure]: https://github.com/remarkjs/remark-lint#configure

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

[skypack]: https://www.skypack.dev
Expand Down
90 changes: 89 additions & 1 deletion script/build-presets.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ presets(root).then((presetObjects) => {
let index = -1

while (++index < presetObjects.length) {
const {name, packages} = presetObjects[index]
const {name, packages, settings} = presetObjects[index]
const base = path.resolve(root, name)
/** @type {PackageJson} */
const pack = JSON.parse(
Expand Down Expand Up @@ -311,6 +311,89 @@ presets(root).then((presetObjects) => {
]
},
{type: 'table', align: [], children: rows},
{
type: 'heading',
depth: 2,
children: [{type: 'text', value: 'Settings'}]
},
.../** @type {Array<BlockContent>} */ (
settings
? [
{
type: 'paragraph',
children: [
{type: 'text', value: 'It sets the following remark '},
{
type: 'linkReference',
identifier: 'configure',
referenceType: 'full',
children: [{type: 'text', value: 'settings'}]
},
{
type: 'text',
value:
'.\nSettings are shared among all plugins --- particularly '
},
{
type: 'link',
url: 'https://github.com/remarkjs/remark/tree/main/packages/remark-stringify#options',
title: null,
children: [{type: 'inlineCode', value: 'remark-stringify'}]
},
{type: 'text', value: ':'}
]
},
{
type: 'table',
align: [],
children: [
{
type: 'tableRow',
children: [
{
type: 'tableCell',
children: [{type: 'text', value: 'Name'}]
},
{
type: 'tableCell',
children: [{type: 'text', value: 'Value'}]
}
]
},
...Object.entries(settings).map(([name, value]) => ({
type: 'tableRow',
children: [
{
type: 'tableCell',
children: [
{type: 'inlineCode', value: `settings.${name}`}
]
},
{
type: 'tableCell',
children: [{type: 'inlineCode', value: inspect(value)}]
}
]
}))
]
}
]
: [
{
type: 'paragraph',
children: [
{type: 'text', value: "It doesn't set any remark "},
{
type: 'linkReference',
identifier: 'configure',
referenceType: 'full',
children: [{type: 'text', value: 'settings'}]
},
{type: 'text', value: '.'}
]
}
]
),
{
type: 'heading',
depth: 2,
Expand Down Expand Up @@ -664,6 +747,11 @@ presets(root).then((presetObjects) => {
identifier: 'mono',
url: 'https://github.com/' + slug
},
{
type: 'definition',
identifier: 'configure',
url: `https://github.com/${slug}#configure`
},
{
type: 'definition',
identifier: 'esm',
Expand Down
4 changes: 2 additions & 2 deletions script/util/presets.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import url from 'node:url'

/**
* @param {string} base
* @returns {Promise<Array<{name: string, packages: Record<string, unknown>}>>}
* @returns {Promise<Array<{name: string, packages: Record<string, unknown>, settings: Record<string, unknown>|undefined}>>}
*/
export async function presets(base) {
const allFiles = await fs.readdir(base)
Expand Down Expand Up @@ -70,7 +70,7 @@ export async function presets(base) {
] = option
}

return {name, packages}
return {name, packages, settings: preset.settings}
})
)
}

0 comments on commit 6a78b63

Please sign in to comment.