Skip to content

Commit b484607

Browse files
📝 Add docstrings to docs (#61)
* 📝 Add docstrings to `docs` Docstrings generation was requested by @brianrodri. * #60 (comment) The following files were modified: * `src/model/task/lib/obsidian-tasks.ts` * `src/util/luxon-utils.ts` * Update src/util/luxon-utils.ts * Update src/model/task/lib/obsidian-tasks.ts * Update src/util/luxon-utils.ts * Update src/model/task/lib/obsidian-tasks.ts --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: Brian Rodriguez <[email protected]>
1 parent 9aefb95 commit b484607

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

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

+15-9
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,24 @@ import { Task } from "@/model/task/schema";
77
import { SYMBOL_PATH_LOOKUP, SYMBOL_PRIORITY_LOOKUP, SYMBOL_REG_EXP } from "./obsidian-tasks.const";
88

99
/**
10-
* Parses {@link Task} metadata from a real markdown blob using Obsidian Task's emoji format.
10+
* Parses task metadata from a markdown string using Obsidian Task's emoji format.
1111
*
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 )
12+
* The function extracts the task description (the text preceding the first emoji symbol) and associated metadata.
13+
* Recognized emoji markers denote fields such as cancellation, creation, completion dates, priority, or dependencies.
1714
*
18-
* { cancelled: "cancelled date", created: "creation date", done: "completed date" }
15+
* For example:
16+
* ```
17+
* "Prepare slides ❌ 2025-05-01 ➕ 2025-04-20 ✅ 2025-05-05"
18+
* // Returns an object similar to:
19+
* // {
20+
* // description: "Prepare slides",
21+
* // cancelled: DateTime for "2025-05-01",
22+
* // created: DateTime for "2025-04-20",
23+
* // done: DateTime for "2025-05-05"
24+
* // }
1925
* ```
20-
* @param text - the text of the task without its' markdown text.
21-
* @returns a {@link Task} with the parsed metadata.
26+
* @param text - The markdown text containing the task description and metadata formatted with Obsidian Task's emoji syntax.
27+
* @returns A partial {@link Task} object populated with the extracted metadata.
2228
* @see {@link https://publish.obsidian.md/tasks/Reference/Task+Formats/Tasks+Emoji+Format}
2329
*/
2430
export function parseTaskEmojiFormat(text: string): DeepPartial<Task> {

src/util/luxon-utils.ts

+9-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,16 @@ export function assertValidLuxonValue(
2828
}
2929

3030
/**
31-
* @param dateFormat - the format to check.
32-
* @param dateOptions - the options to use when parsing and formatting.
31+
* Asserts that the provided date format yields consistent results when formatting and parsing a date.
32+
*
33+
* This function formats a fixed UTC reference date into a string using the given format and optional options,
34+
* then parses that string back into a date. It verifies that the parsed date is valid and that reformatting it
35+
* produces the original string. Failing this consistency check triggers an error, indicating that the format is invalid
36+
* for round-trip date conversions.
37+
* @param dateFormat - The date format string to validate.
38+
* @param dateOptions - Optional formatting and parsing options for date-time operations.
3339
* @see {@link https://moment.github.io/luxon/#/parsing?id=table-of-tokens}
40+
* @throws If the date format does not produce matching formatted strings upon parsing.
3441
*/
3542
export function assertValidDateTimeFormat(
3643
dateFormat: string,

0 commit comments

Comments
 (0)