whatnext 3.4__tar.gz → 3.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. {whatnext-3.4 → whatnext-3.5}/CHANGELOG.md +13 -0
  2. {whatnext-3.4 → whatnext-3.5}/PKG-INFO +2 -2
  3. whatnext-3.5/docs/including.md +26 -0
  4. {whatnext-3.4 → whatnext-3.5}/docs/index.md +3 -0
  5. {whatnext-3.4 → whatnext-3.5}/docs/usage.md +2 -2
  6. whatnext-3.5/tasks/including.md +8 -0
  7. whatnext-3.5/tests/including/chain-a.md +2 -0
  8. whatnext-3.5/tests/including/diamond-a.md +3 -0
  9. whatnext-3.5/tests/including/diamond-b.md +2 -0
  10. whatnext-3.5/tests/including/diamond-c.md +2 -0
  11. whatnext-3.5/tests/including/diamond-d.md +1 -0
  12. whatnext-3.5/tests/including/included.md +1 -0
  13. whatnext-3.5/tests/including/includes-empty.md +2 -0
  14. whatnext-3.5/tests/including/includes-missing.md +2 -0
  15. whatnext-3.5/tests/including/list.md +3 -0
  16. whatnext-3.5/tests/including/loop-a.md +2 -0
  17. whatnext-3.5/tests/including/loop-b.md +2 -0
  18. whatnext-3.5/tests/including/queue.md +3 -0
  19. whatnext-3.5/tests/including/subdir/chain-b.md +2 -0
  20. whatnext-3.5/tests/including/subdir/chain-c.md +1 -0
  21. whatnext-3.5/tests/including/transitive.md +2 -0
  22. whatnext-3.5/tests/including.bats +58 -0
  23. {whatnext-3.4 → whatnext-3.5}/tests/mute.bats +12 -0
  24. {whatnext-3.4 → whatnext-3.5}/tests/test_file.py +138 -0
  25. {whatnext-3.4 → whatnext-3.5}/tests/usage.bats +7 -10
  26. whatnext-3.5/whatnext/__init__.py +0 -0
  27. {whatnext-3.4 → whatnext-3.5}/whatnext/guide.txt +7 -0
  28. {whatnext-3.4 → whatnext-3.5}/whatnext/models.py +41 -10
  29. {whatnext-3.4 → whatnext-3.5}/whatnext/whatnext.py +14 -7
  30. {whatnext-3.4 → whatnext-3.5}/.flake8 +0 -0
  31. {whatnext-3.4 → whatnext-3.5}/.github/dependabot.yml +0 -0
  32. {whatnext-3.4 → whatnext-3.5}/.github/workflows/publish.yml +0 -0
  33. {whatnext-3.4 → whatnext-3.5}/.github/workflows/tests.yml +0 -0
  34. {whatnext-3.4 → whatnext-3.5}/.gitignore +0 -0
  35. {whatnext-3.4 → whatnext-3.5}/.whatnext +0 -0
  36. {whatnext-3.4 → whatnext-3.5}/LICENCE +0 -0
  37. {whatnext-3.4 → whatnext-3.5}/LICENSE +0 -0
  38. {whatnext-3.4 → whatnext-3.5}/Makefile +0 -0
  39. {whatnext-3.4 → whatnext-3.5}/README.md +0 -0
  40. {whatnext-3.4 → whatnext-3.5}/archive/done/tasks.md +0 -0
  41. {whatnext-3.4 → whatnext-3.5}/docs/annotations.md +0 -0
  42. {whatnext-3.4 → whatnext-3.5}/docs/basics.md +0 -0
  43. {whatnext-3.4 → whatnext-3.5}/docs/deadlines.md +0 -0
  44. {whatnext-3.4 → whatnext-3.5}/docs/deferring.md +0 -0
  45. {whatnext-3.4 → whatnext-3.5}/docs/exclusions.md +0 -0
  46. {whatnext-3.4 → whatnext-3.5}/docs/installation.md +0 -0
  47. {whatnext-3.4 → whatnext-3.5}/docs/next.md +0 -0
  48. {whatnext-3.4 → whatnext-3.5}/docs/prioritisation.md +0 -0
  49. {whatnext-3.4 → whatnext-3.5}/docs/sequential.md +0 -0
  50. {whatnext-3.4 → whatnext-3.5}/example/archived/projects/tangerine.md +0 -0
  51. {whatnext-3.4 → whatnext-3.5}/example/projects/curtain.md +0 -0
  52. {whatnext-3.4 → whatnext-3.5}/example/projects/fountain.md +0 -0
  53. {whatnext-3.4 → whatnext-3.5}/example/projects/harvest.md +0 -0
  54. {whatnext-3.4 → whatnext-3.5}/example/projects/obelisk.md +0 -0
  55. {whatnext-3.4 → whatnext-3.5}/example/projects/tinsel.md +0 -0
  56. {whatnext-3.4 → whatnext-3.5}/example/tasks.md +0 -0
  57. {whatnext-3.4 → whatnext-3.5}/example/template.md +0 -0
  58. {whatnext-3.4 → whatnext-3.5}/pyproject.toml +0 -0
  59. {whatnext-3.4 → whatnext-3.5}/scripts/update-usage-examples.py +0 -0
  60. {whatnext-3.4 → whatnext-3.5}/tasks/deferring.md +0 -0
  61. {whatnext-3.4 → whatnext-3.5}/tasks/documentation.md +0 -0
  62. {whatnext-3.4 → whatnext-3.5}/tasks/ignoring.md +0 -0
  63. {whatnext-3.4 → whatnext-3.5}/tasks/listing.md +0 -0
  64. {whatnext-3.4 → whatnext-3.5}/tasks/muting.md +0 -0
  65. {whatnext-3.4 → whatnext-3.5}/tasks/next.md +0 -0
  66. {whatnext-3.4 → whatnext-3.5}/tasks/summaries.md +0 -0
  67. {whatnext-3.4 → whatnext-3.5}/tasks/test_refactor.md +0 -0
  68. {whatnext-3.4 → whatnext-3.5}/tasks/version_0.1.md +0 -0
  69. {whatnext-3.4 → whatnext-3.5}/tasks/version_0.2.md +0 -0
  70. {whatnext-3.4 → whatnext-3.5}/tasks/version_0.3.md +0 -0
  71. {whatnext-3.4 → whatnext-3.5}/tasks/version_0.4.md +0 -0
  72. {whatnext-3.4 → whatnext-3.5}/tasks/version_0.5.md +0 -0
  73. {whatnext-3.4 → whatnext-3.5}/tasks/version_1.0.md +0 -0
  74. {whatnext-3.4 → whatnext-3.5}/tasks/version_1.1.md +0 -0
  75. {whatnext-3.4 → whatnext-3.5}/tasks/version_1.2.md +0 -0
  76. {whatnext-3.4 → whatnext-3.5}/tasks/version_1.3.md +0 -0
  77. {whatnext-3.4 → whatnext-3.5}/tasks.md +0 -0
  78. {whatnext-3.4 → whatnext-3.5}/tests/colour.bats +0 -0
  79. {whatnext-3.4 → whatnext-3.5}/tests/config/.whatnext +0 -0
  80. {whatnext-3.4 → whatnext-3.5}/tests/config/.whatnext.alt +0 -0
  81. {whatnext-3.4 → whatnext-3.5}/tests/config/apples.md +0 -0
  82. {whatnext-3.4 → whatnext-3.5}/tests/config/oranges.md +0 -0
  83. {whatnext-3.4 → whatnext-3.5}/tests/config-external +0 -0
  84. {whatnext-3.4 → whatnext-3.5}/tests/config.bats +0 -0
  85. {whatnext-3.4 → whatnext-3.5}/tests/deadline.bats +0 -0
  86. {whatnext-3.4 → whatnext-3.5}/tests/deferring/bare-after.md +0 -0
  87. {whatnext-3.4 → whatnext-3.5}/tests/deferring/circular-a.md +0 -0
  88. {whatnext-3.4 → whatnext-3.5}/tests/deferring/circular-b.md +0 -0
  89. {whatnext-3.4 → whatnext-3.5}/tests/deferring/deferred.md +0 -0
  90. {whatnext-3.4 → whatnext-3.5}/tests/deferring/dir-complete/tasks.md +0 -0
  91. {whatnext-3.4 → whatnext-3.5}/tests/deferring/duplicate-warnings.md +0 -0
  92. {whatnext-3.4 → whatnext-3.5}/tests/deferring/missing-dep.md +0 -0
  93. {whatnext-3.4 → whatnext-3.5}/tests/deferring/needs-absolute.md +0 -0
  94. {whatnext-3.4 → whatnext-3.5}/tests/deferring/needs-dir-complete.md +0 -0
  95. {whatnext-3.4 → whatnext-3.5}/tests/deferring/needs-subdir-file.md +0 -0
  96. {whatnext-3.4 → whatnext-3.5}/tests/deferring/needs-subdir.md +0 -0
  97. {whatnext-3.4 → whatnext-3.5}/tests/deferring/phase-misplaced.md +0 -0
  98. {whatnext-3.4 → whatnext-3.5}/tests/deferring/phases-empty.md +0 -0
  99. {whatnext-3.4 → whatnext-3.5}/tests/deferring/phases-partial.md +0 -0
  100. {whatnext-3.4 → whatnext-3.5}/tests/deferring/phases-queue.md +0 -0
  101. {whatnext-3.4 → whatnext-3.5}/tests/deferring/phases.md +0 -0
  102. {whatnext-3.4 → whatnext-3.5}/tests/deferring/regular.md +0 -0
  103. {whatnext-3.4 → whatnext-3.5}/tests/deferring/root-target.md +0 -0
  104. {whatnext-3.4 → whatnext-3.5}/tests/deferring/samename.md +0 -0
  105. {whatnext-3.4 → whatnext-3.5}/tests/deferring/subdir/needs-parent.md +0 -0
  106. {whatnext-3.4 → whatnext-3.5}/tests/deferring/subdir/needs-sibling.md +0 -0
  107. {whatnext-3.4 → whatnext-3.5}/tests/deferring/subdir/samename.md +0 -0
  108. {whatnext-3.4 → whatnext-3.5}/tests/deferring/subdir/target.md +0 -0
  109. {whatnext-3.4 → whatnext-3.5}/tests/deferring.bats +0 -0
  110. {whatnext-3.4 → whatnext-3.5}/tests/edit.bats +0 -0
  111. {whatnext-3.4 → whatnext-3.5}/tests/headerless/annotation.md +0 -0
  112. {whatnext-3.4 → whatnext-3.5}/tests/headerless/deadline.md +0 -0
  113. {whatnext-3.4 → whatnext-3.5}/tests/housekeeping.bats +0 -0
  114. /whatnext-3.4/whatnext/__init__.py → /whatnext-3.5/tests/including/empty.md +0 -0
  115. {whatnext-3.4 → whatnext-3.5}/tests/invalid.md +0 -0
  116. {whatnext-3.4 → whatnext-3.5}/tests/list.bats +0 -0
  117. {whatnext-3.4 → whatnext-3.5}/tests/matching.bats +0 -0
  118. {whatnext-3.4 → whatnext-3.5}/tests/mute/.whatnext.mute +0 -0
  119. {whatnext-3.4 → whatnext-3.5}/tests/mute/.whatnext.mute.expected +0 -0
  120. {whatnext-3.4 → whatnext-3.5}/tests/mute/tasks.md +0 -0
  121. {whatnext-3.4 → whatnext-3.5}/tests/mute-fixture/tasks.md +0 -0
  122. {whatnext-3.4 → whatnext-3.5}/tests/next/alternate.md +0 -0
  123. {whatnext-3.4 → whatnext-3.5}/tests/next/append-after.md +0 -0
  124. {whatnext-3.4 → whatnext-3.5}/tests/next/append.md +0 -0
  125. {whatnext-3.4 → whatnext-3.5}/tests/next/empty.md +0 -0
  126. {whatnext-3.4 → whatnext-3.5}/tests/next/insert.md +0 -0
  127. {whatnext-3.4 → whatnext-3.5}/tests/next/projects/alpha/tasks/things.md +0 -0
  128. {whatnext-3.4 → whatnext-3.5}/tests/next/projects/alpha/tasks.md +0 -0
  129. {whatnext-3.4 → whatnext-3.5}/tests/next/projects/beta/things.md +0 -0
  130. {whatnext-3.4 → whatnext-3.5}/tests/next/something.txt +0 -0
  131. {whatnext-3.4 → whatnext-3.5}/tests/next/tasks.md +0 -0
  132. {whatnext-3.4 → whatnext-3.5}/tests/next/wide.md +0 -0
  133. {whatnext-3.4 → whatnext-3.5}/tests/next/wrapped.md +0 -0
  134. {whatnext-3.4 → whatnext-3.5}/tests/next.bats +0 -0
  135. {whatnext-3.4 → whatnext-3.5}/tests/notnext.bats +0 -0
  136. {whatnext-3.4 → whatnext-3.5}/tests/queue/all-complete.md +0 -0
  137. {whatnext-3.4 → whatnext-3.5}/tests/queue/blocked.md +0 -0
  138. {whatnext-3.4 → whatnext-3.5}/tests/queue/in-progress.md +0 -0
  139. {whatnext-3.4 → whatnext-3.5}/tests/queue/normal.md +0 -0
  140. {whatnext-3.4 → whatnext-3.5}/tests/queue/prioritised.md +0 -0
  141. {whatnext-3.4 → whatnext-3.5}/tests/queue.bats +0 -0
  142. {whatnext-3.4 → whatnext-3.5}/tests/summary.bats +0 -0
  143. {whatnext-3.4 → whatnext-3.5}/tests/test_config.py +0 -0
  144. {whatnext-3.4 → whatnext-3.5}/tests/test_defer.py +0 -0
  145. {whatnext-3.4 → whatnext-3.5}/tests/test_edit.py +0 -0
  146. {whatnext-3.4 → whatnext-3.5}/tests/test_limit.py +0 -0
  147. {whatnext-3.4 → whatnext-3.5}/tests/test_mute.py +0 -0
  148. {whatnext-3.4 → whatnext-3.5}/tests/test_output.py +0 -0
  149. {whatnext-3.4 → whatnext-3.5}/tests/test_summary.py +0 -0
  150. {whatnext-3.4 → whatnext-3.5}/tests/test_task.py +0 -0
  151. {whatnext-3.4 → whatnext-3.5}/tests/version.bats +0 -0
  152. {whatnext-3.4 → whatnext-3.5}/whatnext/next.py +0 -0
  153. {whatnext-3.4 → whatnext-3.5}/whatnext/summary.py +0 -0
