Skip to content

Commit 15b0cdc

Browse files
authored
Merge pull request #2607 from obsidian-tasks-group/tidy-src-and-tests
refactor: Rearrange src/ and tests/ so structure is easier to see
2 parents 03c1e68 + 3ce7946 commit 15b0cdc

File tree

219 files changed

+522
-521
lines changed

Some content is hidden

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

219 files changed

+522
-521
lines changed

contributing/Code/How do I add a new field to the Task class.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ For example, It's fine to have a first release of a feature without `sort by` an
1717

1818
### Store the field
1919

20-
- Add the field to [src/Task.ts](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/src/Task.ts)
20+
- Add the field to [src/Task/Task.ts](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/src/Task/Task.ts)
2121

2222
### Read and write the field
2323

2424
- Update all supported formats in [src/TaskSerializer/](https://github.com/obsidian-tasks-group/obsidian-tasks/tree/main/src/TaskSerializer)
2525

2626
### Detect edits to field value
2727

28-
- In [tests/Task.test.ts](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/tests/Task.test.ts):
28+
- In [tests/Task/Task.test.ts](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/tests/Task/Task.test.ts):
2929
- Add a new failing block to the `'identicalTo'` section.
3030
- Here is an existing example: ['should check path'](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/5b0831c36a80c4cde2d64a6cd281bb4b51e9a142/tests/Task.test.ts#L834-L840).
31-
- In [src/Task.ts](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/src/Task.ts), update `Task.identicalTo()`:
32-
- Once you have a failing test in [tests/Task.test.ts](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/tests/Task.test.ts), implement the check for changed value of your new field in `Task.identicalTo()`.
31+
- In [src/Task/Task.ts](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/src/Task/Task.ts), update `Task.identicalTo()`:
32+
- Once you have a failing test in [tests/Task/Task.test.ts](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/tests/Task/Task.test.ts), implement the check for changed value of your new field in `Task.identicalTo()`.
3333
- This important method is used to detect whether any edits of any kind have been made to a task, to detect whether task block results need to be updated.
3434
- Here is the code for the method as of 2022-11-12:
3535
- [Task.identicalTo() in 5b0831c36a80c4cde2d64a6cd281bb4b51e9a142](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/5b0831c36a80c4cde2d64a6cd281bb4b51e9a142/src/Task.ts#L732-L802)
@@ -70,4 +70,4 @@ Can be added in later releases
7070
- Update `dates.md`
7171
- Handling invalid dates
7272
- Add the new field to all sections of [resources/sample_vaults/Tasks-Demo/Manual Testing/Invalid Dates.md](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/resources/sample_vaults/Tasks-Demo/Manual%20Testing/Invalid%20Dates.md)
73-
- Update the query in the 'invalid dates' section of [docs/queries/filters.md](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/docs/queries/filters.md)
73+
- Update the query in the 'invalid dates' section of [docs/Queries/Filters.md](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/docs/Queries/Filters.md)

contributing/Code/How do I add a new task filter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ For help on writing and running the tests, see [[About Testing]]
2727
- Add to [tests/Query/Filter](https://github.com/obsidian-tasks-group/obsidian-tasks/tree/main/tests/Query/Filter) a new test file.
2828
- This should focus on testing whether or not individual Task objects, with carefully selected sample date, match the filter.
2929
- Think about edge cases.
30-
- Add the new instruction(s) to 'Query parsing' test in [tests/Query.test.ts](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/tests/Query.test.ts)
30+
- Add the new instruction(s) to 'Query parsing' test in [tests/Query/Query.test.ts](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/tests/Query/Query.test.ts)
3131
- This verifies that the new filter instruction has been correctly wired in to the Query class.
3232

3333
## Update doc/

contributing/Code/How does Tasks handle status changes.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ You can toggle a task‘s status by:
55
| # | User mechanism | Source-code location | Toggle behaviour |
66
| --- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
77
| 1 | using the **command** (may be bound to a hotkey). | [src/Commands/ToggleDone.ts](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/src/Commands/ToggleDone.ts) | toggles the line directly where the cursor is in the file inside Obsidian's vault. |
8-
| 2 | clicking on a checkbox of an **inline task** in **Live Preview**. | [src/LivePreviewExtension.ts](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/src/LivePreviewExtension.ts) | toggles the line directly where the checkbox is on the "document" of CodeMirror (the library that Obsidian uses to show text on screen).<br>That, in turn, updates the file in Obsidian's Vault. |
9-
| 3 | clicking on a checkbox of an **inline task** in **Reading mode**. | uses a checkbox created by `renderTaskLine()` in [src/TaskLineRenderer](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/src/TaskLineRenderer.ts).<br>There, the checkbox gets a click event handler. | The click event listener of 3. and 4. uses `replaceTaskWithTasks()` in [src/File.ts](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/src/File.ts).<br>That, in turn, updates the file in Obsidian‘s Vault (like 1, but it needs to find the correct line). |
8+
| 2 | clicking on a checkbox of an **inline task** in **Live Preview**. | [src/Obsidian/LivePreviewExtension.ts](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/src/Obsidian/LivePreviewExtension.ts) | toggles the line directly where the checkbox is on the "document" of CodeMirror (the library that Obsidian uses to show text on screen).<br>That, in turn, updates the file in Obsidian's Vault. |
9+
| 3 | clicking on a checkbox of an **inline task** in **Reading mode**. | uses a checkbox created by `renderTaskLine()` in [src/Renderer/TaskLineRenderer](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/src/Renderer/TaskLineRenderer.ts).<br>There, the checkbox gets a click event handler. | The click event listener of 3. and 4. uses `replaceTaskWithTasks()` in [src/Obsidian/File.ts](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/src/Obsidian/File.ts).<br>That, in turn, updates the file in Obsidian‘s Vault (like 1, but it needs to find the correct line). |
1010
| 4 | clicking on a checkbox in **query results** (same for **Reading mode** and **Live Preview**). | As 3 | As 3 |
1111
| 5 | via 'Create or edit task' **modal** Status dropdown | [src/ui/EditTask.svelte](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/src/ui/EditTask.svelte) and [src/Commands/CreateOrEdit.ts](https://github.com/obsidian-tasks-group/obsidian-tasks/blob/main/src/Commands/CreateOrEdit.ts) | Not yet implemented: see [#1590](https://github.com/obsidian-tasks-group/obsidian-tasks/issues/1590) |
1212

src/Api/createTaskLineModal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { App } from 'obsidian';
2-
import type { Task } from '../Task';
2+
import type { Task } from '../Task/Task';
33

44
/**
55
* Interface to remove all references to {TaskModal} in this file.

src/Api/createTaskLineModalHelper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { App } from 'obsidian';
2-
import type { Task } from '../Task';
2+
import type { Task } from '../Task/Task';
33
import { taskFromLine } from '../Commands/CreateOrEditTaskParser';
4-
import { TaskModal } from '../TaskModal';
4+
import { TaskModal } from '../Obsidian/TaskModal';
55
import type { ITaskModal, taskModalFactory } from './createTaskLineModal';
66

77
/**

src/Commands/CreateOrEdit.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { App, Editor, MarkdownView, View } from 'obsidian';
2-
import { TaskModal } from '../TaskModal';
3-
import type { Task } from '../Task';
4-
import { DateFallback } from '../DateFallback';
2+
import { TaskModal } from '../Obsidian/TaskModal';
3+
import type { Task } from '../Task/Task';
4+
import { DateFallback } from '../Task/DateFallback';
55
import { taskFromLine } from './CreateOrEditTaskParser';
66

77
export const createOrEdit = (checking: boolean, editor: Editor, view: View, app: App, allTasks: Task[]) => {

src/Commands/CreateOrEditTaskParser.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { Status } from '../Status';
2-
import { Priority, Task, TaskRegularExpressions } from '../Task';
3-
import { DateFallback } from '../DateFallback';
4-
import { StatusRegistry } from '../StatusRegistry';
5-
import { TaskLocation } from '../TaskLocation';
1+
import { Status } from '../Statuses/Status';
2+
import { Priority, Task, TaskRegularExpressions } from '../Task/Task';
3+
import { DateFallback } from '../Task/DateFallback';
4+
import { StatusRegistry } from '../Statuses/StatusRegistry';
5+
import { TaskLocation } from '../Task/TaskLocation';
66
import { getSettings } from '../Config/Settings';
77
import { GlobalFilter } from '../Config/GlobalFilter';
88

src/Commands/ToggleDone.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Editor, type EditorPosition, type MarkdownFileInfo, MarkdownView } from 'obsidian';
2-
import { StatusRegistry } from '../StatusRegistry';
2+
import { StatusRegistry } from '../Statuses/StatusRegistry';
33

4-
import { Task, TaskRegularExpressions } from '../Task';
5-
import { TaskLocation } from '../TaskLocation';
4+
import { Task, TaskRegularExpressions } from '../Task/Task';
5+
import { TaskLocation } from '../Task/TaskLocation';
66

77
export const toggleDone = (checking: boolean, editor: Editor, view: MarkdownView | MarkdownFileInfo) => {
88
if (checking) {

src/Config/CustomStatusModal.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Modal, Notice, Setting, TextComponent } from 'obsidian';
22
import type { Plugin } from 'obsidian';
3-
import { StatusConfiguration, StatusType } from '../StatusConfiguration';
4-
import { StatusValidator } from '../StatusValidator';
5-
import { Status } from '../Status';
3+
import { StatusConfiguration, StatusType } from '../Statuses/StatusConfiguration';
4+
import { StatusValidator } from '../Statuses/StatusValidator';
5+
import { Status } from '../Statuses/Status';
66

77
const validator = new StatusValidator();
88

src/Config/Settings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
} from '../Suggestor/Suggestor';
66
import { DEFAULT_SYMBOLS } from '../TaskSerializer/DefaultTaskSerializer';
77
import { DATAVIEW_SYMBOLS } from '../TaskSerializer/DataviewTaskSerializer';
8-
import { StatusConfiguration } from '../StatusConfiguration';
9-
import { Status } from '../Status';
8+
import { StatusConfiguration } from '../Statuses/StatusConfiguration';
9+
import { Status } from '../Statuses/Status';
1010
import { DefaultTaskSerializer, type TaskSerializer } from '../TaskSerializer';
1111
import type { SuggestionBuilder } from '../Suggestor';
1212
import type { LogOptions } from '../lib/logging';

0 commit comments

Comments
 (0)