Skip to content

Commit

Permalink
Add Prettier to format Java code
Browse files Browse the repository at this point in the history
Signed-off-by: Jarno Elovirta <[email protected]>
  • Loading branch information
jelovirt committed Apr 6, 2023
1 parent 3d40155 commit 673b0e7
Show file tree
Hide file tree
Showing 6 changed files with 126 additions and 18 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ jobs:
cache: 'gradle'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- name: Check formatting
run: |
npm ci
npm run check-fmt
- name: Build with Gradle
run: ./gradlew
- name: Run unit tests
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build
1 change: 1 addition & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
printWidth: 120
56 changes: 38 additions & 18 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

_DITA Open Toolkit_, or _DITA-OT_ for short, is an open-source publishing engine for content authored in the _Darwin Information Typing Architecture_.

Visit the project website at [dita-ot.org][site] for documentation, information about releases, and [download packages][dist].
Visit the project website at [dita-ot.org][site] for documentation, information about releases, and [download packages][dist].

For information on additional DITA and DITA-OT resources, see [SUPPORT]. To report a bug or suggest a feature, [create an issue][issue]. For more information on how you can help contribute to the project, see [CONTRIBUTING].

Expand All @@ -28,7 +28,9 @@ You can download the OpenJDK from [AdoptOpenJDK][adoptopenjdk].

On macOS and Linux, you can also install DITA-OT using the [Homebrew] package manager:

brew install dita-ot
```shell
brew install dita-ot
```

Homebrew will automatically download the latest version of the toolkit, install it in a subfolder of the local package Cellar and symlink the `dita` command to the `bin` subfolder of the Homebrew installation directory.

Expand All @@ -47,12 +49,14 @@ Homebrew will automatically download the latest version of the toolkit, install
You can generate output using the `dita` command-line tool included with DITA Open Toolkit.

1. On the command line, change to the `bin` folder of the DITA-OT installation directory:

cd path/to/dita-ot-dir/bin

```shell
cd path/to/dita-ot-dir/bin
```
2. Run the `dita` command to generate output:

dita --input=input-file --format=format [options]
```shell
dita --input=input-file --format=format [options]
```

where:

Expand All @@ -67,30 +71,46 @@ See the [documentation][docs] for arguments and [options].
<summary>Building the toolkit from source code and compiling the distribution package</summary>

1. Clone the DITA-OT Git repository:

git clone git://github.com/dita-ot/dita-ot.git

```shell
git clone git://github.com/dita-ot/dita-ot.git
```
2. Change to the DITA-OT directory:
```shell
cd dita-ot
```
3. Fetch the submodules:
```shell
git submodule update --init --recursive
```
4. In the root directory, run Gradle to compile the Java code and install plugins:
```shell
./gradlew
```

cd dita-ot
### Formatting code

3. Fetch the submodules:
Requirements:

git submodule update --init --recursive
- Node.js

4. In the root directory, run Gradle to compile the Java code and install plugins:
Prettier is used retain consistent Java formatting.

./gradlew
1. Run Prettier:
```shell
npm run fmt
```

### Distribution builds

1. In the root directory, set up the build environment:

./gradlew

```shell
./gradlew
```
2. Build the distribution packages:

./gradlew dist
```shell
./gradlew dist
```

Distribution packages are built in the `build/distributions` directory.

Expand Down
69 changes: 69 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"scripts": {
"fmt": "prettier --write '**/*.java'",
"check-fmt": "prettier --check '**/*.java'"
},
"devDependencies": {
"prettier-plugin-java": "^2.1.0"
}
}

0 comments on commit 673b0e7

Please sign in to comment.