@@ -1,6 +1,19 @@
1
1
  # Changelog
2
2
 
3
3
 
4
+ ## [v3.5] - 2026-08-16
5
+
6
+ **Added:**
7
+ - `@include filename` inserts another file's content, as though it was
8
+ written there.
9
+
10
+
11
+ ## [v3.4.1] - 2026-04-29
12
+
13
+ **Fixed:**
14
+ - `--mute` accepts multiple match patterns, not silently discards them.
15
+
16
+
4
17
  ## [v3.4] - 2026-04-17
5
18
 
6
19
  **Added:**
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: whatnext
3
- Version: 3.4
3
+ Version: 3.5
4
4
  Summary: A lister of tasks found in Markdown files
5
5
  Project-URL: Homepage, https://github.com/norm/whatnext
6
6
  Project-URL: Repository, https://github.com/norm/whatnext
@@ -0,0 +1,26 @@
1
+ # Including files
2
+
3
+ The purpose of multiple task files is to encourage breaking large projects
4
+ down, and to keep otherwise unrelated work separate. But at times you want to
5
+ both have multiple task files and one unified view of the tasks. If you need
6
+ to include one task file inside another, use the `@include`
7
+
8
+ As an example, a project has a lot of small, repetative tasks to perform on
9
+ multiple targets. A directory of multiple task files, one per target, would
10
+ overwhelm the output of `whatnext`, even if a directive such as `@queue` was
11
+ used.
12
+
13
+ However, using an index task file and `@include` gives us more control:
14
+
15
+ ```markdown
16
+ @queue
17
+
18
+ @include subtasks/a.md
19
+ @include subtasks/b.md
20
+ @include subtasks/c.md
21
+ @include subtasks/d.md
22
+ ```
23
+
24
+ The result of this would be all of the subtasks are treated as though they
25
+ are in the index file, and that file controls the output with `@queue`
26
+ so that only the next task of `a.md` appears.
@@ -59,6 +59,9 @@ order, you can [defer tasks](deferring.md) until all/some other tasks are comple
59
59
  For sequential work where only one task or small group of tasks can be done at
