Skip to content

Commit 2efeedc

Browse files
committed
docs: Document addition of query.allTasks to custom searches
1 parent 6a14af6 commit 2efeedc

File tree

5 files changed

+47
-8
lines changed

5 files changed

+47
-8
lines changed

docs/Introduction.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,22 @@ _In recent [releases](https://github.com/obsidian-tasks-group/obsidian-tasks/rel
1313
Move the older ones down to the top of the comment block below...
1414
-->
1515

16+
- X.Y.Z:
17+
- `query.allTasks` is now available in custom searches: see [[Query Properties#Values for Query Search Properties|query search properties]].
1618
- 6.0.0:
1719
- Add [[Custom Sorting|custom sorting]].
1820
- Document the [[Sorting#Default sort order|default sort order]].
1921
- **Warning**: This release contains some **bug-fixes** to **sorting** and to treatment of **invalid dates**.
2022
- The changes are detailed in [[breaking changes#Tasks 6.0.0 (19 January 2024)|breaking changes]], even though they are all improvements to the previous behaviour.
2123
- You may need to update any CSS snippets for the Edit or Postpone buttons: see [[How to style buttons]].
22-
- 5.6.0:
23-
- The [[Postponing|postpone]] menu now offers `today` and `tomorrow`.
24-
- 5.5.0:
25-
- The [[Create or edit Task]] modal can now edit Created, Done and Cancelled dates
26-
- Add support for [[Dates#Cancelled date|cancelled dates]].
2724

2825
> [!Released]- Earlier Releases
2926
>
27+
> - 5.6.0:
28+
> - The [[Postponing|postpone]] menu now offers `today` and `tomorrow`.
29+
> - 5.5.0:
30+
> - The [[Create or edit Task]] modal can now edit Created, Done and Cancelled dates
31+
> - Add support for [[Dates#Cancelled date|cancelled dates]].
3032
> - 5.4.0:
3133
> - Add [[Layout#Full Mode|'full mode']] to turn off `short mode`.
3234
> - Add any [[Grouping|'group by']] and [[Sorting|'sort by']] instructions to [[Explaining Queries|explain]] output.

docs/Scripting/Query Properties.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,17 @@ This page documents all the available pieces of information in Queries that you
4242
1. The presence of `.md` filename extensions is chosen to match the existing conventions in the Tasks filter instructions [[Filters#File Path|path]] and [[Filters#File Name|filename]].
4343
1. `query.file.pathWithoutExtension` was added in Tasks 4.8.0.
4444
1. `query.file.filenameWithoutExtension` was added in Tasks 4.8.0.
45+
46+
## Values for Query Search Properties
47+
48+
<!-- placeholder to force blank line before included text --><!-- include: QueryProperties.test.query_search_properties.approved.md -->
49+
50+
| Field | Type | Example |
51+
| ----- | ----- | ----- |
52+
| `query.allTasks` | `Task[]` | `[... an array with all the Tasks-tracked tasks in the vault ...]` |
53+
54+
<!-- placeholder to force blank line after included text --><!-- endInclude -->
55+
56+
1. `query.allTasks` provides access to all the tasks that Tasks has read from the vault.
57+
1. See [[Task Properties]] for the available properties on each task in `query.allTasks`.
58+
1. `query.allTasks` was added in Tasks X.Y.Z.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!-- placeholder to force blank line before included text -->
2+
3+
| Field | Type | Example |
4+
| ----- | ----- | ----- |
5+
| `query.allTasks` | `Task[]` | `[... an array with all the Tasks-tracked tasks in the vault ...]` |
6+
7+
8+
<!-- placeholder to force blank line after included text -->

tests/Scripting/QueryProperties.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ describe('query', () => {
1010
function verifyFieldDataForReferenceDocs(fields: string[]) {
1111
const markdownTable = new MarkdownTable(['Field', 'Type', 'Example']);
1212
const path = 'root/sub-folder/file containing query.md';
13-
const task = new TaskBuilder().build();
13+
const task = new TaskBuilder()
14+
.description('... an array with all the Tasks-tracked tasks in the vault ...')
15+
.build();
1416
const queryContext = makeQueryContextWithTasks(path, [task]);
1517
for (const field of fields) {
1618
const value1 = parseAndEvaluateExpression(task, field, queryContext);
@@ -34,4 +36,8 @@ describe('query', () => {
3436
'query.file.filenameWithoutExtension',
3537
]);
3638
});
39+
40+
it('search properties', () => {
41+
verifyFieldDataForReferenceDocs(['query.allTasks']);
42+
});
3743
});

tests/Scripting/ScriptingTestHelpers.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import moment from 'moment';
22
import { TasksDate } from '../../src/Scripting/TasksDate';
33
import { TaskRegularExpressions } from '../../src/Task/TaskRegularExpressions';
4+
import { Task } from '../../src/Task/Task';
45

56
export function formatToRepresentType(x: any): string {
67
if (typeof x === 'string') {
@@ -11,6 +12,10 @@ export function formatToRepresentType(x: any): string {
1112
return `moment('${x.format(TaskRegularExpressions.dateTimeFormat)}')`;
1213
}
1314

15+
if (x instanceof Task) {
16+
return x.description;
17+
}
18+
1419
if (x instanceof TasksDate) {
1520
return x.formatAsDateAndTime();
1621
}
@@ -33,7 +38,7 @@ export function addBackticks(x: any) {
3338
return quotedText;
3439
}
3540

36-
export function determineExpressionType(value: any) {
41+
export function determineExpressionType(value: any): string {
3742
if (value === null) {
3843
return 'null';
3944
}
@@ -42,13 +47,17 @@ export function determineExpressionType(value: any) {
4247
return 'Moment';
4348
}
4449

50+
if (value instanceof Task) {
51+
return 'Task';
52+
}
53+
4554
if (value instanceof TasksDate) {
4655
return 'TasksDate';
4756
}
4857

4958
if (Array.isArray(value)) {
5059
if (value.length > 0) {
51-
return `${typeof value[0]}[]`;
60+
return `${determineExpressionType(value[0])}[]`;
5261
} else {
5362
return 'any[]';
5463
}

0 commit comments

Comments
 (0)