Skip to content

Commit 01ec632

Browse files
jtkieselclementdessoude
authored andcommitted
docs: create Docusaurus website
1 parent 983a09d commit 01ec632

27 files changed

+9179
-4
lines changed

docs/advanced_usage.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,3 @@ Open your Preferences. Then, go to the `Tools/File Watchers` section and create
8787
- Trigger the watcher on external changes: `checked`
8888

8989
Please refer to the [Prettier "Using File Watchers" documentation](https://prettier.io/docs/en/webstorm.html#running-prettier-on-save-using-file-watcher) for more information.
90-
91-
## Nuxt Project
92-
93-
If you would like to import prettier-java into a Nuxt Project, you might encounter an [issue](https://github.com/jhipster/prettier-java/issues/462) with Chevrotain

packages/prettier-plugin-java/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"files": [
88
"dist"
99
],
10+
"homepage": "https://jhipster.github.io/prettier-java/",
1011
"repository": "https://github.com/jhipster/prettier-java",
1112
"license": "Apache-2.0",
1213
"dependencies": {

packages/prettier-plugin-java/src/options.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,5 +239,12 @@ export default {
239239
],
240240
description:
241241
"Prettify from the entrypoint, allowing to use prettier on snippet."
242+
},
243+
trailingComma: {
244+
type: "choice",
245+
category: "Java",
246+
default: "all",
247+
choices: ["all", "none"],
248+
description: "Print trailing commas wherever possible when multi-line."
242249
}
243250
};

website/.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Dependencies
2+
/node_modules
3+
4+
# Production
5+
/build
6+
7+
# Generated files
8+
.docusaurus
9+
.cache-loader
10+
11+
# Misc
12+
.DS_Store
13+
.env.local
14+
.env.development.local
15+
.env.test.local
16+
.env.production.local
17+
18+
npm-debug.log*
19+
yarn-debug.log*
20+
yarn-error.log*

website/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Website
2+
3+
This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.
4+
5+
### Installation
6+
7+
```
8+
$ yarn
9+
```
10+
11+
### Local Development
12+
13+
```
14+
$ yarn start
15+
```
16+
17+
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.
18+
19+
### Build
20+
21+
```
22+
$ yarn build
23+
```
24+
25+
This command generates static content into the `build` directory and can be served using any static contents hosting service.
26+
27+
### Deployment
28+
29+
Using SSH:
30+
31+
```
32+
$ USE_SSH=true yarn deploy
33+
```
34+
35+
Not using SSH:
36+
37+
```
38+
$ GIT_USER=<Your GitHub username> yarn deploy
39+
```
40+
41+
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.

website/babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
presets: [require.resolve("@docusaurus/core/lib/babel/preset")]
3+
};