60
60
  a time, you can [limit output](sequential.md) within the file.
61
61
 
62
+ To build a task list up from other files to apply more control, you can
63
+ [include one file inside another](including.md).
64
+
62
65
  If you need to exclude out some Markdown files for any reason, there are
63
66
  [two ways to do that](exclusions.md).
64
67
 
@@ -234,8 +234,8 @@ To show a random selection of tasks rather than by priority, use `5r`.
234
234
 
235
235
  - `--ignore-mute` — ignore mute settings.
236
236
 
237
- - `--mute [time] [match]` — for the next 'time' period (formatted `4d`, `2w`, `1m2d`)
238
- mute any tasks with 'match' in the text, header, or filename.
237
+ - `--mute [time] match [...]` — for the next 'time' period (formatted `4d`,
238
+ `2w`, `1m2d`, etc) mute any tasks matching the standard match arguments.
239
239
 
240
240
  - `-o` / `--open` — show only open tasks.
241
241
 
@@ -0,0 +1,8 @@
1
+ If `tasks/list.md` contains the directive `@include tasks.md`, running
2
+ `whatnext` should behave as though the contents of `tasks.md` were inside
3
+ `list.md`.
4
+
5
+ - [X] `@include` directive pulls another file's contents in
6
+ - the included file is read and substituted into this file at the
7
+ directive
8
+ - the included file is no longer considered as a source
@@ -0,0 +1,2 @@
1
+ - [ ] task in a
2
+ @include subdir/chain-b.md
@@ -0,0 +1,3 @@
1
+ - [ ] task in a
2
+ @include diamond-b.md
3
+ @include diamond-c.md
@@ -0,0 +1,2 @@
1
+ - [ ] task in b
2
+ @include diamond-d.md
@@ -0,0 +1,2 @@
1
+ - [ ] task in c
2
+ @include diamond-d.md
@@ -0,0 +1 @@
1
+ - [ ] task in d
@@ -0,0 +1 @@
1
+ - [ ] from the included file
@@ -0,0 +1,2 @@
1
+ - [ ] only task
2
+ @include empty.md
@@ -0,0 +1,2 @@
1
+ - [ ] real task
2
+ @include ghost.md
@@ -0,0 +1,3 @@
1
+ - [ ] first in list
2
+ @include included.md
3
+ - [ ] last in list
@@ -0,0 +1,2 @@
1
+ - [ ] task in a
2
+ @include loop-b.md
@@ -0,0 +1,2 @@
1
+ - [ ] task in b
2
+ @include loop-a.md
@@ -0,0 +1,3 @@
1
+ @queue
2
+ - [ ] child one
3
+ - [ ] child two
@@ -0,0 +1,2 @@
1
+ - [ ] task in b
2
+ @include chain-c.md
@@ -0,0 +1 @@
1
+ - [ ] task in c
@@ -0,0 +1,2 @@
1
+ - [ ] parent task
2
+ @include queue.md
@@ -0,0 +1,58 @@
1
+ bats_require_minimum_version 1.5.0
2
+
3
+ @test "included file's contents are substituted at the directive" {
4
+ expected_output=$(sed -e 's/^ //' <<" EOF"
5
+ tests/including/list.md:
6
+ - [ ] first in list
7
+ - [ ] from the included file
8
+ - [ ] last in list
9
+ EOF
10
+ )
11
+
12
+ run --separate-stderr \
13
+ whatnext \
14
+ tests/including/list.md
15
+
16
+ diff -u <(echo "$expected_output") <(echo "$output")
17
+ [ $status -eq 0 ]
18
+ }
19
+
20
+ @test "included file is no longer considered a source" {
21
+ expected_output=$(sed -e 's/^ //' <<" EOF"
22
+ tests/including/list.md:
23
+ - [ ] first in list
24
+ - [ ] from the included file
25
+ - [ ] last in list
26
+ EOF
27
+ )
28
+
29
+ # included.md is passed alongside list.md, but because list.md includes it
30
+ # it must not appear under its own header, nor its task be shown twice
31
+ run --separate-stderr \
32
+ whatnext \
33
+ tests/including/list.md \
34
+ tests/including/included.md
35
+
36
+ diff -u <(echo "$expected_output") <(echo "$output")
37
+ [ $status -eq 0 ]
38
+ }
39
+
40
+ @test "including a non-existent file warns and contributes nothing" {
41
+ expected_output=$(sed -e 's/^ //' <<" EOF"
42
+ tests/including/includes-missing.md:
43
+ - [ ] real task
44
+ EOF
45
+ )
46
+ expected_stderr=$(sed -e 's/^ //' <<" EOF"
47
+ WARNING: tests/including/includes-missing.md: 'ghost.md' does not exist
48
+ EOF
49
+ )
50
+
51
+ run --separate-stderr \
52
+ whatnext \
53
+ tests/including/includes-missing.md
54
+
55
+ diff -u <(echo "$expected_output") <(echo "$output")
56
+ diff -u <(echo "$expected_stderr") <(echo "$stderr")
57
+ [ $status -eq 0 ]
58
+ }
@@ -26,6 +26,18 @@ bats_require_minimum_version 1.5.0
26
26
  [ $status -eq 0 ]
