Skip to content

Commit 9d3b412

Browse files
Doc94zlataovce
andauthored
fix: more broken URLs, verify Javadoc links (#598)
* feat: external URL improvements * feat: use legacy bugs site for point to comment jira ticket * fix: format astro.config.ts * feat: remove lint dependency * revert: test broken jd * feat: rework jd markdown checks * fix: jd to incorrect class * fix: jd to incorrect package * revert: another test * chore: add user agent, change error message --------- Co-authored-by: Matouš Kučera <[email protected]>
1 parent 1216ab5 commit 9d3b412

File tree

9 files changed

+92
-13
lines changed

9 files changed

+92
-13
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"devDependencies": {
3333
"@types/mdast": "^4.0.4",
3434
"@types/node": "^22.15.16",
35+
"dead-or-alive": "^1.0.4",
3536
"prettier": "3.5.3",
3637
"prettier-plugin-astro": "0.14.1",
3738
"prettier-plugin-organize-imports": "^4.1.0",

pnpm-lock.yaml

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/content/docs/misc/contact.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ Reach out for support, or contact us on our forums.
1414

1515
- [Forums](https://forums.papermc.io)
1616

17-
## Twitter
17+
## Twitter/X
1818

1919
We often tweet out version release notes, update notices, and other information via our Twitter
2020
page.
2121

22-
- [@PaperPowered](https://twitter.com/PaperPowered)
22+
- [@PaperPowered](https://x.com/PaperPowered)
2323

2424
You should not DM or @ this account for support. It is not checked as regularly as the above
2525
locations.

src/content/docs/paper/dev/api/component-api/intro.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ representations in the legacy string format.
3333
Representing text as components is now the supported way of representing text for Paper and Velocity. They are used
3434
for almost all aspects of text being displayed to clients. Text like item names, lore, bossbars, team prefixes and
3535
suffixes, custom names, and much more all support components in respective APIs.
36-
[Mojang has stated](https://bugs.mojang.com/browse/MC-190605?focusedId=993040&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-993040)
36+
[Mojang has stated](https://bugs-legacy.mojang.com/browse/MC-190605?focusedId=993040&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-993040)
3737
that client support for the legacy format with `§` will be removed in the future.
3838

3939

src/content/docs/paper/dev/api/pdc.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,9 @@ public class UUIDDataType implements PersistentDataType<byte[], UUID> {
156156
:::note
157157

158158
In order to use your own `PersistentDataType`, you must pass an instance of it to the
159-
[`get`](jd:paper:org.bukkit.persistence.PersistentDataContainer#get(org.bukkit.NamespacedKey,org.bukkit.persistence.PersistentDataType))/
159+
[`get`](jd:paper:io.papermc.paper.persistence.PersistentDataContainerView#get(org.bukkit.NamespacedKey,org.bukkit.persistence.PersistentDataType))/
160160
[`set`](jd:paper:org.bukkit.persistence.PersistentDataContainer#set(org.bukkit.NamespacedKey,org.bukkit.persistence.PersistentDataType,C))/
161-
[`has`](jd:paper:org.bukkit.persistence.PersistentDataContainer#has(org.bukkit.NamespacedKey,org.bukkit.persistence.PersistentDataType)) methods.
161+
[`has`](jd:paper:io.papermc.paper.persistence.PersistentDataContainerView#has(org.bukkit.NamespacedKey,org.bukkit.persistence.PersistentDataType)) methods.
162162
```java
163163
container.set(key, new UUIDDataType(), uuid);
164164
```

src/content/docs/paper/dev/misc/databases.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ dependencies {
119119

120120
:::caution
121121

122-
The Hikari library is not bundled with Paper, so you will need to shade/relocate it. In Gradle, you will need to use the [Shadow plugin](https://imperceptiblethoughts.com/shadow/).
122+
The Hikari library is not bundled with Paper, so you will need to shade/relocate it. In Gradle, you will need to use the [Shadow plugin](https://gradleup.com/shadow/).
123123
Alternatively, you can use the library loader with your Paper plugin to load the library at runtime. See [here](/paper/dev/getting-started/paper-plugins#loaders)
124124
for more information on how to use this.
125125

src/content/docs/velocity/admin/reference/libraries.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Velocity uses a number of open-source libraries:
1515
| [adventure](https://github.com/KyoriPowered/adventure) | [KyoriPowered](https://github.com/KyoriPowered) | [MIT License](https://github.com/KyoriPowered/adventure/blob/main/4/license.txt) |
1616
| [Brigadier](https://github.com/Mojang/brigadier) | [Mojang](https://www.minecraft.net) | [MIT License](https://github.com/Mojang/brigadier/blob/master/LICENSE) |
1717
| [event](https://github.com/KyoriPowered/event) | [KyoriPowered](https://github.com/KyoriPowered) | [MIT License](https://github.com/KyoriPowered/event/blob/master/license.txt) |
18-
| [ASM](http://asm.ow2.org/) | [OW2](https://www.ow2.org/) | [BSD 3-Clause License](http://asm.ow2.io/license.html) |
18+
| [ASM](https://asm.ow2.io/) | [OW2](https://asm.ow2.io/) | [BSD 3-Clause License](https://asm.ow2.io/license.html) |
1919
| [SLF4J](https://github.com/qos-ch/slf4j) | [SLF4J](https://www.slf4j.org/) | [MIT License](https://github.com/qos-ch/slf4j/blob/master/LICENSE.txt) |
2020
| [Log4j](https://logging.apache.org/log4j/2.x/) | [Log4j Team](https://logging.apache.org/log4j/2.3.x/log4j-web/team-list) | [Apache License 2.0](https://logging.apache.org/log4j/2.12.x/license.html) |
2121
| [TerminalConsoleAppender](https://github.com/Minecrell/TerminalConsoleAppender) | [Minecrell](https://github.com/Minecrell) | [MIT License](https://github.com/Minecrell/TerminalConsoleAppender/blob/master/LICENSE) |
@@ -24,7 +24,7 @@ Velocity uses a number of open-source libraries:
2424
| [HOCON](https://github.com/lightbend/config) | [lightbend](https://github.com/lightbend) | [Apache License 2.0](https://github.com/lightbend/config/blob/master/LICENSE-2.0.txt) |
2525
| [toml4j](https://github.com/mwanji/toml4j) | [Moandji Ezana](https://github.com/mwanji) | [MIT License](https://github.com/mwanji/toml4j/blob/master/LICENSE) |
2626
| [Night-Config](https://github.com/TheElectronWill/night-config) | [TheElectronWill](https://github.com/TheElectronWill) | [GNU Lesser General Public License 3.0](https://github.com/TheElectronWill/night-config/blob/master/LICENSE) |
27-
| [fastutil](http://fastutil.di.unimi.it/) | [Sebastiano Vigna](http://vigna.di.unimi.it/) | [Apache License 2.0](https://github.com/vigna/fastutil/blob/master/LICENSE-2.0) |
27+
| [fastutil](https://fastutil.di.unimi.it/) | [Sebastiano Vigna](https://vigna.di.unimi.it/) | [Apache License 2.0](https://github.com/vigna/fastutil/blob/master/LICENSE-2.0) |
2828
| [JLine](https://github.com/jline/jline3/blob/master/LICENSE.txt) | [JLine project](https://github.com/jline/jline3) | [BSD 3-Clause License](https://github.com/jline/jline3/blob/master/LICENSE.txt) |
2929
| [AsyncHttpClient](https://github.com/AsyncHttpClient/async-http-client) | [Stephane Landelle](https://github.com/slandelle) | [Apache License 2.0](https://github.com/AsyncHttpClient/async-http-client/blob/master/LICENSE.txt) |
3030
| [completable-futures](https://github.com/spotify/completable-futures) | [Spotify](https://github.com/spotify) | [Apache License 2.0](https://github.com/spotify/completable-futures/blob/master/LICENSE) |

src/content/docs/velocity/dev/api/event.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ You'll notice that your events don't need to extend or implement anything. They
219219

220220
To fire the event, you'll need to get the server's event manager and use the
221221
[`fire`](jd:velocity:com.velocitypowered.api.event.EventManager#fire(E))
222-
method. Note that this returns a [`CompletableFuture`](jd:velocity:java.util.concurrent.CompletableFuture),
222+
method. Note that this returns a [`CompletableFuture`](jd:java:java.util.concurrent.CompletableFuture),
223223
so if you want to continue logic after the event is handled by all listeners, use a callback:
224224

225225
```java

src/utils/remark/javadoc.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { RemarkPlugin } from "@astrojs/markdown-remark";
2+
import { deadOrAlive } from "dead-or-alive";
23
import { visit } from "unist-util-visit";
34

45
// replaces special Markdown links with Javadoc URLs
@@ -20,7 +21,7 @@ const asUrl = (name: string): string => {
2021
return `${name0}.html` + (hash ? `#${hash}` : "");
2122
};
2223

23-
const parse = (url: string, { targets }: Options): string | null => {
24+
const parse = async (url: string, { targets }: Options): Promise<string | null> => {
2425
const match = /^jd:(.+?)(?::(.+?))?(?::(.+?))?$/.exec(url);
2526
if (!match) {
2627
return null;
@@ -40,14 +41,31 @@ const parse = (url: string, { targets }: Options): string | null => {
4041

4142
const module = match[3] ? match[2] : typeof target !== "string" ? target.module : undefined;
4243

43-
return `${targetUrl}/${module ? `${module}/` : ""}${asUrl(name)}`;
44+
const parsed: string = `${targetUrl}/${module ? `${module}/` : ""}${asUrl(name)}`;
45+
46+
const result = await deadOrAlive(parsed, {
47+
findUrls: false,
48+
followMetaHttpEquiv: false,
49+
userAgent: "PaperMC/docs (https://docs.papermc.io)",
50+
});
51+
if (result.status !== "alive") {
52+
throw new Error(`Javadoc link "${url}" is not valid`);
53+
}
54+
55+
return parsed;
4456
};
4557

4658
const plugin: RemarkPlugin = (options: Options) => {
47-
return (tree) => {
59+
return async (tree) => {
60+
const promises: Promise<void>[] = [];
4861
visit(tree, "link", (node) => {
49-
node.url = parse(node.url, options) ?? node.url;
62+
promises.push(
63+
parse(node.url, options).then((url) => {
64+
node.url = url ?? node.url;
65+
})
66+
);
5067
});
68+
await Promise.all(promises);
5169
};
5270
};
5371

0 commit comments

Comments
 (0)