Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
jtkiesel committed Dec 15, 2023
1 parent 00a8585 commit 407a3f3
Show file tree
Hide file tree
Showing 22 changed files with 9,288 additions and 0 deletions.
20 changes: 20 additions & 0 deletions website/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependencies
/node_modules

# Production
/build

# Generated files
.docusaurus
.cache-loader

# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
41 changes: 41 additions & 0 deletions website/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Website

This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.

### Installation

```
$ yarn
```

### Local Development

```
$ yarn start
```

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

### Build

```
$ yarn build
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.

### Deployment

Using SSH:

```
$ USE_SSH=true yarn deploy
```

Not using SSH:

```
$ GIT_USER=<Your GitHub username> yarn deploy
```

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.
3 changes: 3 additions & 0 deletions website/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
77 changes: 77 additions & 0 deletions website/blog/2023-11-26-2.5.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
author: "Jordan Kiesel (@jtkiesel)"
authorURL: "https://github.com/jtkiesel"
title: "Prettier Java 2.5: Java 21 unnamed patterns and variables preview feature!"
---

This release adds support for the Java 21 preview feature: unnamed patterns and variables ([JEP 443](https://openjdk.org/jeps/443))!

<!-- truncate -->

## Highlights

### Support Java 21 preview feature: unnamed patterns and variables ([#620](https://github.com/jhipster/prettier-java/pull/620) by [@jtkiesel](https://github.com/jtkiesel))

We’ve added support for the Java 21 preview feature "Unnamed Patterns and Variables":

#### Unnamed pattern variables

```java
// Example
r instanceof Point _
```

#### Unnamed variables

```java
// Example
int acc = 0;
for (Order _ : orders) {
if (acc < LIMIT) {
// ... acc++ ...
}
}
```

## Other Changes

### 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))

Provide an entrypoint that exposes both the CST and the underlying token array.

### 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))

When a block begins with `// prettier-ignore`, only the first statement is ignored, rather than the whole block.

<!-- prettier-ignore -->
```java
// Input
void foo() {
// prettier-ignore
var bar = List.of(
1
);

var baz = 2;
}

// Prettier Java 2.4
void foo() {
// prettier-ignore
var bar = List.of(
1
);

var baz = 2;
}

// Prettier Java 2.5
void foo() {
// prettier-ignore
var bar = List.of(
1
);

var baz = 2;
}
```
33 changes: 33 additions & 0 deletions website/docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Introduction

Prettier Java is an opinionated Java code formatter.

It removes all original styling and ensures that all outputted code conforms to a consistent style.

Prettier Java takes your code and reprints it from scratch by taking the line length into account.

For example, take the following code:

```java
foo(arg1, arg2, arg3, arg4);
```

It fits in a single line so it's going to stay as is. However, we've all run into this situation:

<!-- prettier-ignore -->
```java
foo(reallyLongArg(), omgSoManyParameters(), IShouldRefactorThis(), isThereSeriouslyAnotherOne());
```

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:

```java
foo(
reallyLongArg(),
omgSoManyParameters(),
IShouldRefactorThis(),
isThereSeriouslyAnotherOne()
);
```

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.
34 changes: 34 additions & 0 deletions website/docs/installation.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import TabItem from "@theme/TabItem";
import Tabs from "@theme/Tabs";

# Installation

## Requirements

- [Node.js](https://nodejs.org/en/download/) version 10.0 or above

## Install Prettier and the Prettier Java plugin

<Tabs>
<TabItem value="npm">

```sh
npm install --save-dev --save-exact prettier prettier-plugin-java
```

</TabItem>
<TabItem value="Yarn">

```sh
yarn add --dev --exact prettier prettier-plugin-java
```

</TabItem>
<TabItem value="pnpm">

```sh
pnpm add --save-dev --save-exact prettier prettier-plugin-java
```

</TabItem>
</Tabs>
117 changes: 117 additions & 0 deletions website/docusaurus.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import type { Options, ThemeConfig } from "@docusaurus/preset-classic";
import type { Config } from "@docusaurus/types";
import { themes } from "prism-react-renderer";

export default {
title: "Prettier Java",
tagline: "Prettier code formatter plugin for Java",
favicon: "img/favicon.png",
trailingSlash: false,
url: "https://jtkiesel.github.io",
baseUrl: "/prettier-java/",
organizationName: "jtkiesel",
projectName: "prettier-java",
i18n: {
defaultLocale: "en",
locales: ["en"]
},
presets: [
[
"classic",
{
docs: {
editUrl:
"https://github.com/jtkiesel/prettier-java/tree/docs/create-website/website/"
},
blog: {
editUrl:
"https://github.com/jtkiesel/prettier-java/tree/docs/create-website/website/"
},
theme: {
customCss: "./src/css/custom.css"
}
} satisfies Options
]
],
themeConfig: {
colorMode: {
respectPrefersColorScheme: true
},
image: "img/banner-dark.png",
navbar: {
title: "Prettier Java",
logo: {
alt: "Prettier Java Logo",
src: "img/icon.svg",
srcDark: "img/icon-dark.svg"
},
items: [
{
label: "Playground",
to: "/playground",
position: "left"
},
{
label: "Docs",
to: "/docs",
position: "left"
},
{ label: "Blog", to: "/blog", position: "left" },
{
label: "GitHub",
to: "https://github.com/jhipster/prettier-java",
position: "right"
}
]
},
footer: {
style: "dark",
links: [
{
title: "Docs",
items: [
{
label: "Introduction",
to: "/docs"
},
{
label: "Installation",
to: "/docs/installation"
}
]
},
{
title: "Community",
items: [
{
label: "@JHipster on Twitter",
to: "https://twitter.com/jhipster"
}
]
},
{
title: "More",
items: [
{
label: "Blog",
to: "/blog"
},
{
label: "GitHub",
to: "https://github.com/jhipster/prettier-java"
},
{
label: "Issues",
to: "https://github.com/jhipster/prettier-java/issues"
}
]
}
]
},
prism: {
theme: themes.github,
darkTheme: themes.dracula,
additionalLanguages: ["bash", "java"]
}
} satisfies ThemeConfig
} satisfies Config;
54 changes: 54 additions & 0 deletions website/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "website",
"version": "0.0.0",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start",
"build": "docusaurus build",
"swizzle": "docusaurus swizzle",
"deploy": "docusaurus deploy",
"clear": "docusaurus clear",
"serve": "docusaurus serve",
"write-translations": "docusaurus write-translations",
"write-heading-ids": "docusaurus write-heading-ids",
"typecheck": "tsc"
},
"dependencies": {
"@codemirror/commands": "6.3.2",
"@codemirror/lang-java": "6.0.1",
"@codemirror/state": "6.3.3",
"@codemirror/view": "6.22.2",
"@docusaurus/core": "3.0.1",
"@docusaurus/preset-classic": "3.0.1",
"@mdx-js/react": "3.0.0",
"codemirror": "6.0.1",
"prettier": "3.1.0",
"prettier-plugin-java": "2.5.0",
"prism-react-renderer": "2.3.0",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "3.0.1",
"@docusaurus/tsconfig": "3.0.1",
"@docusaurus/types": "3.0.1",
"@types/react": "18.2.42",
"typescript": "5.3.3"
},
"browserslist": {
"production": [
">0.5%",
"not dead",
"not op_mini all"
],
"development": [
"last 3 chrome version",
"last 3 firefox version",
"last 5 safari version"
]
},
"engines": {
"node": ">=18.0"
}
}
Loading

0 comments on commit 407a3f3

Please sign in to comment.