27
27
  }
28
28
 
29
+ @test "--mute accepts multiple patterns" {
30
+ run whatnext --config "$BATS_TEST_TMPDIR/.whatnext" --mute 1d "buy apples" "oranges"
31
+
32
+ expected=$(sed -e 's/^ //' <<-EOF
33
+ pattern = "buy apples"
34
+ pattern = "oranges"
35
+ EOF
36
+ )
37
+ diff -u <(echo "$expected") <(grep 'pattern' "$BATS_TEST_TMPDIR/.whatnext.mute")
38
+ [ $status -eq 0 ]
39
+ }
40
+
29
41
  @test "--mute rejects empty pattern" {
30
42
  run --separate-stderr \
31
43
  whatnext --config "$BATS_TEST_TMPDIR/.whatnext" --mute 1d ""
@@ -971,6 +971,28 @@ class TestNotnextParsing:
971
971
  )
972
972
  assert file.notnext is False
973
973
 
974
+ def test_escaped_notnext_in_backticks(self):
975
+ file = MarkdownFile(
976
+ source_string=dedent("""\
977
+ Use `@notnext` to hide a file.
978
+
979
+ - [ ] first task
980
+ """),
981
+ today=date(2025, 1, 1),
982
+ )
983
+ assert file.notnext is False
984
+
985
+ def test_escaped_notnext_with_backslash(self):
986
+ file = MarkdownFile(
987
+ source_string=dedent("""\
988
+ Use \\@notnext to hide a file.
989
+
990
+ - [ ] first task
991
+ """),
992
+ today=date(2025, 1, 1),
993
+ )
994
+ assert file.notnext is False
995
+
974
996
 
