diff --git a/.vitepress/config/en.ts b/.vitepress/config/en.ts index 16289cebdf..5236a175b4 100644 --- a/.vitepress/config/en.ts +++ b/.vitepress/config/en.ts @@ -88,6 +88,21 @@ export const enConfig = defineLocaleConfig("root", { }, ], }, + { + text: "Formatter", + link: "/docs/guide/usage/formatter", + collapsed: true, + items: [ + { + text: "CLI reference", + link: "/docs/guide/usage/formatter/cli", + }, + // { + // text: "Configuration file reference", + // link: "/docs/guide/usage/formatter/config-file-reference", + // }, + ], + }, { text: "Parser", link: "/docs/guide/usage/parser" }, { text: "Transformer", @@ -120,7 +135,6 @@ export const enConfig = defineLocaleConfig("root", { }, ], }, - { text: "Formatter", link: "/docs/guide/usage/formatter" }, { text: "Minifier", link: "/docs/guide/usage/minifier", diff --git a/src/docs/guide/usage/formatter.md b/src/docs/guide/usage/formatter.md index 88a02f7f2a..27227c8d4f 100644 --- a/src/docs/guide/usage/formatter.md +++ b/src/docs/guide/usage/formatter.md @@ -65,43 +65,14 @@ $ bun add -D oxfmt ## Command-line Interface -``` -Usage: [--check | --list-different] [-c=PATH] [--ignore-path=PATH]... [PATH]... - -Output Options - --check Check mode - check if files are formatted, also show statistics - --list-different List mode - list files that would be changed - -Basic Options - -c, --config=PATH Path to the configuration file - -Ignore Options - --ignore-path=PATH Path to ignore file(s). Can be specified multiple times. If not - specified, .gitignore and .prettierignore in the current directory are - used. - --with-node-modules Format code in node_modules directory (skipped by default) - -Miscellaneous - --lsp Start language server protocol (LSP) server - --no-error-on-unmatched-pattern Do not exit with error when pattern is unmatched - --threads=INT Number of threads to use. Set to 1 for using only 1 CPU core. - -Available positional items: - PATH Single file, single path or list of paths. If not provided, current - working directory is used. Glob is supported only for exclude patterns - like `'!**/fixtures/*.js'. - -Available options: - -h, --help Prints help information - -V, --version Prints version information -``` - -Oxfmt works like `prettier --write .` by default. +`oxfmt` works like `prettier --write .` by default. Format options like `--no-semi` are not supported by CLI, we recommend to use configuration file instead. This will help you use CLI and editor extension with the same settings. Globs in positional paths are not expanded. (Still you can rely on your shell.) But it works in `!` prefixed exclude paths. +See more details in [CLI reference](./formatter/cli). + ## Configuration file By default, `oxfmt` automatically tries to find the nearest `.oxfmtrc.json` or `.oxfmtrc.jsonc` file from current working directory. If not found, default configuration is used. diff --git a/src/docs/guide/usage/formatter/cli.md b/src/docs/guide/usage/formatter/cli.md new file mode 100644 index 0000000000..b896f75405 --- /dev/null +++ b/src/docs/guide/usage/formatter/cli.md @@ -0,0 +1,9 @@ +--- +outline: [2, 3] +editLink: false +--- + +# Command-line Interface + + + diff --git a/src/docs/guide/usage/formatter/config-file-reference.md b/src/docs/guide/usage/formatter/config-file-reference.md new file mode 100644 index 0000000000..91774b343d --- /dev/null +++ b/src/docs/guide/usage/formatter/config-file-reference.md @@ -0,0 +1,7 @@ +--- +outline: [2, 3] +editLink: false +--- + + + diff --git a/src/docs/guide/usage/formatter/generated-cli.md b/src/docs/guide/usage/formatter/generated-cli.md new file mode 100644 index 0000000000..36a828ca92 --- /dev/null +++ b/src/docs/guide/usage/formatter/generated-cli.md @@ -0,0 +1,47 @@ +--- +search: false +--- + +## Usage + +**`oxfmt`** \[**`-c`**=_`PATH`_\] \[_`PATH`_\]... + +## Output Options + +- **`--check`** — + Check mode - check if files are formatted, also show statistics +- **`--list-different`** — + List mode - list files that would be changed + +## Basic Options + +- **`-c`**, **`--config`**=_`PATH`_ — + Path to the configuration file + +## Ignore Options + +- **`--ignore-path`**=_`PATH`_ — + Path to ignore file(s). Can be specified multiple times. If not specified, .gitignore and .prettierignore in the current directory are used. +- **`--with-node-modules`** — + Format code in node_modules directory (skipped by default) + +## Miscellaneous + +- **`--lsp`** — + Start language server protocol (LSP) server +- **`--no-error-on-unmatched-pattern`** — + Do not exit with error when pattern is unmatched +- **`--threads`**=_`INT`_ — + Number of threads to use. Set to 1 for using only 1 CPU core. + +## Available positional items: + +- _`PATH`_ — + Single file, single path or list of paths. If not provided, current working directory is used. Glob is supported only for exclude patterns like `'!**/fixtures/*.js'`. + +## Available options: + +- **`-h`**, **`--help`** — + Prints help information +- **`-V`**, **`--version`** — + Prints version information diff --git a/src/docs/guide/usage/formatter/generated-config.md b/src/docs/guide/usage/formatter/generated-config.md new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/docs/guide/usage/linter/config-file-reference.md b/src/docs/guide/usage/linter/config-file-reference.md index 4c68269bf5..748aa215c1 100644 --- a/src/docs/guide/usage/linter/config-file-reference.md +++ b/src/docs/guide/usage/linter/config-file-reference.md @@ -3,5 +3,5 @@ outline: [2, 3] editLink: false --- - +