Skip to content

Commit

Permalink
docs: build with mdBook
Browse files Browse the repository at this point in the history
  • Loading branch information
g-plane committed Aug 29, 2024
1 parent 49712dd commit 8301c32
Show file tree
Hide file tree
Showing 33 changed files with 1,080 additions and 45 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,22 @@ jobs:
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- run: cargo test --all-features

docs:
name: documentation
if: ${{ github.event_name == 'push' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install mdbook
run: |
tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name')
url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz"
mkdir mdbook
curl -sSL $url | tar -xz --directory=./mdbook
echo `pwd`/mdbook >> $GITHUB_PATH
- run: mdbook build docs
- name: Deploy Production
run: netlify deploy --dir=docs/book --site=markup-fmt --prod
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
node_modules/
pnpm-lock.yaml
docs/book
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Please read the [documentation](https://docs.rs/markup_fmt).

## Configuration

Please refer to [Configuration](./docs/config.md).
Please refer to [Configuration](https://markup-fmt.netlify.app/).

## Credit

Expand Down
8 changes: 8 additions & 0 deletions docs/book.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[book]
title = "Markup_fmt Documentation"
authors = ["Pig Fang"]
language = "en"

[output.html]
git-repository-url = "https://github.com/g-plane/markup_fmt"
edit-url-template = "https://github.com/g-plane/markup_fmt/edit/main/docs/{path}"
28 changes: 28 additions & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Summary

- [Configuration](./config/README.md)
- [printWidth](./config/print-width.md)
- [useTabs](./config/use-tabs.md)
- [indentWidth](./config/indent-width.md)
- [lineBreak](./config/line-break.md)
- [quotes](./config/quotes.md)
- [formatComments](./config/format-comments.md)
- [scriptIndent](./config/script-indent.md)
- [styleIndent](./config/style-indent.md)
- [closingBracketSameLine](./config/closing-bracket-same-line.md)
- [closingTagLineBreakForEmpty](./config/closing-tag-line-break-for-empty.md)
- [maxAttrsPerLine](./config/max-attrs-per-line.md)
- [preferAttrsSingleLine](./config/prefer-attrs-single-line.md)
- [*.selfClosing](./config/self-closing.md)
- [whitespaceSensitivity](./config/whitespace-sensitivity.md)
- [doctypeKeywordCase](./config/doctype-keyword-case.md)
- [vBindStyle](./config/v-bind-style.md)
- [vOnStyle](./config/v-on-style.md)
- [vForDelimiterStyle](./config/v-for-delimiter-style.md)
- [vSlotStyle](./config/v-slot-style.md)
- [vBindSameNameShortHand](./config/v-bind-same-name-short-hand.md)
- [strictSvelteAttr](./config/strict-svelte-attr.md)
- [svelteAttrShorthand](./config/svelte-attr-shorthand.md)
- [svelteDirectiveShorthand](./config/svelte-directive-shorthand.md)
- [astroAttrShorthand](./config/astro-attr-shorthand.md)
- [ignoreCommentDirective](./config/ignore-comment-directive.md)
3 changes: 3 additions & 0 deletions docs/src/config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Configuration

Options name in this page are in camel case. If you're using markup_fmt as a Rust crate, please use snake case instead.
54 changes: 54 additions & 0 deletions docs/src/config/astro-attr-shorthand.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# `astroAttrShorthand`

Control whether Astro attribute should be written in short-hand form or not when possible.
If this option is unset, attribute won't be changed.

Default value is `null`.

## Example for `null`

Input:

```html
<MyComponent {value} />
<MyComponent value={value} />
```

Output:

```html
<MyComponent {value} />
<MyComponent value={value} />
```

## Example for `true`

Input:

```html
<MyComponent {value} />
<MyComponent value={value} />
```

Output:

```html
<MyComponent {value} />
<MyComponent {value} />
```

## Example for `false`

Input:

```html
<MyComponent {value} />
<MyComponent value={value} />
```

Output:

```html
<MyComponent value={value} />
<MyComponent value={value} />
```
23 changes: 23 additions & 0 deletions docs/src/config/closing-bracket-same-line.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# `closingBracketSameLine`

Control the closing bracket (`>`) of a multi-line element should come at the end of the last line
or on the next line (with a line break).

Default option is `false`.

## Example for `false`

```html
<span
class=""
style=""
></span>
```

## Example for `true`

```html
<span
class=""
style=""></span>
```
36 changes: 36 additions & 0 deletions docs/src/config/closing-tag-line-break-for-empty.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# `closingTagLineBreakForEmpty`

When there're no children in an element,
this option controls whether to insert a line break before the closing tag or not.

Possible options:

- `"always"`: Always insert a line break before the closing tag.
- `"fit"`: Only insert a line break if it doesn't fit the [`printWidth`](./print-width.md) option.
- `"never"`: Don't insert a line break.

Default option is `"fit"`.

## Example for `"always"`

```html
<div>
</div>
<div class="very-very-very-very-very-very-very-very-very-long-class-name">
</div>
```

## Example for `"fit"`

```html
<div></div>
<div class="very-very-very-very-very-very-very-very-very-long-class-name">
</div>
```

## Example for `"never"`

```html
<div></div>
<div class="very-very-very-very-very-very-very-very-very-long-class-name"></div>
```
59 changes: 59 additions & 0 deletions docs/src/config/doctype-keyword-case.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# `doctypeKeywordCase`

Control the case of "doctype" keyword in `<!DOCTYPE>`.

Possible options:

- `"ignore"`: Keep the case as-is.
- `"upper"`: Print "DOCTYPE" in upper case.
- `"lower"`: Print "doctype" in lower case.

Default option is `"upper"`.

## Example for `"ignore"`

Input:

```html
<!DOCTYPE html>
<!doctype html>
```

Output:

```html
<!DOCTYPE html>
<!doctype html>
```

## Example for `"upper"`

Input:

```html
<!DOCTYPE html>
<!doctype html>
```

Output:

```html
<!DOCTYPE html>
<!DOCTYPE html>
```

## Example for `"lower"`

Input:

```html
<!DOCTYPE html>
<!doctype html>
```

Output:

```html
<!doctype html>
<!doctype html>
```
28 changes: 28 additions & 0 deletions docs/src/config/format-comments.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# `formatComments`

Control whether whitespace should be inserted at the beginning and end of comments and
comments should be indented properly or not.

When this option is set to `false`, comments contain leading or trailing whitespace will still be kept as-is.

Default option is `false`.

## Example for `false`

```html
<!--comments-->
<!-- comments -->
<!--very very very very very very very very very very very very very very very very long-->
```

will be formatted as its original input.

## Example for `true`

```html
<!-- comments -->
<!-- comments -->
<!--
very very very very very very very very very very very very very very very very long
-->
```
13 changes: 13 additions & 0 deletions docs/src/config/ignore-comment-directive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# `ignoreCommentDirective`

Text directive for ignoring formatting specific element or node.

Default is `"markup-fmt-ignore"`.

## Example

```html
<div></div>
<!-- markup-fmt-ignore -->
<div > </div>
```
26 changes: 26 additions & 0 deletions docs/src/config/indent-width.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# `indentWidth`

Size of indentation. When enabled [`useTabs`](./use-tabs.md), this option may be disregarded,
since only one tab will be inserted when indented once.

Default option is `2`. This can't be zero.

## Example for `2`

```html
<script
src="very-very-very-very-long-name.js"
async
defer
></script>
```

## Example for `4`

```html
<script
src="very-very-very-very-long-name.js"
async
defer
></script>
```
5 changes: 5 additions & 0 deletions docs/src/config/line-break.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# `lineBreak`

Specify whether use `\n` (LF) or `\r\n` (CRLF) for line break.

Default option is `"lf"`. Possible options are `"lf"` and `"crlf"`.
33 changes: 33 additions & 0 deletions docs/src/config/max-attrs-per-line.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# `maxAttrsPerLine`

Control the maximum number of attributes in one line.
If this option is unset, there won't be any limitations.

This option conflicts with [`preferAttrsSingleLine`](./prefer-attrs-single-line.md) option.

Default option is `null`. This option can't be `0`.

## Example for `null`

```html
<div data-a data-b data-c></div>
```

## Example for `1`

```html
<div
data-a
data-b
data-c
></div>
```

## Example for `2`

```html
<div
data-a data-b
data-c
></div>
```
Loading

0 comments on commit 8301c32

Please sign in to comment.