975
997
  class TestQueueParsing:
976
998
  def test_file_without_queue(self):
@@ -1037,3 +1059,119 @@ class TestQueueParsing:
1037
1059
  today=date(2025, 1, 1),
1038
1060
  )
1039
1061
  assert file.queue is False
1062
+
1063
+
1064
+ class TestIncludeParsing:
1065
+ def test_included_tasks_substituted_at_directive(self):
1066
+ file = MarkdownFile(
1067
+ source="tests/including/list.md",
1068
+ today=date(2025, 1, 1),
1069
+ )
1070
+ assert [task.text for task in file.tasks] == [
1071
+ "first in list",
1072
+ "from the included file",
1073
+ "last in list",
1074
+ ]
1075
+
1076
+ def test_including_empty_file_contributes_nothing(self):
1077
+ file = MarkdownFile(
1078
+ source="tests/including/includes-empty.md",
1079
+ today=date(2025, 1, 1),
1080
+ )
1081
+ assert [task.text for task in file.tasks] == ["only task"]
1082
+
1083
+ def test_included_file_can_itself_include(self):
1084
+ file = MarkdownFile(
1085
+ source="tests/including/chain-a.md",
1086
+ today=date(2025, 1, 1),
1087
+ )
1088
+ assert [task.text for task in file.tasks] == [
1089
+ "task in a",
1090
+ "task in b",
1091
+ "task in c",
1092
+ ]
1093
+
1094
+ def test_circular_include_silently_skips_already_present(self):
1095
+ file = MarkdownFile(
1096
+ source="tests/including/loop-a.md",
1097
+ today=date(2025, 1, 1),
1098
+ )
1099
+ assert [task.text for task in file.tasks] == [
1100
+ "task in a",
1101
+ "task in b",
1102
+ ]
1103
+ assert file.warnings == []
1104
+
1105
+ def test_bare_include_is_silent_no_op(self):
1106
+ file = MarkdownFile(
1107
+ source_string=dedent("""\
1108
+ - [ ] real task
1109
+ @include
1110
+ """),
1111
+ path="tests/including/probe.md",
1112
+ today=date(2025, 1, 1),
1113
+ )
1114
+ assert [task.text for task in file.tasks] == ["real task"]
1115
+ assert file.warnings == []
1116
+
1117
+ def test_directive_in_included_file_applies_to_parent(self):
1118
+ file = MarkdownFile(
1119
+ source="tests/including/transitive.md",
1120
+ today=date(2025, 1, 1),
1121
+ )
1122
+ assert file.queue is True
1123
+ assert [task.text for task in file.tasks] == [
1124
+ "parent task",
1125
+ "child one",
1126
+ "child two",
1127
+ ]
1128
+
1129
+ def test_diamond_include_present_file_included_once(self):
1130
+ file = MarkdownFile(
1131
+ source="tests/including/diamond-a.md",
1132
+ today=date(2025, 1, 1),
1133
+ )
1134
+ assert [task.text for task in file.tasks] == [
1135
+ "task in a",
1136
+ "task in b",
1137
+ "task in d",
1138
+ "task in c",
1139
+ ]
1140
+
1141
+ def test_escaped_include_in_backticks(self):
1142
+ file = MarkdownFile(
1143
+ source_string=dedent("""\
1144
+ Use `@include included.md` to pull a file in.
1145
+
1146
+ - [ ] first task
1147
+ """),
1148
+ path="tests/including/probe.md",
1149
+ today=date(2025, 1, 1),
1150
+ )
1151
+ assert [task.text for task in file.tasks] == ["first task"]
1152
+
1153
+ def test_escaped_include_with_backslash(self):
1154
+ file = MarkdownFile(
1155
+ source_string=dedent("""\
1156
+ Use \\@include included.md to pull a file in.
1157
+
1158
+ - [ ] first task
1159
+ """),
1160
+ path="tests/including/probe.md",
1161
+ today=date(2025, 1, 1),
1162
+ )
1163
+ assert [task.text for task in file.tasks] == ["first task"]
1164
+
1165
+ def test_include_must_be_on_own_line(self):
1166
+ file = MarkdownFile(
1167
+ source_string=dedent("""\
1168
+ # Tasks
1169
+
1170
+ - [ ] something @include included.md something else
1171
+ """),
1172
+ path="tests/including/probe.md",
1173
+ today=date(2025, 1, 1),
1174
+ )
1175
+ assert [task.text for task in file.tasks] == [
1176
+ "something @include included.md something else"
1177
+ ]
@@ -8,10 +8,9 @@ bats_require_minimum_version 1.5.0
8
8
  expected_output=$(sed -e 's/^ //' <<" EOF"
9
9
  Usage: whatnext [-h] [--help] [--version] [--guide] [--dir DIR] [-s] [-e]
10
10
  [--relative] [-a] [--ignore-after] [--ignore-queue]
11
- [--ignore-phase] [--ignore-all] [--ignore-mute]
12
- [--mute TIME MATCH] [--config CONFIG] [--ignore PATTERN] [-q]
13
- [-o] [-p] [-b] [-d] [-c] [--priority LEVEL]
14
- [--color | --no-color]
11
+ [--ignore-phase] [--ignore-all] [--ignore-mute] [--mute TIME]
12
+ [--config CONFIG] [--ignore PATTERN] [-q] [-o] [-p] [-b] [-d]
13
+ [-c] [--priority LEVEL] [--color | --no-color]
15
14
  [match ...]
16
15
  EOF
17
16
  )
