jsx-readme로 README 파일 자동 생성
코드가 변경될 때마다 README 파일을 수동으로 업데이트하는 대신 README가 자동으로 최신 상태를 유지할 수 있다면 어떨까요? 추가해야 하는 배지를 기억하는 대신 이 모든 작업이 완료되면 어떻게 될까요?
jsx-readme 소개
다음은
jsx-readme
사용 예입니다.// We need to tell the JSX transpiler that in this file,
// instead of React we use the custom createElement and Fragment
// functions from jsx-readme
/* @jsx MD */
/* @jsxFrag Fragment */
import type { Component } from "jsx-readme";
import MD, {
BadgesFromPkg,
CodecovBadge,
DescriptionFromPkg,
ExamplesFromPkg,
Fragment,
GithubWorkflowBadge,
HomepageFromPkg,
renderToFile,
TitleFromPkg,
} from "jsx-readme";
import { Heading, InlineCode, LineBreak } from "jsx-md";
import pkg from "./package.json";
const Readme: Component = () => (
<Fragment>
{/* Create a header with title, badges and description inferred from package.json */}
<TitleFromPkg pkg={pkg} />
<BadgesFromPkg pkg={pkg} />
{/* Add additional badges. */}
<CodecovBadge pkg={pkg} />
<GithubWorkflowBadge pkg={pkg} workflowName="Build and deploy" />
<LineBreak />
<DescriptionFromPkg pkg={pkg} />
{/* You can use the components from jsx-md to build custom markdown. */}
<Heading level={2}>Installation</Heading>
Add <InlineCode>jsx-readme</InlineCode> to your{" "}
<InlineCode>devDependencies</InlineCode> and install it. I recommend using
it with <InlineCode>ts-node</InlineCode>. Then all you need to do is add a
file like in the example below and run it via{" "}
<InlineCode>ts-node</InlineCode> whenever you want to create a new version
of the <InlineCode>README</InlineCode>.
<LineBreak />
<LineBreak />
{/* Create an example section based on all files from the example directory set up in package.json */}
<ExamplesFromPkg pkg={pkg} />
{/* Create a section linking to the homepage from package.json */}
<HomepageFromPkg pkg={pkg} />
</Fragment>
);
void renderToFile("./README.md", <Readme />);
보시다시피
jsx-readme
는 React와 유사한 JSX 구문을 사용하여 Markdown을 정의합니다. 필요에 따라 독립적으로 또는 jsx-md
와 함께 사용할 수도 있는 jsx-readme
위에 구축되었습니다.JSX는 기본적으로 JavaScript이므로 이 파일에서 원하는 모든 작업을 수행할 수 있습니다. 이 간단한 경우에는 로컬
package.json
파일을 가져와서 읽기만 하면 되지만 e. g. GitHub API를 쿼리하여 누가 기여했는지 파악한 다음 읽어보기에 추가하시겠습니까?그리고 그냥 TypeScript 파일이기 때문에 e를 통해 간단히 실행할 수 있습니다. g.
ts-node
또 다른 CLI 도구를 배울 필요가 없습니다.그래서 어떻게 생겼습니까?
위 스크립트의 결과를 이해하는 가장 좋은 방법은 the package itself -
jsx-readme
가 이를 사용하여 자체 README를 만드는 것입니다.
Reference
이 문제에 관하여(jsx-readme로 README 파일 자동 생성), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/the_startup_cto/automatically-generating-readme-files-with-jsx-readme-8a1텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)