website/blog/2023-11-26-2.5.0.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
---
2+
author: "Jordan Kiesel (@jtkiesel)"
3+
authorURL: "https://github.com/jtkiesel"
4+
title: "Prettier Java 2.5: Java 21 unnamed patterns and variables preview feature!"
5+
---
6+
7+
This release adds support for the Java 21 preview feature: unnamed patterns and variables ([JEP 443](https://openjdk.org/jeps/443))!
8+
9+
<!-- truncate -->
10+
11+
## Highlights
12+
13+
### Support Java 21 preview feature: unnamed patterns and variables ([#620](https://github.com/jhipster/prettier-java/pull/620) by [@jtkiesel](https://github.com/jtkiesel))
14+
15+
We’ve added support for the Java 21 preview feature "Unnamed Patterns and Variables":
16+
17+
#### Unnamed pattern variables
18+
19+
```java
20+
// Example
21+
r instanceof Point _
22+
```
23+
24+
#### Unnamed variables
25+
26+
```java
27+
// Example
28+
int acc = 0;
29+
for (Order _ : orders) {
30+
if (acc < LIMIT) {
31+
// ... acc++ ...
32+
}
33+
}
34+
```
35+
36+
## Other Changes
37+
38+
### New entrypoint `lexAndParse` to return both tokens and CST ([#625](https://github.com/jhipster/prettier-java/pull/625) by [@max-schaefer](https://github.com/max-schaefer))
39+
40+
Provide an entrypoint that exposes both the CST and the underlying token array.
41+
42+
### No longer ignore whole block when `prettier-ignore` at start ([#603](https://github.com/jhipster/prettier-java/pull/603) by [@jtkiesel](https://github.com/jtkiesel))
43+
44+
When a block begins with `// prettier-ignore`, only the first statement is ignored, rather than the whole block.
45+
46+
<!-- prettier-ignore -->
47+
```java
48+
// Input
49+
void foo() {
50+
// prettier-ignore
51+
var bar = List.of(
52+
1
53+
);
54+
55+
var baz = 2;
56+
}
57+
58+
// Prettier Java 2.4
59+
void foo() {
60+
// prettier-ignore
61+
var bar = List.of(
62+
1
63+
);
64+
65+
var baz = 2;
66+
}
67+
68+
// Prettier Java 2.5
69+
void foo() {
70+
// prettier-ignore
71+
var bar = List.of(
72+
1
73+
);
74+
75+
var baz = 2;
76+
}
77+
```

website/docs/index.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Introduction
2+
3+
Prettier Java is an opinionated Java code formatter.
4+
5+
It removes all original styling and ensures that all outputted code conforms to a consistent style.
6+
7+
Prettier Java takes your code and reprints it from scratch by taking the line length into account.
8+
9+
For example, take the following code:
10+
11+
```java
12+
foo(arg1, arg2, arg3, arg4);
13+
```
14+
15+
It fits in a single line so it's going to stay as is. However, we've all run into this situation:
16+
17+
<!-- prettier-ignore -->
18+
```java
19+
foo(reallyLongArg(), omgSoManyParameters(), IShouldRefactorThis(), isThereSeriouslyAnotherOne());
20+
```
21+
22+
Suddenly our previous format for calling function breaks down because this is too long. Prettier Java is going to do the painstaking work of reprinting it like that for you:
23+
24+
```java
25+
foo(
26+
reallyLongArg(),
27+
omgSoManyParameters(),
28+
IShouldRefactorThis(),
29+
isThereSeriouslyAnotherOne()
30+
);
31+
```
32+
33+
Prettier Java enforces a consistent code **style** (i.e. code formatting that won't affect the AST) across your entire codebase because it disregards the original styling by parsing it away and re-printing the parsed AST with its own rules that take the maximum line length into account, wrapping code when necessary.

website/docs/installation.mdx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import TabItem from "@theme/TabItem";
2+
import Tabs from "@theme/Tabs";
3+
4+
# Installation
5+
6+
## Requirements
7+
8+
- [Node.js](https://nodejs.org/en/download/) version 10.0 or above
9+
10+
## Install Prettier and the Prettier Java plugin
11+
12+
<Tabs>
13+
<TabItem value="npm">
14+
15+
```sh
16+
npm install --save-dev --save-exact prettier prettier-plugin-java
17+
```
18+
19+
</TabItem>
20+
<TabItem value="Yarn">
21+
22+
```sh
23+
yarn add --dev --exact prettier prettier-plugin-java
24+
```
25+
26+
</TabItem>
27+
<TabItem value="pnpm">
28+
29+
```sh
30+
pnpm add --save-dev --save-exact prettier prettier-plugin-java
31+
```
32+
33+
</TabItem>
34+
</Tabs>

website/docusaurus.config.ts

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import type { Options, ThemeConfig } from "@docusaurus/preset-classic";
2+
import type { Config } from "@docusaurus/types";
3+
import { themes } from "prism-react-renderer";
4+
import {
5+
homepage,
6+
repository
7+
} from "../packages/prettier-plugin-java/package.json";
8+
9+
const { origin: url, pathname: baseUrl } = new URL(homepage);
10+
const [, organizationName, projectName] = new URL(repository).pathname.split(
11+
"/"
12+
);
13+
const editUrl = `${repository}/tree/docs/create-website/website/`;
14+
15+
export default {
16+
title: "Prettier Java",
17+
tagline: "Prettier code formatter plugin for Java",
18+
favicon: "img/favicon.png",
19+
trailingSlash: false,
20+
url,
21+
baseUrl,
22+
organizationName,
23+
projectName,
24+
i18n: {
25+
defaultLocale: "en",
26+
locales: ["en"]
27+
},
28+
presets: [
29+
[
30+
"classic",
31+
{
32+
docs: { editUrl },
33+
blog: { editUrl },
34+
theme: {
35+
customCss: "./src/css/custom.css"
36+
}
37+
} satisfies Options
38+
]
39+
],
40+
themeConfig: {
41+
colorMode: {
42+
respectPrefersColorScheme: true
43+
},
44+
image: "img/banner-dark.png",
45+
navbar: {
46+
title: "Prettier Java",
47+
logo: {
48+
alt: "Prettier Java Logo",
49+
src: "img/icon.svg",
50+
srcDark: "img/icon-dark.svg"
51+
},
52+
items: [
53+
{ label: "Playground", to: "/playground", position: "left" },
54+
{ label: "Docs", to: "/docs", position: "left" },
55+
{ label: "Blog", to: "/blog", position: "left" },
56+
{ label: "GitHub", to: repository, position: "right" }
57+
]
58+
},
59+
footer: {
60+
style: "dark",
61+
links: [
62+
{
63+
title: "Docs",
64+
items: [
65+
{ label: "Introduction", to: "/docs" },
66+
{ label: "Installation", to: "/docs/installation" }
67+
]
68+
},
69+
{
70+
title: "Community",
71+
items: [
72+
{
73+
label: "@JHipster on Twitter",
74+
to: "https://twitter.com/jhipster"
75+
}
76+
]
77+
},
78+
{
79+
title: "More",
80+
items: [
81+
{ label: "Blog", to: "/blog" },
82+
{ label: "GitHub", to: repository },
83+
{ label: "Issues", to: `${repository}/issues` }
84+
]
85+
}
86+
]
87+
},
88+
prism: {
89+
theme: themes.github,
90+
darkTheme: themes.dracula,
91+
additionalLanguages: ["bash", "java"]
92+
}
93+
} satisfies ThemeConfig
94+
} satisfies Config;

website/package.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "website",
3+
"version": "0.0.0",
4+
"private": true,
5+
"scripts": {
6+
"docusaurus": "docusaurus",
7+
"start": "docusaurus start",
8+
"build": "docusaurus build",
9+
"swizzle": "docusaurus swizzle",
10+
"deploy": "docusaurus deploy",
11+
"clear": "docusaurus clear",
12+
"serve": "docusaurus serve",
13+
"write-translations": "docusaurus write-translations",
14+
"write-heading-ids": "docusaurus write-heading-ids",
15+
"typecheck": "tsc"
16+
},
17+
"dependencies": {
18+
"@docusaurus/core": "3.1.1",
19+
"@docusaurus/preset-classic": "3.1.1",
20+
"@mdx-js/react": "3.0.0",
21+
"@monaco-editor/react": "4.6.0",
22+
"lz-string": "1.5.0",
23+
"prettier": "3.2.4",
24+
"prettier-plugin-java": "link:./../packages/prettier-plugin-java",
25+
"prism-react-renderer": "2.3.1",
26+
"react": "18.2.0",
27+
"react-dom": "18.2.0"
28+
},
29+
"devDependencies": {
30+
"@docusaurus/module-type-aliases": "3.1.1",
31+
"@docusaurus/tsconfig": "3.1.1",
32+
"@docusaurus/types": "3.1.1",
33+
"@types/react": "18.2.48",
34+
"typescript": "5.3.3"
35+
},
36+
"browserslist": {
37+
"production": [
38+
">0.5%",
39+
"not dead",
40+
"not op_mini all"
41+
],
42+
"development": [
43+
"last 3 chrome version",
44+
"last 3 firefox version",
45+
"last 5 safari version"
46+
]
47+
},
48+
"engines": {
49+
"node": ">=18.0"
50+
}
51+
}

0 commit comments

Comments
 (0)