Skip to content

Commit

Permalink
docs: es-hangul의 신뢰성을 나타낼 수 있는 문서를 만듭니다 (#302)
Browse files Browse the repository at this point in the history
* docs: 신뢰성 문서를 작성합니다.

* coverage 파일을 사용하여 동적으로 커버리지 퍼센트를 나타냅니다

* apiList 상수 이름 변경

* scripts 복구

* gitignore에 coverage 재추가

* constants 경로를 단순화합니다

* 코드를 매끄럽게 풀어나갑니다

---------

Co-authored-by: 박찬혁 <[email protected]>
  • Loading branch information
po4tion and okinawaa authored Jan 2, 2025
1 parent 8b90c82 commit 102f1e2
Show file tree
Hide file tree
Showing 17 changed files with 204 additions and 19 deletions.
14 changes: 14 additions & 0 deletions docs/src/pages/docs/advantages/reliability.en.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: reliability
---

import Reliability from './reliability.tsx';

# 💯 Providing High Reliability

`es-hangul` has achieved <b>100% test coverage</b> by adopting a testing framework. This means that all features of the library have been thoroughly verified, minimizing unexpected errors. Built on high reliability, it offers stable and predictable performance, so you can confidently incorporate it into your projects. Experience a new standard in Hangul processing by utilizing `es-hangul` now!

<br />
<br />

<Reliability locale="en" />
14 changes: 14 additions & 0 deletions docs/src/pages/docs/advantages/reliability.ko.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: reliability
---

import Reliability from './reliability.tsx';

# 💯 높은 신뢰성 제공

`es-hangul`은 테스팅 프레임워크를 도입하여 <b>테스트 커버리지 100%</b>를 달성하였습니다. 이는 라이브러리의 모든 기능이 철저하게 검증되었음을 의미하며, 예기치 않은 오류를 최소화합니다. 높은 신뢰성을 바탕으로 안정적이고 예측 가능한 성능을 제공하므로, 안심하고 프로젝트에 도입하실 수 있습니다. 지금 `es-hangul`을 활용하여 한글 처리의 새로운 기준을 경험해 보세요!

<br />
<br />

<Reliability locale="ko" />
162 changes: 162 additions & 0 deletions docs/src/pages/docs/advantages/reliability.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
import coverageJSON from '../../../../../coverage/coverage-summary.json';

type Locale = 'ko' | 'en';

interface TypeSupportTableProps {
locale: Locale;
}

export default function Reliability({ locale }: TypeSupportTableProps) {
const isKorean = locale === 'ko';
const statements = isKorean ? '문장' : 'Statements';
const branches = isKorean ? '브랜치' : 'Branches';
const functions = isKorean ? '함수' : 'Functions';
const lines = isKorean ? '라인' : 'Lines';

const { total: totalCoverage, ...fileEntries } = coverageJSON;

const isValidFilePath = (filePath: string): boolean => {
// src 뒤 2-depth까지의 경로를 필터링하며, anything.something.ts 등의 명칭을 가진 파일들은 반환되지 않도록 `.ts`로 끝나되 추가 점(`.`)이 없는 경우만 허용
const regex = /\/src\/[^/]+\/[^/]+(?<!\..+)\.ts$/;

return regex.test(filePath) && !filePath.endsWith('constants.ts') && !filePath.includes('_internal');
};

const extractFileName = (filePath: string): string | undefined => {
return filePath.split('/').pop()?.split('.')[0];
};

const filterValidFileEntries = (coverageFileEntries: typeof fileEntries) => {
return Object.entries(coverageFileEntries)
.filter(([filePath]) => isValidFilePath(filePath))
.flatMap(([filePath, info]) => {
const filename = extractFileName(filePath);

return filename != null ? [[filename, info] as const] : [];
});
};

return (
<div>
<div className="overflow-x-auto mb-10">
<table className="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400">
<caption className="caption-top text-sm">
{isKorean ? 'es-hangul의 테스트 커버리지 항목' : "es-hangul's test coverage item"}
</caption>

<thead className="text-xs text-gray-700 bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
<tr>
<th scope="col" className="px-6 py-3">
{isKorean ? '테스트 커버리지 항목' : 'Test coverage item'}
</th>
<th scope="col" className="px-6 py-3">
{isKorean ? '커버리지 비율' : 'Coverage percentage'}
</th>
</tr>
</thead>

<tbody>
<tr className="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
<th scope="row" className="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
{statements}
<br />
<span className="text-gray-500 text-xs">
ℹ️&nbsp;
{isKorean
? '코드에서 실행 가능한 모든 문장이 테스트에서 실행되었는지'
: 'Whether all executable statements in the code have been executed during testing'}
</span>
</th>
<td className="px-6 py-4">✅ ({totalCoverage.statements.pct}%)</td>
</tr>

<tr className="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
<th scope="row" className="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
{branches}
<br />
<span className="text-gray-500 text-xs">
ℹ️&nbsp;
{isKorean
? '조건문(if, else, switch 등)에서 발생하는 모든 분기 경로가 테스트되었는지'
: 'Whether all branching paths in conditional statements (if, else, switch, etc.) have been tested'}
</span>
</th>
<td className="px-6 py-4">✅ ({totalCoverage.branches.pct}%)</td>
</tr>

<tr className="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
<th scope="row" className="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
{functions}
<br />
<span className="text-gray-500 text-xs">
ℹ️&nbsp;
{isKorean
? '코드 내의 모든 함수가 테스트에서 호출되었는지'
: 'Whether all functions within the code have been called during testing'}
</span>
</th>
<td className="px-6 py-4">✅ ({totalCoverage.functions.pct}%)</td>
</tr>

<tr className="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
<th scope="row" className="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
{lines}
<br />
<span className="text-gray-500 text-xs">
ℹ️&nbsp;
{isKorean
? '소스 코드의 각 라인이 테스트에서 실행되었는지'
: 'Whether each line of the source code has been executed during testing'}
</span>
</th>
<td className="px-6 py-4">✅ ({totalCoverage.lines.pct}%)</td>
</tr>
</tbody>
</table>
</div>

<div className="overflow-x-auto">
<table className="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400">
<caption className="caption-top text-sm">
{isKorean ? 'es-hangul의 테스트 커버리지 현황' : "es-hangul's test coverage status"}
</caption>

<thead className="text-xs text-gray-700 bg-gray-50 dark:bg-gray-700 dark:text-gray-400">
<tr>
<th scope="col" className="px-6 py-3">
API
</th>
<th scope="col" className="px-6 py-3">
{statements}
</th>
<th scope="col" className="px-6 py-3">
{branches}
</th>
<th scope="col" className="px-6 py-3">
{functions}
</th>
<th scope="col" className="px-6 py-3">
{lines}
</th>
</tr>
</thead>

<tbody>
{filterValidFileEntries(fileEntries).map(([filename, info]) => (
<tr key={filename} className="bg-white border-b dark:bg-gray-800 dark:border-gray-700">
<th scope="row" className="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
<a href={`../api/${filename}`}>{filename} 🔗</a>
</th>

<td className="px-6 py-4">✅ ({info.statements.pct}%)</td>
<td className="px-6 py-4">✅ ({info.branches.pct}%)</td>
<td className="px-6 py-4">✅ ({info.functions.pct}%)</td>
<td className="px-6 py-4">✅ ({info.lines.pct}%)</td>
</tr>
))}
</tbody>
</table>
</div>
</div>
);
}
2 changes: 1 addition & 1 deletion docs/src/pages/docs/introduction.ko.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ ECMAScript Modules를 이용하여 사용하는 함수만 애플리케이션에

### 신뢰할 수 있습니다

우리는 커버리지 100%를 목표로 모든 기능을 테스트하기 위해 노력하고 있습니다.
우리는 커버리지 100%를 목표로 모든 기능을 테스트하기 위해 [노력하고 있습니다](./advantages/reliability).
[![codecov](https://codecov.io/gh/toss/es-hangul/branch/main/graph/badge.svg?token=토큰추가가필요합니다)](https://codecov.io/gh/toss/es-hangul)

### TypeScript를 지원합니다
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/days/days.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { hasProperty } from '../_internal';
import { DAYS_MAP, DAYS_ONLY_TENS_MAP } from './days.constants';
import { DAYS_MAP, DAYS_ONLY_TENS_MAP } from './constants';

export function days(num: number): string {
return getNumberWord(num);
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/standardizePronunciation/rules/transform12th.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
발음변환_첫소리_ㅎ,
발음변환_첫소리_ㅎ_발음,
음가가_없는_자음,
} from '../standardizePronunciation.constants';
} from '../constants';
import { Nullable, NullableReturnSyllables, ReturnSyllables, Syllable } from './rules.types';
import { replace받침ㅎ } from './rules.utils';

Expand Down
2 changes: 1 addition & 1 deletion src/standardizePronunciation/rules/transform13And14th.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { arrayIncludes } from '../../_internal';
import { 음가가_없는_자음 } from '../standardizePronunciation.constants';
import { 음가가_없는_자음 } from '../constants';
import { ReturnSyllables, Syllable } from './rules.types';

const 받침의길이 = {
Expand Down
7 changes: 1 addition & 6 deletions src/standardizePronunciation/rules/transform16th.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import { arrayIncludes } from '../../_internal';
import {
음가가_없는_자음,
특별한_한글_자모,
특별한_한글_자모의_발음,
한글_자모,
} from '../standardizePronunciation.constants';
import { 음가가_없는_자음, 특별한_한글_자모, 특별한_한글_자모의_발음, 한글_자모 } from '../constants';
import { ReturnSyllables, Syllable } from './rules.types';

type Apply16항 = {
Expand Down
2 changes: 1 addition & 1 deletion src/standardizePronunciation/rules/transform17th.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { hasProperty } from '../../_internal';
import { 음의_동화_받침 } from '../standardizePronunciation.constants';
import { 음의_동화_받침 } from '../constants';
import { ReturnSyllables, Syllable } from './rules.types';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/standardizePronunciation/rules/transform18th.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { arrayIncludes } from '../../_internal';
import { 비음화_받침_ㄴ_변환, 비음화_받침_ㅁ_변환, 비음화_받침_ㅇ_변환 } from '../standardizePronunciation.constants';
import { 비음화_받침_ㄴ_변환, 비음화_받침_ㅁ_변환, 비음화_받침_ㅇ_변환 } from '../constants';
import { ReturnSyllables, Syllable } from './rules.types';

/**
Expand Down
2 changes: 1 addition & 1 deletion src/standardizePronunciation/rules/transform19th.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { arrayIncludes } from '../../_internal';
import { 자음동화_받침_ㄴ_변환 } from '../standardizePronunciation.constants';
import { 자음동화_받침_ㄴ_변환 } from '../constants';
import { ReturnSyllables, Syllable } from './rules.types';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { hasProperty } from '../../_internal';
import { 받침_대표음_발음, 음가가_없는_자음 } from '../standardizePronunciation.constants';
import { 받침_대표음_발음, 음가가_없는_자음 } from '../constants';
import { Nullable, ReturnSyllables, Syllable } from './rules.types';

/**
Expand Down
5 changes: 2 additions & 3 deletions src/standardizePronunciation/rules/transformHardConversion.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { arrayIncludes } from '../../_internal';
import { hasProperty } from '../../_internal';
import { 된소리, 된소리_받침, 어간_받침 } from '../standardizePronunciation.constants';
import { arrayIncludes, hasProperty } from '../../_internal';
import { 된소리, 된소리_받침, 어간_받침 } from '../constants';
import { ReturnSyllables, Syllable } from './rules.types';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
ㄴㄹ이_덧나는_후속음절_모음,
ㄴㄹ이_덧나서_받침_ㄴ_변환,
ㄴㄹ이_덧나서_받침_ㄹ_변환,
} from '../standardizePronunciation.constants';
} from '../constants';
import { ReturnSyllables, Syllable } from './rules.types';

/**
Expand Down
3 changes: 2 additions & 1 deletion vitest.config.mts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import path from 'path';
import { defineConfig } from 'vitest/config';
import packageJson from './package.json';
import path from 'path';

export default defineConfig({
resolve: {
Expand All @@ -13,6 +13,7 @@ export default defineConfig({
globals: true,
coverage: {
provider: 'istanbul',
reporter: ['json-summary', 'text'],
include: ['src/**/*'],
},
},
Expand Down

0 comments on commit 102f1e2

Please sign in to comment.