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

docs: es-hangul의 신뢰성을 나타낼 수 있는 문서를 만듭니다 #302

Merged
merged 9 commits into from
Jan 2, 2025

Conversation

po4tion
Copy link
Collaborator

@po4tion po4tion commented Dec 3, 2024

Overview

resolve #297

PC version.
스크린샷 2024-12-12 오후 4 25 59

Mobile Version.

default.mp4

es-hangul의 API들이 높은 신뢰성을 제공함을 사용자에게 보여줄 수 있는 문서를 제작했습니다.

[제공]

  1. API들의 신뢰성 강조(표 제공)
  2. 한글/영문 제공

PR Checklist

  • I read and included theses actions below
  1. I have read the Contributing Guide
  2. I have written documents and tests, if needed.

@po4tion po4tion added the documentation Improvements or additions to documentation label Dec 3, 2024
@po4tion po4tion self-assigned this Dec 3, 2024
Copy link

changeset-bot bot commented Dec 3, 2024

⚠️ No Changeset found

Latest commit: fdd8149

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Dec 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
es-hangul ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 2, 2025 0:34am

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (44c840f) to head (4c215fe).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #302   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           37        37           
  Lines          639       639           
  Branches       154       154           
=========================================
  Hits           639       639           


{coverageItems.map(item => (
<td key={item} className="px-6 py-4">
✅ (100%)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

특정 상황에서는
함수의 테스트 커버리지가 100%가 되지 않는 타이밍도 있을 것 같은데요.
그러면 거짓된 정보를 제공하는것이라 좋지 않은 것 같아요.
항상 100%로 하드코딩하기보다는, 테스트 커버리지를 동적으로 받아올 수 있는 방법이 없을까요?

Copy link
Collaborator Author

@po4tion po4tion Dec 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

build 전 테스트 커버리지 파일 업데이트를 통해 '최신 커버리지 파일'을 이용하는 방식으로 변경했습니다. 파일의 무게는 13kb로 기존 빌드배포 시간에 큰 영향을 미치지 않는다고 판단하였습니다. 해당 이슈를 진행하면서 한가지 아쉬웠던 점은 es-hangul의 공식문서에서 공개하고 있는 API 리스트들을 커버리지 파일을 이용하여 가져올 수 없는지 확인을 해봤는데 실패했습니다.
그러하여, deduplicationAPIList 라는 상수를 통해 es-hangul 내에서 테스트되고 있는 파일들 중 사용자들에게 보여주고 있는 API 테스트 파일들만 필터링 했습니다. 이렇게 하지 않으면 _internal, standardizePronunciation의 transform과 관련된 테스트 값들이 불필요하게 사용자들에게 보여집니다.

그리고 docs를 build 하기 전, 배포 명령어에 "yarn test"를 넣어주실 수 있나요? 해당 명령어를 통해 coverage 파일을 최신화하고자 합니다.

@po4tion po4tion marked this pull request as ready for review December 12, 2024 07:25
@@ -0,0 +1,44 @@
{"total": {"lines":{"total":540,"covered":540,"skipped":0,"pct":100},"statements":{"total":545,"covered":545,"skipped":0,"pct":100},"functions":{"total":101,"covered":101,"skipped":0,"pct":100},"branches":{"total":339,"covered":339,"skipped":0,"pct":100},"branchesTrue":{"total":0,"covered":0,"skipped":0,"pct":100}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yarn test실행시 업데이트 되는 파일이라면,
gitignore에 기존대로 넣어도 괜찮지 않나요?
개인 파일 경로가 들어가있어서 main에 머지되어도 괜찮을까 걱정이 되어서요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gitignore에 다시 coverage 경로를 넣어도 될 것 같습니다. 다만, 제가 알고있는 사항으로는 docs 배포시에 따로 yarn test 명령어를 통해 coverage를 생성하지 않는 것으로 알고 있습니다. 혹시 yarn test 명령어를 배포 명령시 추가해주실 수 있을까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 18 to 62
const filteredCoverage = (coverageFileEntries: typeof fileEntries, openAPIList: typeof deduplicationAPIList) => {
return Object.entries(coverageFileEntries)
.filter(([filePath]) => {
const fileNameWithoutExt = filteredFilePath(filePath);

if (!fileNameWithoutExt) {
return false;
}

return filteredFileName(fileNameWithoutExt, openAPIList);
})
.map(([filePath, coverage]) => {
const fileNameWithoutExt = filteredFilePath(filePath);

return [fileNameWithoutExt, coverage] as const;
});
};

const filteredFilePath = (filePath: string) => {
const segments = filePath.split('/');
const lastSegment = segments[segments.length - 1];

if (!lastSegment.endsWith('.ts')) {
return '';
}

return lastSegment.replace(/\.ts$/, '');
};

const filteredFileName = (fileNameWithoutExt: string, openAPIList: typeof deduplicationAPIList) => {
return openAPIList.some(api => {
if (fileNameWithoutExt === api) {
return true;
}

if (fileNameWithoutExt.startsWith(api) && fileNameWithoutExt.length > api.length) {
const nextChar = fileNameWithoutExt.charAt(api.length);

return nextChar === nextChar.toUpperCase() && nextChar !== nextChar.toLowerCase();
}

return false;
});
};

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분 풀고자 하는 문제보다 약간 복잡하게 코드가 작성되어 있는 느낌을 받았는데요,

  1. 생각보다 많은 분기가 있고
  2. 함수명이 상수명처럼 과거형으로 되어있고 ( 필터하는 함수라면 filtered가 아닌 filter가 더 적절해보여요.)
  3. name과 path의 구분을 잘 이해하지 못했어요.
  4. deduplicationAPIList를 상수로 관리하는 이유를 코맨트로 적어주셨지만 이해하지 못하였어요. coverage-summary.json에 함수명들이 다 존재하지 않나요?
  const result = {};

  // for 구문은 명령형 구조이므로 수정은 필요함
  for (const [key, value] of Object.entries(fileEntries)) {
    const name = key.split('/').pop()?.split('.')[0];
    if (name == null) {
      return;
    }

    result[name] = {
      lines: value.lines.pct,
      functions: value.functions.pct,
      statements: value.statements.pct,
      branches: value.branches.pct,
    };
  }

위와 같이 간단히 생각해보았는데요, 위처럼 간단하게만 해도 함수별로 각 커버리지를 알 수 있는데, 기존 코드로 풀고자 하는 문제가 어떤것이셨나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기존 코드에서는 constants.ts, transform*.ts, _internal 경로등의 모든 테스트 파일이 fileEntries에 담겨져 있어서 사용자들에게 보여주는 API로만 목록을 구성하고 싶었기에 '필터'를 위한 상수와 함수를 고안했습니다.

@okinawaa 님과 대화를 해보면서 현재 추가한 코드보다 더 간단하게 풀어낼 수 있는 것 같아서 수정해보았습니다.
코드를 매끄럽게 풀어나갑니다

Copy link
Member

@okinawaa okinawaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

감사합니다~

@okinawaa okinawaa merged commit 102f1e2 into main Jan 2, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature]: es-hangul의 신뢰성을 나타낼 수 있는 페이지를 문서에 만듭니다.
3 participants