Skip to content

Commit 8890db0

Browse files
authored
docs: create reference documentation with beautifully styled (#57)
* wip * renew reference docs * fix * fix * works
1 parent 15a3222 commit 8890db0

File tree

514 files changed

+19259
-8148
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

514 files changed

+19259
-8148
lines changed

.github/CONTRIBUTING.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,25 @@ feat(repository): add options for initialize repository
7575
docs: fix link to website page
7676
chore: upgrade vitest to v3
7777
```
78+
79+
## Documentation
80+
81+
This project aims to maintain high documentation quality.
82+
83+
Please refer to the following guide to create robust references using JSDoc.
84+
85+
- `@category` : Specifies the category in which the reference documentation will be placed. You can use `/` to specify depth (e.g. `Repository/Methods`).
86+
- `@signature` : Describes what type of signature a function or method has. Please write a type declaration in the TypeScript language.
87+
- `@param` : Write all parameters.
88+
- `@returns` : Specifies what value is returned.
89+
- `@throws` : Write documentation for errors that should be noted.
90+
- `@example` : Examples are not required, but are recommended as they make the behavior easier to understand.
91+
92+
To automatically generate reference documentation after writing a JSDoc, please run the command below.
93+
94+
```shell
95+
yarn build
96+
97+
cd docs/
98+
yarn gen-reference
99+
```

README-ko_kr.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ console.log(head); // "refs/heads/main"
2424
## 문서
2525

2626
- [사용법](https://es-git.slash.page/ko/usage/repository.html)
27-
- [레퍼런스](https://es-git.slash.page/ko/reference/globals.html)
27+
- [레퍼런스](https://es-git.slash.page/ko/reference/Repository/openRepository.html)
2828

2929
## 기여하기
3030

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ console.log(head); // "refs/heads/main"
2424
## Documentation
2525

2626
- [Usage](https://es-git.slash.page/usage/repository.html)
27-
- [Reference](https://es-git.slash.page/reference/globals.html)
27+
- [Reference](https://es-git.slash.page/reference/Repository/openRepository.html)
2828

2929
## Contributing
3030

docs/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.vitepress/cache
22
typedoc-generated/
3+
typedoc-generated.json

docs/.vitepress/en.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,33 @@ function nav(): DefaultTheme.NavItem[] {
2626
{ text: 'Home', link: '/' },
2727
{ text: 'Getting Started', link: '/getting-started' },
2828
{ text: 'Usage', link: '/usage/repository' },
29+
{ text: 'Reference', link: '/reference/Repository/openRepository' },
2930
];
3031
}
3132

3233
function sidebar(): DefaultTheme.Sidebar {
3334
return [
3435
{
35-
text: 'Getting Started',
36-
link: '/getting-started',
37-
},
38-
{
39-
text: 'Usage',
36+
text: 'Guides',
4037
items: [
41-
{ text: 'Repository', link: '/usage/repository' },
42-
{ text: 'Remotes', link: '/usage/remote' },
43-
{ text: 'Commit History', link: '/usage/history' },
44-
{ text: 'Commit Changes', link: '/usage/commit' },
45-
{ text: 'Tags', link: '/usage/tag' },
38+
{
39+
text: 'Getting Started',
40+
link: '/getting-started',
41+
},
42+
{
43+
text: 'Usage',
44+
items: [
45+
{ text: 'Repository', link: '/usage/repository' },
46+
{ text: 'Remotes', link: '/usage/remote' },
47+
{ text: 'Commit History', link: '/usage/history' },
48+
{ text: 'Commit Changes', link: '/usage/commit' },
49+
{ text: 'Tags', link: '/usage/tag' },
50+
],
51+
},
4652
],
4753
},
4854
{
4955
text: 'Reference',
50-
link: '/reference/globals',
5156
items: getReferenceSidebarItems(docsRoot),
5257
},
5358
];

docs/.vitepress/ko.ts

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,28 +26,33 @@ function nav(): DefaultTheme.NavItem[] {
2626
{ text: '홈', link: '/ko' },
2727
{ text: '시작하기', link: '/ko/getting-started' },
2828
{ text: '사용법', link: '/ko/usage/repository' },
29+
{ text: '레퍼런스', link: '/ko/reference/Repository/openRepository' },
2930
];
3031
}
3132

3233
function sidebar(): DefaultTheme.Sidebar {
3334
return [
3435
{
35-
text: '시작하기',
36-
link: '/ko/getting-started',
37-
},
38-
{
39-
text: '사용법',
36+
text: '가이드',
4037
items: [
41-
{ text: '리포지토리', link: '/ko/usage/repository' },
42-
{ text: '리모트', link: '/ko/usage/remote' },
43-
{ text: '커밋 히스토리', link: '/ko/usage/history' },
44-
{ text: '커밋하기', link: '/ko/usage/commit' },
45-
{ text: '태그', link: '/ko/usage/tag' },
38+
{
39+
text: '시작하기',
40+
link: '/ko/getting-started',
41+
},
42+
{
43+
text: '사용법',
44+
items: [
45+
{ text: '리포지토리', link: '/ko/usage/repository' },
46+
{ text: '리모트', link: '/ko/usage/remote' },
47+
{ text: '커밋 히스토리', link: '/ko/usage/history' },
48+
{ text: '커밋하기', link: '/ko/usage/commit' },
49+
{ text: '태그', link: '/ko/usage/tag' },
50+
],
51+
},
4652
],
4753
},
4854
{
4955
text: '레퍼런스',
50-
link: '/ko/reference/globals',
5156
items: getReferenceSidebarItems(docsRoot, 'ko'),
5257
},
5358
];

docs/.vitepress/lib/sidebar.ts

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,62 @@
1-
import fs from 'node:fs';
21
import path from 'node:path';
2+
import glob from 'fast-glob';
33
import type { DefaultTheme } from 'vitepress';
44

55
export function getReferenceSidebarItems(docsRoot: string, lang?: string) {
6-
const jsonFilepath =
7-
lang != null
8-
? path.join(docsRoot, lang, 'reference', 'typedoc-sidebar.json')
9-
: path.join(docsRoot, 'reference', 'typedoc-sidebar.json');
10-
const json = fs.readFileSync(jsonFilepath, 'utf8');
11-
return JSON.parse(json) as DefaultTheme.SidebarItem[];
6+
const files = glob.sync('**/*.md', {
7+
cwd: lang != null ? path.join(docsRoot, lang, 'reference') : path.join(docsRoot, 'reference'),
8+
onlyFiles: true,
9+
});
10+
files.sort((a, b) => {
11+
const aName = path.basename(a, '.md');
12+
const bName = path.basename(b, '.md');
13+
if (aName < bName) {
14+
return -1;
15+
}
16+
if (aName > bName) {
17+
return 1;
18+
}
19+
return 0;
20+
});
21+
22+
const items: DefaultTheme.SidebarItem[] = [];
23+
for (const file of files) {
24+
const parts = file.split('/');
25+
const link = lang != null ? `/${lang}/reference/${file}` : `/reference/${file}`;
26+
let current = items;
27+
if (parts.length > 1) {
28+
for (const part of parts.slice(0, parts.length - 1)) {
29+
let node = current.find(x => x.text === part);
30+
if (node == null) {
31+
node = { text: part, items: [], collapsed: true };
32+
current.push(node);
33+
}
34+
current = node.items!;
35+
}
36+
}
37+
current.push({
38+
text: path.basename(file, '.md'),
39+
link: link.replace(path.extname(link), ''),
40+
});
41+
}
42+
sortItems(items);
43+
return items;
44+
}
45+
46+
function sortItems(items: DefaultTheme.SidebarItem[]) {
47+
items.sort((a, b) => {
48+
const textDiff = a.text! < b.text! ? -1 : a.text! < b.text! ? 1 : 0;
49+
if (a.link != null && b.link == null) {
50+
return 1;
51+
}
52+
if (a.link == null && b.link != null) {
53+
return -1;
54+
}
55+
return textDiff;
56+
});
57+
for (const item of items) {
58+
if (item.items != null) {
59+
sortItems(item.items);
60+
}
61+
}
1262
}

docs/.vitepress/theme/index.css

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
:root {
2+
--vp-c-brand-1: rgb(27, 109, 225);
3+
--vp-c-brand-2: rgb(55, 113, 212);
24
--vp-nav-logo-height: 16px;
35
--vp-font-family-base: "Toss Product Sans", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji",
46
"Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
@@ -7,3 +9,62 @@
79
:root[lang="ko"] {
810
word-break: keep-all;
911
}
12+
13+
ul.param-ul {
14+
margin-top: 8px;
15+
padding: 0;
16+
list-style: none;
17+
18+
& > li.param-li {
19+
position: relative;
20+
padding-left: 16px;
21+
margin-left: 12px;
22+
margin-top: 0;
23+
margin-bottom: 12px;
24+
}
25+
26+
& > li.param-li-root {
27+
margin-left: 0;
28+
padding-left: 0;
29+
}
30+
31+
& li.param-li::before {
32+
position: absolute;
33+
left: 0;
34+
display: block;
35+
content: "";
36+
top: 6px;
37+
width: 8px;
38+
height: 8px;
39+
border-left: 2px solid #5c6064;
40+
border-bottom: 2px solid #5c6064;
41+
}
42+
43+
& li.param-li-root::before {
44+
display: none;
45+
}
46+
}
47+
48+
span.param-name {
49+
font-size: 14px;
50+
font-weight: 700;
51+
color: var(--vp-c-text-1);
52+
margin-right: 6px;
53+
font-family: Menlo, Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
54+
}
55+
56+
span.param-required {
57+
font-size: 14px;
58+
color: #f5645a;
59+
}
60+
61+
span.param-type {
62+
font-size: 14px;
63+
color: #38cc8e;
64+
}
65+
66+
p.param-description {
67+
font-size: 14px;
68+
color: var(--vp-c-text-1);
69+
margin: 0;
70+
}

0 commit comments

Comments
 (0)