Skip to content

Commit 1b353d8

Browse files
committed
feat: Update docstrings in string functions
This commit updates the docstrings in the string functions (capitalize, lowercase, split, uncapitalize, uppercase) to include import statements and usage examples directly in the docstrings. This change makes it easier for users to understand how to use these functions directly from the source code.
1 parent bfea0ca commit 1b353d8

File tree

5 files changed

+39
-52
lines changed

5 files changed

+39
-52
lines changed

src/capitalize.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@ type CapitalizedString<T extends Readonly<string>> = IsStringLiteral<T> extends
44
true ? Capitalize<T> : string;
55

66
/**
7-
* @description capitalize first letter of string
7+
* capitalize first letter of string
88
*
9-
* @param input - input string to capitalize. type should be matched to T
10-
*
11-
* @example
12-
* capitalize('a') // returns 'A'
9+
* ```ts
10+
* import { capitalize } from '@ryoppippi/str-fns'
11+
* const _: 'A' = capitalize('a');
12+
* const __: 'Abc' = capitalize('abc');
13+
* const ___: '' = capitalize('');
14+
* ```
1315
*
14-
* @example
15-
* capitalize('abc') // returns 'Abc'
16-
*
17-
* @example
18-
* capitalize('') // returns ''
16+
* @param input - input string to capitalize. type should be matched to T
1917
*/
2018
export function capitalize<T extends Readonly<string>>(
2119
input: T,

src/lowercase.ts

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,15 @@ type LowercaseString<T extends Readonly<string>> = IsStringLiteral<T> extends
44
true ? Lowercase<T> : string;
55

66
/**
7-
* @description get lowercase string
7+
* get lowercase string
88
*
9+
* ```ts
10+
* import { lowercase } from '@ryoppippi/str-fns'
11+
* const _: 'a' = lowercase('A');
12+
* const __: 'abc' = lowercase('aBC');
13+
* const ___: '' = lowercase('');
14+
* ```
915
* @param input - input string to capitalize. type should be matched to T
10-
*
11-
* @example
12-
* lowercase('A') // 'a'
13-
*
14-
* @example
15-
* lowercase('aBC') // 'abc'
16-
*
17-
* @example
18-
* lowercase('') // ''
1916
*/
2017
export function lowercase<T extends Readonly<string>>(
2118
input: T,

src/split.ts

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,19 @@ type SplitString<
77
: Readonly<string[]>;
88

99
/**
10-
* @description Split string by separator
10+
* Split string by separator
11+
*
12+
* ```ts
13+
* import { split } from '@ryoppippi/str-fns'
14+
* const _: readonly ['A', 'c'] = split('Abc', 'b');
15+
* const __: readonly ['a', 'b', 'c'] = split('a-b-c', '-');
16+
* const ___: readonly ['a', '-', 'b', '-', 'c'] = split('a-b-c', '');
17+
* const ____: readonly ['a-b-c'] = split('a-b-c', '$');
18+
* ```
1119
*
1220
* @param input - string to split. type should be matched to T
1321
*
1422
* @param separator - separator to split string. type should be matched to U
15-
*
16-
* @example
17-
* split('Abc', 'b') // returns ['A', 'c']
18-
*
19-
* @example
20-
* split('a-b-c', '-') // returns ['a', 'b', 'c']
21-
*
22-
* @example
23-
* split('a-b-c', '') // returns ['a', '-', 'b', '-', 'c']
24-
*
25-
* @example
26-
* split('a-b-c', '$') // returns ['a-b-c']
2723
*/
2824
export function split<T extends Readonly<string>, U extends Readonly<string>>(
2925
input: T,

src/uncapitalize.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,16 @@ type UncapitalizedString<T extends Readonly<string>> =
44
IsStringLiteral<T> extends true ? Uncapitalize<T> : string;
55

66
/**
7-
* @description uncapitalize first letter of string
7+
* uncapitalize first letter of string
88
*
9-
* @param input - input string to capitalize. type should be matched to T
10-
*
11-
* @example
12-
* uncapitalize('A') // returns 'a'
9+
* ```ts
10+
* import { uncapitalize } from '@ryoppippi/str-fns'
11+
* const _: 'a' = uncapitalize('A');
12+
* const __: 'abc' = uncapitalize('Abc');
13+
* const ___: '' = uncapitalize('');
14+
* ```
1315
*
14-
* @example
15-
* uncapitalize('Abc') // returns 'abc'
16-
*
17-
* @example
18-
* uncapitalize('') // returns ''
16+
* @param input - input string to capitalize. type should be matched to T
1917
*/
2018
export function uncapitalize<T extends Readonly<string>>(
2119
input: T,

src/uppercase.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,14 @@ type UppercaseString<T extends Readonly<string>> = IsStringLiteral<T> extends
66
/**
77
* @description get uppercase string
88
*
9-
* @param input - input string to capitalize. type should be matched to T
10-
*
11-
* @example
12-
* uppercase('a') // 'A'
9+
* ```ts
10+
* import { uppercase } from '@ryoppippi/str-fns'
11+
* const _: 'A' = uppercase('a');
12+
* const __: 'ABC' = uppercase('abc');
13+
* const ___: '' = uppercase('');
14+
* ```
1315
*
14-
* @example
15-
* uppercase('abc') // 'Abc'
16-
*
17-
* @example
18-
* uppercase('') // ''
16+
* @param input - input string to capitalize. type should be matched to T
1917
*/
2018
export function uppercase<T extends Readonly<string>>(
2119
input: T,

0 commit comments

Comments
 (0)