Skip to content

Commit cfe2c15

Browse files
committed
docs: reformat docs to stay consistent with how typedoc will render them
1 parent 7e7eb2f commit cfe2c15

File tree

5 files changed

+29
-30
lines changed

5 files changed

+29
-30
lines changed

src/model/collection/periodic-notes.ts

+6-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { DateTime, DateTimeOptions, Duration, DurationLike, Interval, IntervalMa
44
import { parse } from "path";
55
import { DeepReadonly } from "utility-types";
66

7-
import { assertLuxonFormat, assertValid } from "@/util/luxon-utils";
7+
import { assertValidDateTimeFormat, assertValidLuxonValue } from "@/util/luxon-utils";
88

99
import { DateBasedCollection } from "./schema";
1010
import { stripTrailingSlash } from "./util";
@@ -29,16 +29,13 @@ export class PeriodicNotes extends DateBasedCollection implements PeriodicNotesC
2929

3030
/**
3131
* The {@link Duration} of each file's corresponding {@link Interval}.
32-
* @example
33-
* Daily notes should use a duration of `{ days: 1 }`.
32+
* Daily notes, for example, should use a duration of `{ days: 1 }`.
3433
*/
3534
public readonly intervalDuration: Duration<true>;
3635

3736
/**
3837
* Offset between the file's _parsed_ date and the corresponding {@link Interval}'s _start_ date. May be negative.
39-
* @example
40-
* Sprint notes may use ISO weeks as their {@link dateFormat}, for example: `2025-W10.md`.
41-
* If sprints _actually_ begin on Thursdays rather than Mondays, then we can adjust the interval with `{ days: 3 }`.
38+
* Sprint notes, for example, can use ISO weeks for {@link dateFormat} and {@link intervalOffset} for their weekday.
4239
*/
4340
public readonly intervalOffset: Duration<true>;
4441

@@ -125,10 +122,10 @@ function validated(config: PeriodicNotesConfig<false>): PeriodicNotesConfig<true
125122

126123
const errors = [
127124
attempt(() => assertNotStrictEqual(folder.length, 0, "folder must be non-empty")),
128-
attempt(() => assertLuxonFormat(dateFormat, dateOptions)),
129-
attempt(() => assertValid(intervalDuration, "interval duration is invalid")),
125+
attempt(() => assertValidDateTimeFormat(dateFormat, dateOptions)),
126+
attempt(() => assertValidLuxonValue(intervalDuration, "interval duration is invalid")),
130127
attempt(() => assertNotStrictEqual(intervalDuration.valueOf(), 0, "interval duration must not be zero")),
131-
attempt(() => assertValid(intervalOffset, "interval offset is invalid")),
128+
attempt(() => assertValidLuxonValue(intervalOffset, "interval offset is invalid")),
132129
].filter(isError);
133130

134131
if (errors.length > 0) {

src/model/task/lib/obsidian-tasks.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ import { SYMBOL_PATH_LOOKUP, SYMBOL_PRIORITY_LOOKUP, SYMBOL_REG_EXP } from "./ob
88

99
/**
1010
* Parses {@link Task} metadata from a real markdown blob using Obsidian Task's emoji format.
11+
*
12+
* Here's an illustration:
13+
* ```
14+
* // ( symbol & value )
15+
* "the text at the front is assumed to be a description. ❌ cancelled date ➕ creation date ✅ completed date"
16+
* // ( symbol & value ) ( symbol & value )
17+
*
18+
* { cancelled: "cancelled date", created: "creation date", done: "completed date" }
19+
* ```
1120
* @param text - the text of the task without its' markdown text.
1221
* @returns a {@link Task} with the parsed metadata.
1322
* @see {@link https://publish.obsidian.md/tasks/Reference/Task+Formats/Tasks+Emoji+Format}
14-
* @example
15-
* ( symbol & value )
16-
* "the text at the front is assumed to be a description. ❌ cancelled date ➕ creation date ✅ completed date"
17-
* ( symbol & value ) ( symbol & value )
18-
*
19-
* \{ cancelled: "cancelled date", created: "creation date", done: "completed date" \}
2023
*/
2124
export function parseTaskEmojiFormat(text: string): DeepPartial<Task> {
2225
const matchedSymbols = [...text.matchAll(SYMBOL_REG_EXP), /$/.exec(text) as RegExpExecArray];
+7-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { DateTime, Duration, Interval } from "luxon";
22
import { describe, expect, it } from "vitest";
33

4-
import { assertLuxonFormat, assertValid } from "../luxon-utils";
4+
import { assertValidDateTimeFormat, assertValidLuxonValue } from "../luxon-utils";
55

6-
describe(`${assertValid.name}`, () => {
6+
describe(`${assertValidLuxonValue.name}`, () => {
77
const reason = "user-provided reason";
88
const explanation = "user-provided explanation";
99

@@ -13,24 +13,24 @@ describe(`${assertValid.name}`, () => {
1313
Duration.fromDurationLike({ days: 1 }),
1414
Interval.after(DateTime.now(), { days: 1 }),
1515
])("should accept valid $constructor.name", (value) => {
16-
expect(() => assertValid(value, message)).not.toThrow();
16+
expect(() => assertValidLuxonValue(value, message)).not.toThrow();
1717
});
1818

1919
it.each([DateTime.fromISO("2025-03-99"), Duration.invalid(reason), Interval.invalid(reason, explanation)])(
2020
"should reject invalid $constructor.name",
2121
(value) => {
22-
expect(() => assertValid(value, message)).toThrowErrorMatchingSnapshot();
22+
expect(() => assertValidLuxonValue(value, message)).toThrowErrorMatchingSnapshot();
2323
},
2424
);
2525
});
2626
});
2727

28-
describe(`${assertLuxonFormat.name}`, () => {
28+
describe(`${assertValidDateTimeFormat.name}`, () => {
2929
it.each(["yyyy-MM-dd", "kkkk-'W'WW", "yyyy-MM"])("should accept valid format=%j", (validFormat) => {
30-
expect(() => assertLuxonFormat(validFormat)).not.toThrow();
30+
expect(() => assertValidDateTimeFormat(validFormat)).not.toThrow();
3131
});
3232

3333
it.each(["FF", "''"])("should reject invalid format=%j", (invalidFormat) => {
34-
expect(() => assertLuxonFormat(invalidFormat)).toThrowErrorMatchingSnapshot();
34+
expect(() => assertValidDateTimeFormat(invalidFormat)).toThrowErrorMatchingSnapshot();
3535
});
3636
});

src/util/luxon-utils.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,21 @@ export type LuxonFormat = Brand<string, "LuxonFormat">;
1818
* @param message - Optional custom header for the error message.
1919
* @throws If the provided value is invalid.
2020
*/
21-
export function assertValid(
21+
export function assertValidLuxonValue(
2222
value: LuxonValue<true> | LuxonValue<false>,
2323
message?: string,
2424
): asserts value is LuxonValue<true> {
25-
const { invalidReason, invalidExplanation } = value;
26-
const header = message ?? `Invalid ${value.constructor.name}`;
27-
const reason = invalidExplanation ? `${invalidReason}: ${invalidExplanation}` : invalidReason;
28-
assert(value.isValid, `${header}: ${reason}`);
25+
message ??= `Invalid ${value.constructor.name}`;
26+
const help = value.invalidExplanation ? `${value.invalidReason}: ${value.invalidExplanation}` : value.invalidReason;
27+
assert(value.isValid, `${message}: ${help}`);
2928
}
3029

3130
/**
3231
* @param dateFormat - the format to check.
3332
* @param dateOptions - the options to use when parsing and formatting.
3433
* @see {@link https://moment.github.io/luxon/#/parsing?id=table-of-tokens}
3534
*/
36-
export function assertLuxonFormat(
35+
export function assertValidDateTimeFormat(
3736
dateFormat: string,
3837
dateOptions?: DateTimeOptions,
3938
): asserts dateFormat is LuxonFormat {

src/util/type-utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/**
22
* The union of all dot-separated paths in an object rescursively.
3-
* @typeParam T - the object to get paths from.
4-
* @example
53
*
4+
* Here's an illustration:
65
* ```typescript
76
* type Obj = { a: { b: { c: string } } };
87
*
98
* type ObjPaths = PathsOf<Obj>;
109
* // ^? type ObjPaths = "a" | "a.b" | "a.b.c"
1110
* ```
11+
* @typeParam T - the object to get paths from.
1212
*/
1313
export type PathsOf<T> =
1414
T extends object ?

0 commit comments

Comments
 (0)