-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from 4lex0017/docs_Fe
docs: more docs for fe
- Loading branch information
Showing
27 changed files
with
374 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { existsSync, mkdirSync, writeFileSync } from 'node:fs' | ||
import path from 'node:path' | ||
import type { DocEntry } from 'tsdoc-markdown' | ||
import { buildDocumentation } from 'tsdoc-markdown' | ||
|
||
export function genTsDocs({ dirPath, inputFiles }: { inputFiles: string[]; dirPath: string }) { | ||
const entries = buildDocumentation({ inputFiles }) | ||
|
||
if (!existsSync(dirPath)) | ||
mkdirSync(dirPath) | ||
|
||
entries.forEach((entry) => { | ||
const md = genMD(entry) | ||
const targetPath = path.join(dirPath, `${entry.name}.md`) | ||
writeFileSync(targetPath, md, { flag: 'w' }) | ||
}) | ||
} | ||
|
||
function genMD(entry: DocEntry) { | ||
// entry.name === 'useRandomColor' && console.log(JSON.stringify(entry, null, 4)) | ||
const md = [] | ||
|
||
md.push(`# ${entry.name}`) | ||
md.push(`${entry.documentation}`) | ||
|
||
const params = entry.jsDocs.filter(d => d.name === 'param') | ||
if (params.length) { | ||
md.push('## Parameters') | ||
md.push('| Name | Description |') | ||
md.push('|------|-------------|') | ||
|
||
params.forEach((d) => { | ||
const [name, desc] = d.text.filter(t => t.kind !== 'space') | ||
md.push(`|${name?.text}|${desc?.text}|`) | ||
}) | ||
} | ||
|
||
// TODO Make this section better | ||
if (entry.type) { | ||
const returns = entry.jsDocs.find(d => d.name === 'returns') | ||
|
||
md.push('## Returns') | ||
md.push(returns?.text?.[0]?.text) | ||
md.push(`\`\`\`\n${entry.type}\n\`\`\``) | ||
} | ||
|
||
const examples = entry.jsDocs.filter(d => d.name === 'example') | ||
if (examples.length) { | ||
md.push('## Examples') | ||
examples.forEach(e => e.text.forEach(t => md.push(t.text))) | ||
} | ||
|
||
return md.join('\n') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# useConvertSecToMin | ||
Converts a duration in seconds to a formatted string representation in minutes and seconds. | ||
## Parameters | ||
| Name | Description | | ||
|------|-------------| | ||
|secs|The duration in seconds to convert.| | ||
## Returns | ||
A formatted string representing the duration in minutes and seconds. | ||
``` | ||
(secs: number) => string | ||
``` | ||
## Examples | ||
```ts | ||
useConvertSecToMin(135) // 2m 15s | ||
|
||
useConvertSecToMin(120) // 2m | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# useDarkToggle | ||
Toggles between light and dark modes. | ||
## Returns | ||
An object with `isDark` (current mode) and `toggle` (toggle function). | ||
``` | ||
() => { isDark: WritableComputedRef<boolean>; toggle: (value?: boolean) => boolean; } | ||
``` | ||
## Examples | ||
```ts | ||
const {isDark, toggle} = useDark() | ||
|
||
isDark.value // false | ||
toggle() | ||
isDark.value // true | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# useDateFormat | ||
Format a date-like object into a predefined or custom format. | ||
## Parameters | ||
| Name | Description | | ||
|------|-------------| | ||
|date|The date-like object to format.| | ||
|format|The date format, either a predefined format ('DD/MM/YYYY') or a custom format string.| | ||
## Returns | ||
The formatted date as a string. | ||
``` | ||
(date: DateLike, format: "DD/MM/YYYY" | Omit<string, "DD/MM/YYYY">) => string | ||
``` | ||
## Examples | ||
```ts | ||
useDateFormat(new Date(), 'DD/MM/YYYY') // 22/09/2023 | ||
|
||
useDateFormat(new Date(), 'dddd DD/MM') // Friday 22/09 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# useDocTitle | ||
Set the document's title with an optional prefix. | ||
## Parameters | ||
| Name | Description | | ||
|------|-------------| | ||
|title|The title to set.| | ||
|prefix|An optional prefix to prepend to the title.| | ||
## Returns | ||
|
||
``` | ||
(title: string, prefix?: string) => void | ||
``` | ||
## Examples | ||
```ts | ||
useDocTitle('New Title') | ||
document.title // DefaultPrefix New Title | ||
|
||
useDocTitle('New Title', 'MyPrefix') | ||
document.title // MyPrefix New Title | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# useDriver | ||
Provides access to the Driver.js instance and configuration for guided tours. | ||
## Returns | ||
An object containing the Driver.js instance and a function to set its configuration. | ||
``` | ||
() => { driver: any; setConfig: (config: Omit<Config, "stagePadding" | "stageRadius">) => void; } | ||
``` | ||
## Examples | ||
```ts | ||
const {driver, setConfig} = useDriver() | ||
|
||
setConfig({}) | ||
driver.value.doSomething() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# useGet | ||
Execute a GET request and manage the response data, loading state, and errors. | ||
## Parameters | ||
| Name | Description | | ||
|------|-------------| | ||
|config|The configuration for the GET request.| | ||
## Returns | ||
An object containing the response data, loading state, error message, and an execution function. | ||
``` | ||
(config: GetConfig) => { data: any; isFetching: any; error: any; execute: () => void; } | ||
``` | ||
## Examples | ||
```ts | ||
const { data, isFetching, error, execute } = useGet({ | ||
url: '/api/example', | ||
onSuccess(data){ | ||
// | ||
} | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# useHash | ||
Generate a hash value for a given string. | ||
## Parameters | ||
| Name | Description | | ||
|------|-------------| | ||
|str|The input string to hash.| | ||
## Returns | ||
A hashed representation of the input string. | ||
``` | ||
(str: string) => string | ||
``` | ||
## Examples | ||
```ts | ||
useHash('somerandomstring') // 19viky0 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# useLocale | ||
Manage the application's locale and localization settings. | ||
## Returns | ||
An object containing available locales and the current locale. | ||
``` | ||
() => { availableLocales: string[]; currentLocale: RemovableRef<string>; } | ||
``` | ||
## Examples | ||
```ts | ||
const { currentLocale } = useLocale() | ||
|
||
currentLocale.value // en | ||
document.documentElement.lang // en | ||
|
||
currentLocale.value = 'de' | ||
document.documentElement.lang // de | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# usePost | ||
Execute a POST request and manage the response data, loading state, and errors. | ||
## Parameters | ||
| Name | Description | | ||
|------|-------------| | ||
|config|The configuration for the POST request.| | ||
## Returns | ||
An object containing the response data, loading state, error message, and an execution function. | ||
``` | ||
<T>(config: PostConfig<T>) => { data: any; isFetching: any; error: any; execute: (body?: unknown) => void; } | ||
``` | ||
## Examples | ||
```ts | ||
const { data, isFetching, error, execute } = useGet({ | ||
url: '/api/example', | ||
body: { filePath: '/tmp/some.mp3' }, | ||
onSuccess(data){ | ||
// | ||
} | ||
}) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# useRandomColor | ||
Generate a random RGBA color string with 50% opacity. | ||
## Returns | ||
A random RGBA color string in the format "rgba(r, g, b, 0.5)". | ||
``` | ||
() => string | ||
``` | ||
## Examples | ||
```ts | ||
useRandomColor() // rgba(123, 203, 78, 0.5) | ||
``` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.