Skip to content

Commit

Permalink
docs: create Docusaurus website
Browse files Browse the repository at this point in the history
  • Loading branch information
jtkiesel authored and clementdessoude committed Feb 13, 2024
1 parent 983a09d commit 01ec632
Show file tree
Hide file tree
Showing 27 changed files with 9,179 additions and 4 deletions.
4 changes: 0 additions & 4 deletions docs/advanced_usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,3 @@ Open your Preferences. Then, go to the `Tools/File Watchers` section and create
- Trigger the watcher on external changes: `checked`

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.

## Nuxt Project

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
1 change: 1 addition & 0 deletions packages/prettier-plugin-java/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"files": [
"dist"
],
"homepage": "https://jhipster.github.io/prettier-java/",
"repository": "https://github.com/jhipster/prettier-java",
"license": "Apache-2.0",
"dependencies": {
Expand Down
7 changes: 7 additions & 0 deletions packages/prettier-plugin-java/src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,5 +239,12 @@ export default {
],
description:
"Prettify from the entrypoint, allowing to use prettier on snippet."
},
trailingComma: {
type: "choice",
category: "Java",
default: "all",
choices: ["all", "none"],
description: "Print trailing commas wherever possible when multi-line."
}
};
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>
94 changes: 94 additions & 0 deletions website/docusaurus.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import type { Options, ThemeConfig } from "@docusaurus/preset-classic";
import type { Config } from "@docusaurus/types";
import { themes } from "prism-react-renderer";
import {
homepage,
repository
} from "../packages/prettier-plugin-java/package.json";

const { origin: url, pathname: baseUrl } = new URL(homepage);
const [, organizationName, projectName] = new URL(repository).pathname.split(
"/"
);
const editUrl = `${repository}/tree/docs/create-website/website/`;

export default {
title: "Prettier Java",
tagline: "Prettier code formatter plugin for Java",
favicon: "img/favicon.png",
trailingSlash: false,
url,
baseUrl,
organizationName,
projectName,
i18n: {
defaultLocale: "en",
locales: ["en"]
},
presets: [
[
"classic",
{
docs: { editUrl },
blog: { editUrl },
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: repository, 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: repository },
{ label: "Issues", to: `${repository}/issues` }
]
}
]
},
prism: {
theme: themes.github,
darkTheme: themes.dracula,
additionalLanguages: ["bash", "java"]
}
} satisfies ThemeConfig
} satisfies Config;
51 changes: 51 additions & 0 deletions website/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"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": {
"@docusaurus/core": "3.1.1",
"@docusaurus/preset-classic": "3.1.1",
"@mdx-js/react": "3.0.0",
"@monaco-editor/react": "4.6.0",
"lz-string": "1.5.0",
"prettier": "3.2.4",
"prettier-plugin-java": "link:./../packages/prettier-plugin-java",
"prism-react-renderer": "2.3.1",
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "3.1.1",
"@docusaurus/tsconfig": "3.1.1",
"@docusaurus/types": "3.1.1",
"@types/react": "18.2.48",
"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 01ec632

Please sign in to comment.