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: add errors reference page #2515

Closed
wants to merge 4 commits into from
Closed
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
3 changes: 2 additions & 1 deletion .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const nav: ThemeConfig['nav'] = [
{ text: 'Quick Start', link: '/guide/quick-start' },
// { text: 'Style Guide', link: '/style-guide/' },
{ text: 'Glossary', link: '/glossary/' },
{ text: 'Error Reference', link: '/errors/' },
{
text: 'Vue 2 Docs',
link: 'https://v2.vuejs.org'
Expand Down Expand Up @@ -695,7 +696,7 @@ export default defineConfigWithTheme<ThemeConfig>({
markdown: {
config(md) {
md.use(headerPlugin)
// .use(textAdPlugin)
// .use(textAdPlugin)
}
},

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
"devDependencies": {
"@types/markdown-it": "^12.2.3",
"@types/node": "^16.9.1",
"@vue/compiler-core": "npm:@vue/compiler-core-canary@minor",
"@vue/runtime-core": "npm:@vue/runtime-core-canary@minor",
"terser": "^5.14.2"
},
"pnpm": {
Expand Down
65 changes: 45 additions & 20 deletions pnpm-lock.yaml

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

34 changes: 34 additions & 0 deletions src/errors/ErrorsTable.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<script setup lang="ts">
defineProps<{
kind: string
errors: Record<any, string>
highlight?: any
}>()
</script>

<template>
<table>
<thead>
<tr>
<th>Code</th>
<th>Message</th>
</tr>
</thead>
<tbody>
<tr
v-for="(msg, code) of errors"
:class="{ highlight: highlight === `${kind}-${code}` }"
>
<td :id="`${kind}-${code}`" v-text="code" />
<td v-text="msg" />
</tr>
</tbody>
</table>
</template>

<style scoped>
.highlight {
color: var(--vt-c-yellow-darker);
font-weight: bold;
}
</style>
14 changes: 14 additions & 0 deletions src/errors/errors.data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { defineLoader } from 'vitepress'
import { errorMessages } from '@vue/compiler-core'

function filterEmptyMsg(data: Record<number, string>) {
return Object.fromEntries(Object.entries(data).filter(([_, msg]) => msg))
}

export default defineLoader({
load() {
return {
compiler: filterEmptyMsg(errorMessages)
}
}
})
16 changes: 16 additions & 0 deletions src/errors/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script setup>
import { ref, onMounted } from 'vue'
import { data } from './errors.data.ts'
import ErrorsTable from './ErrorsTable.vue'

const highlight = ref()
onMounted(() => {
highlight.value = location.hash.slice(1)
})
</script>

# Error Reference {#error-reference}

## Compiler Errors {#compiler-errors}

<ErrorsTable kind="compiler" :errors="data.compiler" :highlight="highlight" />