Skip to content

Commit 4b13e6d

Browse files
Enhance Documentation (#467)
Co-authored-by: Shinigami92 <chrissi92@hotmail.de>
1 parent 6a28a43 commit 4b13e6d

2 files changed

Lines changed: 54 additions & 24 deletions

File tree

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ pnpm add --save-dev prettier @prettier/plugin-pug
6262

6363
## Usage
6464

65+
### CLI
66+
6567
```bash
6668
npx prettier --write "**/*.pug" --plugin="@prettier/plugin-pug"
6769
# or
@@ -70,9 +72,24 @@ yarn prettier --write "**/*.pug" --plugin="@prettier/plugin-pug"
7072
pnpm prettier --write "**/*.pug" --plugin="@prettier/plugin-pug"
7173
```
7274

73-
## Configuration
75+
### Configuration file (.prettierrc)
76+
77+
```json
78+
{
79+
"plugins": ["@prettier/plugin-pug"]
80+
}
81+
```
82+
83+
See [Standard Prettier overrides](https://prettier.github.io/plugin-pug/guide/standard-prettier-overrides.html) and [Pug specific options](https://prettier.github.io/plugin-pug/guide/pug-specific-options.html) for more options.
84+
85+
### API
7486

75-
See [documentation](https://prettier.github.io/plugin-pug/guide)
87+
```js
88+
await prettier.format('code', {
89+
parser: 'pug',
90+
plugins: ['@prettier/plugin-pug'],
91+
});
92+
```
7693

7794
## Workaround / Known Issue
7895

docs/guide/index.md

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ yarn add --dev prettier @prettier/plugin-pug
2222

2323
## Usage
2424

25+
### CLI
26+
2527
Format all pug files in your project:
2628

2729
::: code-group
@@ -40,6 +42,39 @@ yarn prettier --write "**/*.pug" --plugin="@prettier/plugin-pug"
4042

4143
:::
4244

45+
### Configuration file
46+
47+
You can write your `.prettierrc.cjs` like this to get fully type check support with documentation:
48+
49+
```js
50+
// @ts-check
51+
/// <reference types="@prettier/plugin-pug/src/prettier" />
52+
53+
/**
54+
* @type {import('prettier').Options}
55+
*/
56+
module.exports = {
57+
plugins: ['@prettier/plugin-pug'],
58+
59+
printWidth: 120,
60+
singleQuote: true,
61+
62+
pugSingleQuote: false,
63+
// ... more pug* options
64+
};
65+
```
66+
67+
### API
68+
69+
Using the `plugins` option on the API, you can format .pug files:
70+
71+
```js
72+
await prettier.format('code', {
73+
parser: 'pug',
74+
plugins: ['@prettier/plugin-pug'],
75+
});
76+
```
77+
4378
### Selectively ignoring automatic formatting
4479

4580
You can disable code formatting for a particular element by adding `//- prettier-ignore` comments in your pug templates:
@@ -82,25 +117,3 @@ Pug code with automatic formatting:
82117
.text(color="primary", disabled)
83118
```
84119
````
85-
86-
## Type support in configuration file
87-
88-
You can write your `.prettierrc.cjs` like this to get fully type check support with documentation:
89-
90-
```js
91-
// @ts-check
92-
/// <reference types="@prettier/plugin-pug/src/prettier" />
93-
94-
/**
95-
* @type {import('prettier').Options}
96-
*/
97-
module.exports = {
98-
plugins: ['@prettier/plugin-pug'],
99-
100-
printWidth: 120,
101-
singleQuote: true,
102-
103-
pugSingleQuote: false,
104-
// ... more pug* options
105-
};
106-
```

0 commit comments

Comments
 (0)