Skip to content

Commit ba58858

Browse files
committed
feat: new config viewer!
1 parent d607a68 commit ba58858

File tree

8 files changed

+609
-300
lines changed

8 files changed

+609
-300
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// modified from https://github.com/LeavesMC/Documentation , original license is MPL-2.0
2+
3+
import * as fs from 'fs'
4+
import * as yaml from 'yaml'
5+
import { createMarkdownRenderer } from 'vitepress'
6+
import config from '../config.mjs'
7+
8+
// noinspection JSUnusedGlobalSymbols
9+
export default {
10+
async load() {
11+
const raw = yaml.parse(
12+
fs.readFileSync('./docs/.vitepress/config-spec/en.yml', 'utf-8')
13+
)
14+
const md = await createMarkdownRenderer(config.srcDir, config.markdown)
15+
16+
function render(x: any): any {
17+
for (const key in x) {
18+
if (typeof x[key] == 'object') {
19+
x[key] = render(x[key])
20+
} else {
21+
if (key == 'content' || key == 'description') {
22+
x[key] = md.render(x[key])
23+
}
24+
}
25+
}
26+
return x
27+
}
28+
29+
return render(raw)
30+
},
31+
}

docs/.vitepress/config-spec/en.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
verbose-outputs:
2+
default: false
3+
description: If `true`, outputs command registration and unregistration logs in the console
4+
silent-logs:
5+
default: false
6+
description: If `true`, turns off all logging from the CommandAPI, except for errors
7+
messages:
8+
missing-executor-implementation:
9+
default: "This command has no implementations for %s"
10+
description: |
11+
The message to display to senders when a command has no executor.
12+
13+
Available parameters are:
14+
`%s` - the executor class (lowercase) e.g. `craftplayer`
15+
`%S` - the executor class (normal case) e.g. `CraftPlayer`
16+
create-dispatcher-json:
17+
default: false
18+
description: |
19+
If `true`, the CommandAPI creates a `command_registration.json` file showing the mapping of registered commands.
20+
21+
This is designed to be used by developers - setting this to `false` will improve command registration performance.
22+
23+
The `command_registration.json` JSON representation of commands is in the same format as Minecraft's [_Data Generators_ Commands report](https://wiki.vg/Data_Generators#Commands_report).
24+
25+
The format is Brigadier's command graph - more information about the JSON format can be found [here](https://wiki.vg/Command_Data).
26+
use-latest-nms-version:
27+
default: false
28+
description: |
29+
Controls whether the CommandAPI should use the latest NMS implementation for command registration and execution.
30+
31+
This setting can be used to run the CommandAPI on Minecraft versions higher than it can support.
32+
33+
For example, if the CommandAPI supports Minecraft 1.18 and Minecraft 1.18.1 comes out, you can use this to enable support for 1.18.1 before an official CommandAPI release comes out that supports 1.18.1.
34+
35+
::: warning
36+
This feature is very experimental and should only be used if you know what you are doing.
37+
38+
In almost every case, it is better to wait for an official CommandAPI release that supports the latest version of Minecraft.
39+
40+
Using `use-latest-nms-version` is _not_ guaranteed to work and can cause unexpected side effects!
41+
:::
42+
be-lenient-for-minor-versions:
43+
default: false
44+
description: |
45+
Controls whether the CommandAPI should be more lenient when updating to a new Minecraft version.
46+
47+
Similar to the [`use-latest-nms-version`](#use-latest-nms-version) setting, this can allow the CommandAPI to run on a version higher than it officially supports.
48+
49+
As an example, this setting can allow updating to 1.21.2 from 1.21.1 but doesn't allow updating to 1.22 from 1.21.2.
50+
51+
::: warning
52+
53+
Take the warning from the [`use-latest-nms-version`](#use-latest-nms-version) and apply it here too. This is _not_ guaranteed to work either and also may cause unexpected side effects.
54+
55+
:::
56+
hook-paper-reload:
57+
default: true
58+
description: |
59+
Controls whether the CommandAPI hooks into the Paper-exclusive `ServerResourcesReloadedEvent` when available.
60+
61+
When the CommandAPI detects it is running on a Paper-based server, its default behavior will be to hook into the `ServerResourcesReloadedEvent`, which triggers when `/minecraft:reload` is run. During this event, the CommandAPI runs a custom datapack reloading sequence that helps commands registered with the CommandAPI work within datapacks. See [Reloading datapacks](./internal#reloading-datapacks) for more information on this process.
62+
63+
By default, this value is set to `true` and the CommandAPI will hook into the `ServerResourcesReloadedEvent`. If you want, you can set this to `false`, and the CommandAPI will not hook into this event.
64+
skip-initial-datapack-reload:
65+
default: false
66+
description: |
67+
Controls whether the CommandAPI should perform its initial datapack reload when the server has finished loading.
68+
69+
The CommandAPI automatically reloads all datapacks in a similar fashion to `/minecraft:reload` in order to propagate CommandAPI commands into datapack functions and tags. This operation may cause a slight delay to server startup and is not necessary if you are not using datapacks or functions that use CommandAPI commands. This operation can be skipped by setting this value to `true`.
70+
71+
Note that datapacks will still be reloaded if performed manually when `hook-paper-reload` is set to `true` and you run `/minecraft:reload`.
72+
plugins-to-convert:
73+
default: '[]'
74+
description: |
75+
Controls the list of plugins to process for command conversion.
76+
77+
See [Command conversion](command-conversion/conversion) for more information.
78+
other-commands-to-convert:
79+
default: '[]'
80+
description: |
81+
A list of other commands to convert. This should be used for commands which are not declared in a `plugin.yml` file.
82+
83+
See [Arbitrary command conversion](command-conversion/single-command#arbitrary-command-conversion) for more information.
84+
skip-sender-proxy:
85+
default: '[]'
86+
description: |
87+
Determines whether the proxy sender should be skipped when converting a command.
88+
89+
See [Skipping proxy senders](command-conversion/skip-proxy-senders.md) for more information.
Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
<!--copied from https://github.com/LeavesMC/Documentation , original license is MPL-2.0-->
2+
3+
<script setup lang="ts">
4+
import ConfigViewerNode from './ConfigViewerNode.vue'
5+
import { Ref, ref } from 'vue'
6+
import IconExpand from './icons/IconExpand.vue'
7+
import IconCollapse from './icons/IconCollapse.vue'
8+
9+
const props = defineProps({
10+
data: Object,
11+
name: String,
12+
})
13+
14+
const node: Ref<ConfigViewerNode> = ref()
15+
16+
function expandAll() {
17+
node.value.expandAll()
18+
}
19+
20+
function collapseAll() {
21+
node.value.collapseAll()
22+
}
23+
</script>
24+
25+
<template>
26+
<div class="config-lang-yml vp-adaptive-theme">
27+
<span class="lang"
28+
>{{ name }}
29+
<div style="text-align: end; display: flex; flex-wrap: nowrap; gap: 8px; margin-left: 6px; margin-top: 6px;">
30+
<IconExpand role="button" aria-label="Expand all" @click="expandAll" style="width: 20px; height: 20px" />
31+
<IconCollapse role="button" aria-label="Collapse all" @click="collapseAll" style="width: 20px; height: 20px" />
32+
</div>
33+
</span>
34+
<pre
35+
class="shiki shiki-themes github-light github-dark vp-code"
36+
><code class="config-code-block"><ConfigViewerNode
37+
ref="node" :data="data" :padding="false" parent="" /></code></pre>
38+
</div>
39+
</template>
40+
41+
<style>
42+
.config-code-block {
43+
display: block;
44+
padding: 0 24px;
45+
width: fit-content;
46+
min-width: 100%;
47+
line-height: var(--vp-code-line-height);
48+
font-size: var(--vp-code-font-size);
49+
color: var(--vp-code-block-color);
50+
transition: color 0.5s;
51+
52+
font-weight: 400;
53+
background-color: transparent;
54+
55+
/*rtl:ignore*/
56+
direction: ltr;
57+
/*rtl:ignore*/
58+
text-align: left;
59+
white-space: pre;
60+
word-spacing: normal;
61+
word-break: normal;
62+
word-wrap: normal;
63+
-moz-tab-size: 4;
64+
-o-tab-size: 4;
65+
tab-size: 4;
66+
-webkit-hyphens: none;
67+
-moz-hyphens: none;
68+
-ms-hyphens: none;
69+
hyphens: none;
70+
}
71+
72+
.vp-doc .custom-block div[class*='config-lang-'] {
73+
margin: 8px 0;
74+
border-radius: 8px;
75+
}
76+
77+
.vp-doc div[class*='config-lang-'] {
78+
position: relative;
79+
margin: 16px -24px;
80+
background-color: var(--vp-code-block-bg);
81+
overflow-x: auto;
82+
transition: background-color 0.5s;
83+
}
84+
85+
@media (min-width: 640px) {
86+
.vp-doc div[class*='config-lang-'] {
87+
border-radius: 8px;
88+
margin: 16px 0;
89+
}
90+
}
91+
92+
@media (max-width: 639px) {
93+
.vp-doc li div[class*='config-lang-'] {
94+
border-radius: 8px 0 0 8px;
95+
}
96+
}
97+
98+
.vp-doc div[class*='config-lang-'] + div[class*='config-lang-'],
99+
.vp-doc div[class$='-api'] + div[class*='config-lang-'],
100+
.vp-doc
101+
div[class*='config-lang-']
102+
+ div[class$='-api']
103+
> div[class*='config-lang-'] {
104+
margin-top: -8px;
105+
}
106+
107+
.vp-doc [class*='config-lang-'] pre {
108+
/*rtl:ignore*/
109+
direction: ltr;
110+
/*rtl:ignore*/
111+
text-align: left;
112+
white-space: pre;
113+
word-spacing: normal;
114+
word-break: normal;
115+
word-wrap: normal;
116+
-moz-tab-size: 4;
117+
-o-tab-size: 4;
118+
tab-size: 4;
119+
-webkit-hyphens: none;
120+
-moz-hyphens: none;
121+
-ms-hyphens: none;
122+
hyphens: none;
123+
}
124+
125+
.vp-doc [class*='config-lang-'] pre {
126+
position: relative;
127+
z-index: 1;
128+
margin: 0;
129+
padding: 20px 0;
130+
background: transparent;
131+
overflow-x: auto;
132+
}
133+
134+
.vp-doc [class*='config-lang-'] .has-focused-lines .line:not(.has-focus) {
135+
filter: blur(0.095rem);
136+
opacity: 0.4;
137+
transition:
138+
filter 0.35s,
139+
opacity 0.35s;
140+
}
141+
142+
.vp-doc [class*='config-lang-'] .has-focused-lines .line:not(.has-focus) {
143+
opacity: 0.7;
144+
transition:
145+
filter 0.35s,
146+
opacity 0.35s;
147+
}
148+
149+
.vp-doc [class*='config-lang-'] > button.copy {
150+
/*rtl:ignore*/
151+
direction: ltr;
152+
position: absolute;
153+
top: 12px;
154+
/*rtl:ignore*/
155+
right: 12px;
156+
z-index: 3;
157+
border: 1px solid var(--vp-code-copy-code-border-color);
158+
border-radius: 4px;
159+
width: 40px;
160+
height: 40px;
161+
background-color: var(--vp-code-copy-code-bg);
162+
opacity: 0;
163+
cursor: pointer;
164+
background-image: var(--vp-icon-copy);
165+
background-position: 50%;
166+
background-size: 20px;
167+
background-repeat: no-repeat;
168+
transition:
169+
border-color 0.25s,
170+
background-color 0.25s,
171+
opacity 0.25s;
172+
}
173+
174+
.vp-doc [class*='config-lang-']:hover > button.copy,
175+
.vp-doc [class*='config-lang-'] > button.copy:focus {
176+
opacity: 1;
177+
}
178+
179+
.vp-doc [class*='config-lang-'] > button.copy:hover,
180+
.vp-doc [class*='config-lang-'] > button.copy.copied {
181+
border-color: var(--vp-code-copy-code-hover-border-color);
182+
background-color: var(--vp-code-copy-code-hover-bg);
183+
}
184+
185+
.vp-doc [class*='config-lang-'] > button.copy.copied,
186+
.vp-doc [class*='config-lang-'] > button.copy:hover.copied {
187+
/*rtl:ignore*/
188+
border-radius: 0 4px 4px 0;
189+
background-color: var(--vp-code-copy-code-hover-bg);
190+
background-image: var(--vp-icon-copied);
191+
}
192+
193+
.vp-doc [class*='config-lang-'] > button.copy.copied::before,
194+
.vp-doc [class*='config-lang-'] > button.copy:hover.copied::before {
195+
position: relative;
196+
top: -1px;
197+
/*rtl:ignore*/
198+
transform: translateX(calc(-100% - 1px));
199+
display: flex;
200+
justify-content: center;
201+
align-items: center;
202+
border: 1px solid var(--vp-code-copy-code-hover-border-color);
203+
/*rtl:ignore*/
204+
border-right: 0;
205+
border-radius: 4px 0 0 4px;
206+
padding: 0 10px;
207+
width: fit-content;
208+
height: 40px;
209+
text-align: center;
210+
font-size: 12px;
211+
font-weight: 500;
212+
color: var(--vp-code-copy-code-active-text);
213+
background-color: var(--vp-code-copy-code-hover-bg);
214+
white-space: nowrap;
215+
content: var(--vp-code-copy-copied-text-content);
216+
}
217+
218+
.vp-doc [class*='config-lang-'] > span.lang {
219+
position: absolute;
220+
top: 2px;
221+
/*rtl:ignore*/
222+
right: 8px;
223+
z-index: 2;
224+
font-size: 12px;
225+
font-weight: 500;
226+
color: var(--vp-code-lang-color);
227+
transition:
228+
color 0.4s,
229+
opacity 0.4s;
230+
}
231+
232+
.vp-doc [class*='config-lang-']:hover > button.copy + span.lang,
233+
.vp-doc [class*='config-lang-'] > button.copy:focus + span.lang {
234+
opacity: 0;
235+
}
236+
</style>

0 commit comments

Comments
 (0)