@@ -27,10 +26,9 @@ bats_require_minimum_version 1.5.0
27
26
  expected_output=$(sed -e 's/^ //' <<" EOF"
28
27
  Usage: whatnext [-h] [--help] [--version] [--guide] [--dir DIR] [-s] [-e]
29
28
  [--relative] [-a] [--ignore-after] [--ignore-queue]
30
- [--ignore-phase] [--ignore-all] [--ignore-mute]
31
- [--mute TIME MATCH] [--config CONFIG] [--ignore PATTERN] [-q]
32
- [-o] [-p] [-b] [-d] [-c] [--priority LEVEL]
33
- [--color | --no-color]
29
+ [--ignore-phase] [--ignore-all] [--ignore-mute] [--mute TIME]
30
+ [--config CONFIG] [--ignore PATTERN] [-q] [-o] [-p] [-b] [-d]
31
+ [-c] [--priority LEVEL] [--color | --no-color]
34
32
  [match ...]
35
33
 
36
34
  List tasks found in Markdown files
@@ -61,8 +59,7 @@ bats_require_minimum_version 1.5.0
61
59
  --ignore-all Ignore all deferral constraints (@after, @phase,
62
60
  @queue)
63
61
  --ignore-mute Ignore mute settings
64
- --mute TIME MATCH Mute tasks matching pattern for period (e.g. 1d, 2w,
65
- 1m)
62
+ --mute TIME Mute matching tasks for period (e.g. --mute 1d foo bar)
66
63
  --config CONFIG Path to config file (default: WHATNEXT_CONFIG, or
67
64
  '.whatnext' in --dir)
68
65
  --ignore PATTERN Ignore files matching pattern (can be specified
File without changes
@@ -65,6 +65,13 @@ only be shown when previous groups are complete, use @phase on the headers.
65
65
  - [ ] update code to implement desired behaviour
66
66
  - [ ] prove tests pass
67
67
 
68
+ To pull another file's contents into this one, use @include with a filename.
69
+ It is substituted in where the directive appears, as though written there.
70
+
71
+ # Shopping
72
+ - [ ] buy milk
73
+ @include weekend.md
74
+
68
75
  Context around tasks, such as detailed decision notes and designs can be
69
76
  included in the document without showing in the task list. To include a
70
77
  short note in the summary, use special fence blocks:
@@ -251,6 +251,7 @@ class MarkdownFile:
251
251
  $
252
252
  """, re.VERBOSE)
253
253
  FILE_AFTER_PATTERN = re.compile(r"^@after(?:\s+(.+))?\s*$")
254
+ INCLUDE_PATTERN = re.compile(r"^@include\s+(.+?)\s*$")
254
255
  NOTNEXT_PATTERN = re.compile(r"^@notnext(?:\s|$)")
255
256
  QUEUE_PATTERN = re.compile(r"^@queue(?:\s|$)")
256
257
  PHASE_PATTERN = re.compile(r"^(.+?)\s+@phase\s*$")
@@ -281,6 +282,7 @@ class MarkdownFile:
281
282
  self.base_dir = base_dir
282
283
  self.today = today
283
284
  self.warnings = []
285
+ self.includes = []
284
286
  self.notnext = False
285
287
  self.queue = False
286
288
  self.total_phases = 0
@@ -312,12 +314,13 @@ class MarkdownFile:
312
314
  imminent = due - urgency
313
315
  return (due, imminent, cleaned)
314
316
 
315
- def resolve_after_path(self, dep):
317
+ def resolve_relative_path(self, dep, base=None):
318
+ if base is None:
319
+ base = self.path
316
320
  dep = os.path.expanduser(dep)
317
321
  if os.path.isabs(dep):
318
322
  return dep
319
- file_dir = os.path.dirname(self.path)
320
- return os.path.normpath(os.path.join(file_dir, dep))
323
+ return os.path.normpath(os.path.join(os.path.dirname(base), dep))
321
324
 
322
325
  def parse_after(self, text):
323
326
  match = MarkdownFile.AFTER_PATTERN.match(text)
@@ -326,7 +329,7 @@ class MarkdownFile:
326
329
  cleaned = match.group(1).strip()
327
330
  files_str = match.group(2)
328
331
  if files_str:
329
- resolved = [self.resolve_after_path(dep) for dep in files_str.split()]
332
+ resolved = [self.resolve_relative_path(dep) for dep in files_str.split()]
330
333
  return (resolved, cleaned)
331
334
  return ([], cleaned)
332
335
 
@@ -377,11 +380,39 @@ class MarkdownFile:
377
380
  and not line.strip()[len(delimiter):]
378
381
  )
379
382
 
380
- def read_lines(self):
381
- if self._lines is not None:
382
- return self._lines
383
- with open(self.path) as handle:
384
- return [line.rstrip("\n") for line in handle]
383
+ def read_lines(self, path=None):
384
+ if path is None:
385
+ path = self.path
386
+ if self._lines is not None:
387
+ return self.expand_includes(self._lines, path)
388
+ with open(path) as handle:
389
+ raw = [line.rstrip("\n") for line in handle]
390
+ return self.expand_includes(raw, path)
391
+
392
+ def expand_includes(self, lines, base):
393
+ expanded = []
394
+ root_abs = os.path.abspath(self.path)
395
+ for line in lines:
396
+ match = self.INCLUDE_PATTERN.match(line)
397
+ if match is None:
398
+ expanded.append(line)
399
+ continue
400
+ target = match.group(1)
401
+ included_path = self.resolve_relative_path(target, base)
402
+ if not os.path.isfile(included_path):
403
+ self.warnings.append(
404
+ f"WARNING: {self.display_path}: '{target}' does not exist"
405
+ )
406
+ continue
407
+ included_abs = os.path.abspath(included_path)
408
+ # a file already in the chain (or the root itself) would loop
409
+ if included_abs in self.includes:
410
+ continue
411
+ if included_abs == root_abs:
412
+ continue
413
+ self.includes.append(included_abs)
414
+ expanded.extend(self.read_lines(included_path))
415
+ return expanded
385
416
 
386
417
  def relevant_content(self):
387
418
  lines = []
@@ -446,7 +477,7 @@ class MarkdownFile:
446
477
  files_str = match.group(1)
447
478
  if files_str:
448
479
  file_deferred = [
449
- self.resolve_after_path(dep) for dep in files_str.split()
480
+ self.resolve_relative_path(dep) for dep in files_str.split()
450
481
  ]
451
482
  else:
452
483
  file_deferred = []
@@ -415,6 +415,13 @@ def find_markdown_files(paths, today, ignore_patterns, quiet):
415
415
  if file.tasks:
416
416
  task_files[abs_path] = file
417
417
 
418
+ # a file pulled in via @include is part of its includer, not a source
419
+ included = set()
420
+ for file in task_files.values():
421
+ included.update(file.includes)
422
+ for abs_path in included:
423
+ task_files.pop(abs_path, None)
424
+
418
425
  # files are examined depth-last as a lightweight prioritisation
419
426
  return sorted(
420
427
  task_files.values(),
@@ -610,9 +617,8 @@ def main():
610
617
  )
611
618
  parser.add_argument(
612
619
  "--mute",
613
- nargs=2,
614
- metavar=("TIME", "MATCH"),
615
- help="Mute tasks matching pattern for period (e.g. 1d, 2w, 1m)",
620
+ metavar="TIME",
621
+ help="Mute matching tasks for period (e.g. --mute 1d foo bar)",
616
622
  )
617
623
  parser.add_argument(
618
624
  "--config",
@@ -688,19 +694,20 @@ def main():
688
694
  config_path = resolve_config_path(args.config, args.dir)
689
695
 
690
696
  if args.mute:
691
- period_str, pattern = args.mute
692
- if not pattern:
697
+ patterns = [p for p in args.match if p and not re.match(r'^\d+r?$', p)]
698
+ if not patterns:
693
699
  print("ERROR: pattern cannot be empty", file=sys.stderr)
694
700
  sys.exit(1)
695
701
  try:
696
- period = parse_period(period_str)
702
+ period = parse_period(args.mute)
697
703
  except ValueError as e:
698
704
  print(f"ERROR: {e}", file=sys.stderr)
699
705
  sys.exit(1)
700
706
  until = datetime.now() + period
701
707
  config = load_config(config_path, extensions=["mute"])
702
708
  mutes = config.get("mute", [])
703
- mutes.append({"until": until, "pattern": pattern})
709
+ for pattern in patterns:
710
+ mutes.append({"until": until, "pattern": pattern})
704
711
  write_mute_config(config_path, mutes)
705
712
  return
706
713
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes