Skip to content

Commit ac93ea0

Browse files
committed
Update documentation and improve build setup
1 parent 13abb73 commit ac93ea0

File tree

8 files changed

+64
-32
lines changed

8 files changed

+64
-32
lines changed

.github/workflows/deploy-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Generate API Documentation
3939
run: |
4040
pnpm typedoc
41-
sed -i '1s/^/# API Documentation\n\n/' docs/api/index.md
41+
./postprocess_docs.sh
4242
- run: pnpm docs:build
4343
- name: Upload artifact
4444
uses: actions/upload-pages-artifact@v3

README.md

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,45 @@
22

33
[![](https://badge.fury.io/js/uinh-kyaengh.svg)](https://www.npmjs.com/package/uinh-kyaengh) [![](https://data.jsdelivr.com/v1/package/npm/uinh-kyaengh/badge)](https://www.jsdelivr.com/package/npm/uinh-kyaengh) [![](https://github.com/nk2028/uinh-kyaengh-js/workflows/Publish/badge.svg)](https://github.com/nk2028/uinh-kyaengh-js/actions?query=workflow%3A%22Publish%22)
44

5-
A JavaScript library for the _Yunjing_ (韻鏡) system
5+
UinhKyaengh.js is a JavaScript library for working with 韻鏡系韻圖, specifically 韻鏡 and 七音略. It provides a formalised, programmatic representation of traditional rime tables and enables bidirectional conversion between 韻鏡位置 and [TshetUinh.js](https://github.com/nk2028/tshet-uinh-js) 音韻地位.
6+
7+
The core abstraction of this library is the 韻鏡位置 object. A 韻鏡位置 is defined by a three-dimensional coordinate system consisting of 轉號, 上位, and 右位. From this representation, the library can generate canonical descriptions, perform structural analysis, and interoperate with the 音韻地位 model used in TshetUinh.js.
8+
9+
This library is designed for researchers, developers, and students who require a precise model of traditional Chinese rime tables.
10+
11+
## Installation
12+
13+
```sh
14+
npm install uinh-kyaengh
15+
```
16+
17+
## Basic Usage
18+
19+
### Creating a 韻鏡位置
20+
21+
A 韻鏡位置 can be instantiated directly from its coordinates (轉號, 上位, 右位). The object exposes a human-readable description that follows the traditional terminology of 韻鏡.
22+
23+
```javascript
24+
const 當前韻鏡位置 = new 韻鏡位置(42, 15, 7); // 「直」
25+
console.log(當前韻鏡位置.描述); // 外轉第四十二圖·舌音第三位·入聲位·韻鏡三等
26+
```
27+
28+
### Converting 音韻地位 to 韻鏡位置
29+
30+
UinhKyaengh.js supports conversion from TshetUinh.js 音韻地位 objects into 韻鏡位置. This allows existing phonological analyses based on TshetUinh.js to be projected directly onto the 韻鏡 framework.
31+
32+
```javascript
33+
const 當前音韻地位 = 音韻地位.from描述('澄開三蒸入'); // 「直」
34+
const 當前韻鏡位置 = 音韻地位2韻鏡位置(當前音韻地位);
35+
console.log(當前韻鏡位置.坐標); // (42,15,7)
36+
```
37+
38+
### Converting 韻鏡位置 to 音韻地位
39+
40+
A 韻鏡位置 object can also be converted back into a TshetUinh.js 音韻地位. This makes the mapping between the two systems reversible within the supported domain.
41+
42+
```javascript
43+
const 當前韻鏡位置 = new 韻鏡位置(42, 15, 7); // 「直」
44+
const 當前音韻地位 = 當前韻鏡位置.to音韻地位();
45+
console.log(當前音韻地位.描述); // 澄開三蒸入
46+
```

docs/.vitepress/config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ export default defineConfig({
99
themeConfig: {
1010
nav: [
1111
{ text: 'Home', link: '/' },
12-
{ text: 'Introduction', link: '/guide/introduction' },
13-
{ text: 'API Documentation', link: '/api/' },
12+
{ text: 'Introduction', link: '/api/' },
13+
{ text: 'API Documentation', link: '/api/globals' },
1414
],
1515

1616
sidebar: {
1717
'/': [
1818
{
1919
text: 'Get Started',
2020
items: [
21-
{ text: 'Introduction', link: '/guide/introduction' },
22-
{ text: 'API Documentation', link: '/api/' },
21+
{ text: 'Introduction', link: '/api/' },
22+
{ text: 'API Documentation', link: '/api/globals' },
2323
],
2424
},
2525
],

docs/guide/introduction.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/index.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ hero:
55
name: UinhKyaengh.js
66
tagline: A JavaScript library for the <i>Yunjing</i> (韻鏡) system
77
actions:
8-
- theme: brand
9-
text: Get Started
10-
link: /guide/introduction
11-
- theme: alt
12-
text: View on GitHub
13-
link: https://github.com/nk2028/uinh-kyaengh-js
8+
- theme: brand
9+
text: Get Started
10+
link: /api/
11+
- theme: alt
12+
text: View on GitHub
13+
link: https://github.com/nk2028/uinh-kyaengh-js
1414

1515
# features:
1616
# - title: 特性一
@@ -19,4 +19,4 @@ hero:
1919
# details: 描述
2020
# - title: 特性三
2121
# details: 描述
22-
---
22+
---

postprocess_docs.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
sed -i '2{N; /\n\[!\[\](.*)$/d; P; D; }' docs/api/index.md # Remove badge line
3+
sed -i '1s/^# uinh-kyaengh$/# API Documentation/' docs/api/globals.md # Rename title

src/core/韻鏡位置.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ export const 鈍音母 = [...'幫滂並明見溪羣疑影曉匣云'] as const;
2626
* - 右位:在一個轉中,從右向左數的位置(1–23)。
2727
*/
2828
class 韻鏡位置 {
29-
/** 轉的序號(1–43) */
29+
/** 轉的序號(1–43) */
3030
轉號: number;
3131

32-
/** 在一個轉中,從上向下數的位置(1–16) */
32+
/** 在一個轉中,從上向下數的位置(1–16) */
3333
上位: number;
3434

35-
/** 在一個轉中,從右向左數的位置(1–23) */
35+
/** 在一個轉中,從右向左數的位置(1–23) */
3636
右位: number;
3737

3838
/**
3939
* 建立一個韻鏡位置。
4040
*
41-
* @throws 若任何座標超出韻鏡合法範圍
41+
* @throws 若任何取值超出韻鏡範圍
4242
*/
4343
constructor(轉號: number, 上位: number, 右位: number) {
4444
if (轉號 < 1 || 轉號 > 43) {
@@ -64,7 +64,7 @@ class 韻鏡位置 {
6464
}
6565

6666
/**
67-
* 坐標字串表示(如「(1,1,1)」)。
67+
* 坐標的字串表示(如「(1,1,1)」)。
6868
*/
6969
@cached
7070
get 坐標() {

typedoc.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
"entryFileName": "index.md",
77
"hidePageHeader": true,
88
"hideBreadcrumbs": true,
9-
"hidePageTitle": true,
10-
"useCodeBlocks": true,
11-
"readme": "none",
12-
"excludePrivate": true,
13-
"excludeInternal": true
9+
"hidePageTitle": false,
10+
"useCodeBlocks": true
1411
}

0 commit comments

Comments
 (0)