Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ConfiguredProperty for documenting "magic" values consistently #293

Merged
merged 8 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config-specs/properties/properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"MIN_VELOCITY_JAVA": "17",
"RECOMMENDED_PAPER_JAVA": "21"
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ With the release of Minecraft 1.18, Paper now requires **Java 17** to run. We re

:::

| Paper Version | Recommended Java Version |
olijeffers0n marked this conversation as resolved.
Show resolved Hide resolved
|----------------|--------------------------|
| 1.8 to 1.11 | Java 8 |
| 1.12 to 1.16.4 | Java 11 |
| 1.16.5 | Java 16 |
| 1.17.1-1.18.1+ | Java 21 |
| Paper Version | Recommended Java Version |
|----------------|------------------------------------------------------------------|
| 1.8 to 1.11 | Java 8 |
| 1.12 to 1.16.4 | Java 11 |
| 1.16.5 | Java 16 |
| 1.17.1-1.18.1+ | Java <ConfiguredProperty propertyKey="RECOMMENDED_PAPER_JAVA" /> |

## Downloading Paper

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This page covers how to install and set up a minimal configuration of Velocity.
## Installing Java

Velocity is written in Java, so if you do not already have Java installed, you will need to install
it before you continue. Velocity requires Java 17 or newer. See our
it before you continue. Velocity requires Java <ConfiguredProperty propertyKey="MIN_VELOCITY_JAVA" /> or newer. See our
[java installation guide](/misc/java-install) for detailed instructions.

## Downloading Velocity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ many of these questions from the user perspective.

## What version of Java does Velocity require?

Velocity 3.3.x requires Java 17 or above.
Velocity 3.3.x requires Java <ConfiguredProperty propertyKey="MIN_VELOCITY_JAVA" /> or above.

## Where can I find Velocity plugins?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ IDEA is recommended.
- Open your IDE
- Click `Create New Project` or the equivalent
- Select either `Gradle` or `Maven`
- Make sure your **Project JDK** is Java 11 or later
- Make sure your **Project JDK** is Java <ConfiguredProperty propertyKey="MIN_VELOCITY_JAVA" /> or later
- **Finish** the dialog and open the project.

Now we have created our project, we need configure our build system.
Expand Down Expand Up @@ -174,7 +174,7 @@ You will be asked to provide some information about your project.
| **Group ID** | The group ID of your project. This is used for Maven and Gradle. This is usually your domain name in reverse. If you don't know what you should put here, you can use something like `io.github.<yourname>` or if you don't have GitHub you can just use `me.<yourname>`. |
| **Artifact ID** | The artifact ID of your project. This is used for Maven and Gradle. This is usually the name of your project. This is usually the same as the `Name` field. |
| **Version** | The version of your project. This is used for Maven and Gradle. This is usually `1.0-SNAPSHOT` and does not really matter for now. |
| **JDK** | The JDK you want to use. This can be anything from Java 11 and above. |
| **JDK** | The JDK you want to use. This can be anything from Java <ConfiguredProperty propertyKey="MIN_VELOCITY_JAVA" /> and above. |

Now you can click on the `Create` button and IntelliJ will create the project for you.
If everything went well, you should see something like this:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ document very carefully**.

## Minimum supported Java version bump

Velocity 3.3.x now requires Java 17 and above.
Velocity 3.3.x now requires Java <ConfiguredProperty propertyKey="MIN_VELOCITY_JAVA" /> and above.

## Removal of legacy dependencies

Expand Down
27 changes: 27 additions & 0 deletions src/components/ConfiguredProperty.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import configuredProperties from '@site/config-specs/properties/properties.json';

const CONFIGURED_PROPERTY_NAMES = Object.keys(configuredProperties);

export function isConfiguredProperty(propertyKey: string): boolean {
olijeffers0n marked this conversation as resolved.
Show resolved Hide resolved
return CONFIGURED_PROPERTY_NAMES.includes(propertyKey);
}

export function getConfiguredProperty(propertyKey: string): string {
olijeffers0n marked this conversation as resolved.
Show resolved Hide resolved
return configuredProperties[propertyKey];
}

export default function ConfiguredProperty({ propertyKey }) {
olijeffers0n marked this conversation as resolved.
Show resolved Hide resolved

if (!isConfiguredProperty(propertyKey)) {
return null;
}

const value = getConfiguredProperty(propertyKey);

return (
<span className="configured-property">
{value}
</span>
);
}
12 changes: 7 additions & 5 deletions src/theme/MDXComponents.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import React from 'react';
import { Icon } from '@iconify/react';
import MDXComponents from '@theme-original/MDXComponents';
import TabItem from "@theme/TabItem";
import Tabs from "@theme/Tabs";
import VersionFormattedCode from '../components/VersionFormattedCode';
import SoftwareVersion from "../components/SoftwareVersion";
import VersionedJavaDocLink from "../components/VersionedJavaDocLink";
import TabItem from '@theme/TabItem';
import Tabs from '@theme/Tabs';
import VersionFormattedCode from '@site/src/components/VersionFormattedCode';
import SoftwareVersion from '@site/src/components/SoftwareVersion';
import VersionedJavaDocLink from '../components/VersionedJavaDocLink';
import ConfiguredProperty from '@site/src/components/ConfiguredProperty';

export default {
// Re-use the default mapping
Expand All @@ -16,5 +17,6 @@ export default {
VersionFormattedCode,
SoftwareVersion,
VersionedJavaDocLink,
ConfiguredProperty,
Icon: Icon,
};