markdown-include-variants 0.0.5__tar.gz → 0.0.7__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 (74) hide show
  1. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/.github/workflows/issue-manager.yml +1 -1
  2. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/.github/workflows/labeler.yml +1 -1
  3. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/.github/workflows/latest-changes.yml +2 -2
  4. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/.github/workflows/publish.yml +3 -3
  5. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/.github/workflows/smokeshow.yml +4 -8
  6. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/.github/workflows/test.yml +12 -24
  7. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/PKG-INFO +1 -1
  8. markdown_include_variants-0.0.7/docs_src/all_variants_folder/app_an_py311/tutorial001.py +10 -0
  9. markdown_include_variants-0.0.7/docs_src/only_py310/tutorial001_an_py310.py +10 -0
  10. markdown_include_variants-0.0.7/docs_src/only_py_no_an/tutorial001_py310.py +10 -0
  11. markdown_include_variants-0.0.7/docs_src/only_py_no_an/tutorial001_py311.py +10 -0
  12. markdown_include_variants-0.0.7/docs_src/up_to_py39/tutorial001.py +10 -0
  13. markdown_include_variants-0.0.7/docs_src/up_to_py39/tutorial001_an.py +10 -0
  14. markdown_include_variants-0.0.7/docs_src/up_to_py39/tutorial001_an_py39.py +10 -0
  15. markdown_include_variants-0.0.7/docs_src/up_to_py39/tutorial001_py39.py +10 -0
  16. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/pyproject.toml +5 -5
  17. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/release-notes.md +32 -0
  18. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/src/markdown_include_variants/_main.py +89 -19
  19. markdown_include_variants-0.0.7/src/markdown_include_variants/_version.py +1 -0
  20. markdown_include_variants-0.0.7/tests/test_all_variants.py +521 -0
  21. markdown_include_variants-0.0.5/tests/test_all_variants.py → markdown_include_variants-0.0.7/tests/test_all_variants_folder.py +20 -20
  22. markdown_include_variants-0.0.7/tests/test_simple_title.py +59 -0
  23. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/uv.lock +251 -251
  24. markdown_include_variants-0.0.5/src/markdown_include_variants/_version.py +0 -1
  25. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/.github/DISCUSSION_TEMPLATE/questions.yml +0 -0
  26. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/.github/FUNDING.yml +0 -0
  27. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  28. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/.github/ISSUE_TEMPLATE/privileged.yml +0 -0
  29. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/.github/dependabot.yml +0 -0
  30. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/.github/labeler.yml +0 -0
  31. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/.gitignore +0 -0
  32. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/.pre-commit-config.yaml +0 -0
  33. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/.python-version +0 -0
  34. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/CITATION.cff +0 -0
  35. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/LICENSE +0 -0
  36. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/README.md +0 -0
  37. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/docs_src/all_variants/tutorial001.py +0 -0
  38. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/docs_src/all_variants/tutorial001_an.py +0 -0
  39. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/docs_src/all_variants/tutorial001_an_py310.py +0 -0
  40. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/docs_src/all_variants/tutorial001_an_py311.py +0 -0
  41. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/docs_src/all_variants/tutorial001_an_py39.py +0 -0
  42. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/docs_src/all_variants/tutorial001_py310.py +0 -0
  43. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/docs_src/all_variants/tutorial001_py311.py +0 -0
  44. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/docs_src/all_variants/tutorial001_py39.py +0 -0
  45. {markdown_include_variants-0.0.5/docs_src/no_py39 → markdown_include_variants-0.0.7/docs_src/all_variants_folder/app}/tutorial001.py +0 -0
  46. /markdown_include_variants-0.0.5/docs_src/no_py39/tutorial001_an.py → /markdown_include_variants-0.0.7/docs_src/all_variants_folder/app_an/tutorial001.py +0 -0
  47. /markdown_include_variants-0.0.5/docs_src/no_py39/tutorial001_an_py310.py → /markdown_include_variants-0.0.7/docs_src/all_variants_folder/app_an_py310/tutorial001.py +0 -0
  48. /markdown_include_variants-0.0.5/docs_src/up_to_py39/tutorial001_an_py39.py → /markdown_include_variants-0.0.7/docs_src/all_variants_folder/app_an_py39/tutorial001.py +0 -0
  49. /markdown_include_variants-0.0.5/docs_src/no_py39/tutorial001_py310.py → /markdown_include_variants-0.0.7/docs_src/all_variants_folder/app_py310/tutorial001.py +0 -0
  50. /markdown_include_variants-0.0.5/docs_src/only_py_no_an/tutorial001_py311.py → /markdown_include_variants-0.0.7/docs_src/all_variants_folder/app_py311/tutorial001.py +0 -0
  51. /markdown_include_variants-0.0.5/docs_src/only_py_no_an/tutorial001_py39.py → /markdown_include_variants-0.0.7/docs_src/all_variants_folder/app_py39/tutorial001.py +0 -0
  52. {markdown_include_variants-0.0.5/docs_src/only_py_no_an → markdown_include_variants-0.0.7/docs_src/no_py39}/tutorial001.py +0 -0
  53. {markdown_include_variants-0.0.5/docs_src/up_to_py39 → markdown_include_variants-0.0.7/docs_src/no_py39}/tutorial001_an.py +0 -0
  54. {markdown_include_variants-0.0.5/docs_src/only_py310 → markdown_include_variants-0.0.7/docs_src/no_py39}/tutorial001_an_py310.py +0 -0
  55. {markdown_include_variants-0.0.5/docs_src/only_py310 → markdown_include_variants-0.0.7/docs_src/no_py39}/tutorial001_py310.py +0 -0
  56. {markdown_include_variants-0.0.5/docs_src/only_py_no_an → markdown_include_variants-0.0.7/docs_src/only_py310}/tutorial001_py310.py +0 -0
  57. {markdown_include_variants-0.0.5/docs_src/simple → markdown_include_variants-0.0.7/docs_src/only_py_no_an}/tutorial001.py +0 -0
  58. {markdown_include_variants-0.0.5/docs_src/up_to_py39 → markdown_include_variants-0.0.7/docs_src/only_py_no_an}/tutorial001_py39.py +0 -0
  59. {markdown_include_variants-0.0.5/docs_src/up_to_py39 → markdown_include_variants-0.0.7/docs_src/simple}/tutorial001.py +0 -0
  60. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/scripts/format.sh +0 -0
  61. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/scripts/lint.sh +0 -0
  62. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/scripts/test.sh +0 -0
  63. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/src/markdown_include_variants/__init__.py +0 -0
  64. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/src/markdown_include_variants/py.typed +0 -0
  65. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/tests/test_another_preferred_variant.py +0 -0
  66. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/tests/test_no_py39.py +0 -0
  67. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/tests/test_only_preview.py +0 -0
  68. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/tests/test_only_py310.py +0 -0
  69. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/tests/test_only_py_no_an.py +0 -0
  70. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/tests/test_simple_hl.py +0 -0
  71. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/tests/test_simple_ln.py +0 -0
  72. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/tests/test_simple_ln_hl.py +0 -0
  73. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/tests/test_simple_no_configs.py +0 -0
  74. {markdown_include_variants-0.0.5 → markdown_include_variants-0.0.7}/tests/test_up_to_py39.py +0 -0
@@ -27,7 +27,7 @@ jobs:
27
27
  env:
28
28
  GITHUB_CONTEXT: ${{ toJson(github) }}
29
29
  run: echo "$GITHUB_CONTEXT"
30
- - uses: tiangolo/issue-manager@0.5.1
30
+ - uses: tiangolo/issue-manager@0.6.0
31
31
  with:
32
32
  token: ${{ secrets.GITHUB_TOKEN }}
33
33
  config: >
@@ -16,7 +16,7 @@ jobs:
16
16
  pull-requests: write
17
17
  runs-on: ubuntu-latest
18
18
  steps:
19
- - uses: actions/labeler@v5
19
+ - uses: actions/labeler@v6
20
20
  if: ${{ github.event.action != 'labeled' && github.event.action != 'unlabeled' }}
21
21
  - run: echo "Done adding labels"
22
22
  # Run this after labeler applied labels
@@ -20,7 +20,7 @@ jobs:
20
20
  latest-changes:
21
21
  runs-on: ubuntu-latest
22
22
  steps:
23
- - uses: actions/checkout@v4
23
+ - uses: actions/checkout@v6
24
24
  with:
25
25
  # To allow latest-changes to commit to the main branch
26
26
  token: ${{ secrets.LATEST_CHANGES }}
@@ -30,7 +30,7 @@ jobs:
30
30
  if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }}
31
31
  with:
32
32
  limit-access-to-actor: true
33
- - uses: tiangolo/latest-changes@0.3.2
33
+ - uses: tiangolo/latest-changes@0.4.1
34
34
  with:
35
35
  token: ${{ secrets.GITHUB_TOKEN }}
36
36
  latest_changes_file: release-notes.md
@@ -17,9 +17,9 @@ jobs:
17
17
  permissions:
18
18
  id-token: write
19
19
  steps:
20
- - uses: actions/checkout@v4
20
+ - uses: actions/checkout@v6
21
21
  - name: Set up Python
22
- uses: actions/setup-python@v5
22
+ uses: actions/setup-python@v6
23
23
  with:
24
24
  python-version: "3.11"
25
25
  - name: Install build dependencies
@@ -27,4 +27,4 @@ jobs:
27
27
  - name: Build distribution
28
28
  run: python -m build
29
29
  - name: Publish
30
- uses: pypa/gh-action-pypi-publish@v1.12.4
30
+ uses: pypa/gh-action-pypi-publish@v1.13.0
@@ -23,18 +23,14 @@ jobs:
23
23
  env:
24
24
  GITHUB_CONTEXT: ${{ toJson(github) }}
25
25
  run: echo "$GITHUB_CONTEXT"
26
- - uses: actions/checkout@v4
27
- - uses: actions/setup-python@v5
26
+ - uses: actions/checkout@v6
27
+ - uses: actions/setup-python@v6
28
28
  with:
29
29
  python-version: '3.9'
30
- - name: Setup uv
31
- uses: astral-sh/setup-uv@v6
32
- with:
33
- version: "0.4.15"
34
- enable-cache: true
30
+ - uses: astral-sh/setup-uv@v7
35
31
  - name: Install Dependencies
36
32
  run: uv sync
37
- - uses: actions/download-artifact@v4
33
+ - uses: actions/download-artifact@v6
38
34
  with:
39
35
  name: coverage-html
40
36
  path: htmlcov
@@ -20,16 +20,12 @@ jobs:
20
20
  env:
21
21
  GITHUB_CONTEXT: ${{ toJson(github) }}
22
22
  run: echo "$GITHUB_CONTEXT"
23
- - uses: actions/checkout@v4
23
+ - uses: actions/checkout@v6
24
24
  - name: Set up Python
25
- uses: actions/setup-python@v5
25
+ uses: actions/setup-python@v6
26
26
  with:
27
27
  python-version: "3.11"
28
- - name: Setup uv
29
- uses: astral-sh/setup-uv@v6
30
- with:
31
- version: "0.4.15"
32
- enable-cache: true
28
+ - uses: astral-sh/setup-uv@v7
33
29
  - name: Install Dependencies
34
30
  run: uv sync
35
31
  - name: Lint
@@ -47,16 +43,12 @@ jobs:
47
43
  env:
48
44
  GITHUB_CONTEXT: ${{ toJson(github) }}
49
45
  run: echo "$GITHUB_CONTEXT"
50
- - uses: actions/checkout@v4
46
+ - uses: actions/checkout@v6
51
47
  - name: Set up Python
52
- uses: actions/setup-python@v5
48
+ uses: actions/setup-python@v6
53
49
  with:
54
50
  python-version: ${{ matrix.python-version }}
55
- - name: Setup uv
56
- uses: astral-sh/setup-uv@v6
57
- with:
58
- version: "0.4.15"
59
- enable-cache: true
51
+ - uses: astral-sh/setup-uv@v7
60
52
  - name: Install Dependencies
61
53
  run: uv sync
62
54
  - run: mkdir coverage
@@ -66,7 +58,7 @@ jobs:
66
58
  COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
67
59
  CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
68
60
  - name: Store coverage files
69
- uses: actions/upload-artifact@v4
61
+ uses: actions/upload-artifact@v5
70
62
  with:
71
63
  name: coverage-${{ matrix.python-version }}
72
64
  path: coverage
@@ -81,17 +73,13 @@ jobs:
81
73
  env:
82
74
  GITHUB_CONTEXT: ${{ toJson(github) }}
83
75
  run: echo "$GITHUB_CONTEXT"
84
- - uses: actions/checkout@v4
85
- - uses: actions/setup-python@v5
76
+ - uses: actions/checkout@v6
77
+ - uses: actions/setup-python@v6
86
78
  with:
87
79
  python-version: '3.11'
88
- - name: Setup uv
89
- uses: astral-sh/setup-uv@v6
90
- with:
91
- version: "0.4.15"
92
- enable-cache: true
80
+ - uses: astral-sh/setup-uv@v7
93
81
  - name: Get coverage files
94
- uses: actions/download-artifact@v4
82
+ uses: actions/download-artifact@v6
95
83
  with:
96
84
  pattern: coverage-*
97
85
  path: coverage
@@ -102,7 +90,7 @@ jobs:
102
90
  - run: uv run coverage report
103
91
  - run: uv run coverage html --title "Coverage for ${{ github.sha }}"
104
92
  - name: Store coverage HTML
105
- uses: actions/upload-artifact@v4
93
+ uses: actions/upload-artifact@v5
106
94
  with:
107
95
  name: coverage-html
108
96
  path: htmlcov
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: markdown-include-variants
3
- Version: 0.0.5
3
+ Version: 0.0.7
4
4
  Summary: Markdown extension to expand directives to include source example files to also include their variants. Only useful to tiangolo's projets. Don't use it. 😅
5
5
  Project-URL: Homepage, https://github.com/tiangolo/markdown-include-variants
6
6
  Project-URL: Repository, https://github.com/tiangolo/markdown-include-variants
@@ -0,0 +1,10 @@
1
+ print("an py311 line 1")
2
+ print("an py311 line 2")
3
+ print("an py311 line 3")
4
+ print("an py311 line 4")
5
+ print("an py311 line 5")
6
+ print("an py311 line 6")
7
+ print("an py311 line 7")
8
+ print("an py311 line 8")
9
+ print("an py311 line 9")
10
+ print("an py311 line 10")
@@ -0,0 +1,10 @@
1
+ print("an py310 line 1")
2
+ print("an py310 line 2")
3
+ print("an py310 line 3")
4
+ print("an py310 line 4")
5
+ print("an py310 line 5")
6
+ print("an py310 line 6")
7
+ print("an py310 line 7")
8
+ print("an py310 line 8")
9
+ print("an py310 line 9")
10
+ print("an py310 line 10")
@@ -0,0 +1,10 @@
1
+ print("py310 line 1")
2
+ print("py310 line 2")
3
+ print("py310 line 3")
4
+ print("py310 line 4")
5
+ print("py310 line 5")
6
+ print("py310 line 6")
7
+ print("py310 line 7")
8
+ print("py310 line 8")
9
+ print("py310 line 9")
10
+ print("py310 line 10")
@@ -0,0 +1,10 @@
1
+ print("py311 line 1")
2
+ print("py311 line 2")
3
+ print("py311 line 3")
4
+ print("py311 line 4")
5
+ print("py311 line 5")
6
+ print("py311 line 6")
7
+ print("py311 line 7")
8
+ print("py311 line 8")
9
+ print("py311 line 9")
10
+ print("py311 line 10")
@@ -0,0 +1,10 @@
1
+ print("simple line 1")
2
+ print("simple line 2")
3
+ print("simple line 3")
4
+ print("simple line 4")
5
+ print("simple line 5")
6
+ print("simple line 6")
7
+ print("simple line 7")
8
+ print("simple line 8")
9
+ print("simple line 9")
10
+ print("simple line 10")
@@ -0,0 +1,10 @@
1
+ print("an line 1")
2
+ print("an line 2")
3
+ print("an line 3")
4
+ print("an line 4")
5
+ print("an line 5")
6
+ print("an line 6")
7
+ print("an line 7")
8
+ print("an line 8")
9
+ print("an line 9")
10
+ print("an line 10")
@@ -0,0 +1,10 @@
1
+ print("an py39 line 1")
2
+ print("an py39 line 2")
3
+ print("an py39 line 3")
4
+ print("an py39 line 4")
5
+ print("an py39 line 5")
6
+ print("an py39 line 6")
7
+ print("an py39 line 7")
8
+ print("an py39 line 8")
9
+ print("an py39 line 9")
10
+ print("an py39 line 10")
@@ -0,0 +1,10 @@
1
+ print("py39 line 1")
2
+ print("py39 line 2")
3
+ print("py39 line 3")
4
+ print("py39 line 4")
5
+ print("py39 line 5")
6
+ print("py39 line 6")
7
+ print("py39 line 7")
8
+ print("py39 line 8")
9
+ print("py39 line 9")
10
+ print("py39 line 10")
@@ -25,11 +25,8 @@ Repository = "https://github.com/tiangolo/markdown-include-variants"
25
25
  Issues = "https://github.com/tiangolo/markdown-include-variants/issues"
26
26
  Changelog = "https://github.com/tiangolo/markdown-include-variants/release-notes.md"
27
27
 
28
- [tool.hatch.version]
29
- path = "src/markdown_include_variants/_version.py"
30
-
31
- [tool.uv]
32
- dev-dependencies = [
28
+ [dependency-groups]
29
+ dev = [
33
30
  "coverage[toml]>=7.6.1",
34
31
  "inline-snapshot>=0.13.3",
35
32
  "mdx-include>=1.4.2",
@@ -41,6 +38,9 @@ dev-dependencies = [
41
38
  "types-markdown>=3.7.0.20240822",
42
39
  ]
43
40
 
41
+ [tool.hatch.version]
42
+ path = "src/markdown_include_variants/_version.py"
43
+
44
44
  [tool.coverage.run]
45
45
  parallel = true
46
46
  data_file = "coverage/.coverage"
@@ -2,6 +2,38 @@
2
2
 
3
3
  ## Latest Changes
4
4
 
5
+ ## 0.0.7
6
+
7
+ ### Features
8
+
9
+ * ✨ Support `title` option. PR [#39](https://github.com/tiangolo/markdown-include-variants/pull/39) by [@YuriiMotov](https://github.com/YuriiMotov).
10
+
11
+ ### Upgrades
12
+
13
+ * ⬆️ Upgrade uv config in pyproject.toml. PR [#40](https://github.com/tiangolo/markdown-include-variants/pull/40) by [@tiangolo](https://github.com/tiangolo).
14
+
15
+ ## 0.0.6
16
+
17
+ ### Features
18
+
19
+ * ✨ Search for variants by folder name if no variants by file name found. PR [#38](https://github.com/tiangolo/markdown-include-variants/pull/38) by [@YuriiMotov](https://github.com/YuriiMotov).
20
+
21
+ ### Internal
22
+
23
+ * ⬆ Bump actions/checkout from 5 to 6. PR [#37](https://github.com/tiangolo/markdown-include-variants/pull/37) by [@dependabot[bot]](https://github.com/apps/dependabot).
24
+ * ⬆ Bump actions/checkout from 5 to 6. PR [#34](https://github.com/tiangolo/markdown-include-variants/pull/34) by [@dependabot[bot]](https://github.com/apps/dependabot).
25
+ * 👷 Upgrade `latest-changes` GitHub Action and pin `actions/checkout@v5`. PR [#35](https://github.com/tiangolo/markdown-include-variants/pull/35) by [@tiangolo](https://github.com/tiangolo).
26
+ * ⬆ Bump actions/upload-artifact from 4 to 5. PR [#32](https://github.com/tiangolo/markdown-include-variants/pull/32) by [@dependabot[bot]](https://github.com/apps/dependabot).
27
+ * ⬆ Bump actions/download-artifact from 5 to 6. PR [#33](https://github.com/tiangolo/markdown-include-variants/pull/33) by [@dependabot[bot]](https://github.com/apps/dependabot).
28
+ * ⬆ Bump astral-sh/setup-uv from 6 to 7. PR [#31](https://github.com/tiangolo/markdown-include-variants/pull/31) by [@dependabot[bot]](https://github.com/apps/dependabot).
29
+ * ⬆ Bump tiangolo/issue-manager from 0.5.1 to 0.6.0. PR [#30](https://github.com/tiangolo/markdown-include-variants/pull/30) by [@dependabot[bot]](https://github.com/apps/dependabot).
30
+ * ⬆ Bump actions/labeler from 5 to 6. PR [#29](https://github.com/tiangolo/markdown-include-variants/pull/29) by [@dependabot[bot]](https://github.com/apps/dependabot).
31
+ * ⬆ Bump actions/setup-python from 5 to 6. PR [#27](https://github.com/tiangolo/markdown-include-variants/pull/27) by [@dependabot[bot]](https://github.com/apps/dependabot).
32
+ * ⬆ Bump pypa/gh-action-pypi-publish from 1.12.4 to 1.13.0. PR [#26](https://github.com/tiangolo/markdown-include-variants/pull/26) by [@dependabot[bot]](https://github.com/apps/dependabot).
33
+ * ⬆ Bump actions/checkout from 4 to 5. PR [#25](https://github.com/tiangolo/markdown-include-variants/pull/25) by [@dependabot[bot]](https://github.com/apps/dependabot).
34
+ * ⬆ Bump actions/download-artifact from 4 to 5. PR [#24](https://github.com/tiangolo/markdown-include-variants/pull/24) by [@dependabot[bot]](https://github.com/apps/dependabot).
35
+ * ⬆ Bump tiangolo/latest-changes from 0.3.2 to 0.4.0. PR [#23](https://github.com/tiangolo/markdown-include-variants/pull/23) by [@dependabot[bot]](https://github.com/apps/dependabot).
36
+
5
37
  ## 0.0.5
6
38
 
7
39
  ### Features
@@ -6,6 +6,13 @@ from typing import Any, Literal, Union
6
6
  from markdown import Extension, Markdown
7
7
  from markdown.preprocessors import Preprocessor
8
8
 
9
+ AN = "_an"
10
+ PY39 = "_py39"
11
+ PY310 = "_py310"
12
+ PY311 = "_py311"
13
+
14
+ SUFFIXES_TO_REMOVE = ["_an", "_py39", "_py310", "_py311"]
15
+
9
16
 
10
17
  @dataclass(frozen=True)
11
18
  class Variant:
@@ -25,21 +32,70 @@ def remove_suffixes(base_name: str, suffixes: list[str]) -> str:
25
32
 
26
33
  def calculate_variants(base_path: Path) -> dict[tuple[str, Union[bool, None]], Variant]:
27
34
  preferred_name = base_path.stem
28
- base_name = remove_suffixes(preferred_name, ["_an", "_py39", "_py310", "_py311"])
35
+ base_name = remove_suffixes(preferred_name, SUFFIXES_TO_REMOVE)
29
36
  base_dir = base_path.parent
30
- variants: dict[tuple[str, Union[bool, None]], Variant] = {}
31
- an = "_an"
32
- py39 = "_py39"
33
- py310 = "_py310"
34
- py311 = "_py311"
35
- an_p311_path = base_dir / f"{base_name}{an}{py311}.py"
36
- an_p310_path = base_dir / f"{base_name}{an}{py310}.py"
37
- an_p39_path = base_dir / f"{base_name}{an}{py39}.py"
38
- an_p38_path = base_dir / f"{base_name}{an}.py"
39
- p311_path = base_dir / f"{base_name}{py311}.py"
40
- p310_path = base_dir / f"{base_name}{py310}.py"
41
- p39_path = base_dir / f"{base_name}{py39}.py"
37
+
38
+ an_p311_path = base_dir / f"{base_name}{AN}{PY311}.py"
39
+ an_p310_path = base_dir / f"{base_name}{AN}{PY310}.py"
40
+ an_p39_path = base_dir / f"{base_name}{AN}{PY39}.py"
41
+ an_p38_path = base_dir / f"{base_name}{AN}.py"
42
+ p311_path = base_dir / f"{base_name}{PY311}.py"
43
+ p310_path = base_dir / f"{base_name}{PY310}.py"
44
+ p39_path = base_dir / f"{base_name}{PY39}.py"
42
45
  p38_path = base_dir / f"{base_name}.py"
46
+
47
+ return _create_variants(
48
+ an_p311_path=an_p311_path,
49
+ an_p310_path=an_p310_path,
50
+ an_p39_path=an_p39_path,
51
+ an_p38_path=an_p38_path,
52
+ p311_path=p311_path,
53
+ p310_path=p310_path,
54
+ p39_path=p39_path,
55
+ p38_path=p38_path,
56
+ )
57
+
58
+
59
+ def calculate_variants_folder(
60
+ base_path: Path,
61
+ ) -> dict[tuple[str, Union[bool, None]], Variant]:
62
+ file_name = base_path.name
63
+ folder = base_path.parent
64
+ base_dir = folder.parent
65
+ base_name = remove_suffixes(folder.name, SUFFIXES_TO_REMOVE)
66
+
67
+ an_p311_path = base_dir / f"{base_name}{AN}{PY311}" / file_name
68
+ an_p310_path = base_dir / f"{base_name}{AN}{PY310}" / file_name
69
+ an_p39_path = base_dir / f"{base_name}{AN}{PY39}" / file_name
70
+ an_p38_path = base_dir / f"{base_name}{AN}" / file_name
71
+ p311_path = base_dir / f"{base_name}{PY311}" / file_name
72
+ p310_path = base_dir / f"{base_name}{PY310}" / file_name
73
+ p39_path = base_dir / f"{base_name}{PY39}" / file_name
74
+ p38_path = base_dir / f"{base_name}" / file_name
75
+
76
+ return _create_variants(
77
+ an_p311_path=an_p311_path,
78
+ an_p310_path=an_p310_path,
79
+ an_p39_path=an_p39_path,
80
+ an_p38_path=an_p38_path,
81
+ p311_path=p311_path,
82
+ p310_path=p310_path,
83
+ p39_path=p39_path,
84
+ p38_path=p38_path,
85
+ )
86
+
87
+
88
+ def _create_variants(
89
+ an_p311_path: Path,
90
+ an_p310_path: Path,
91
+ an_p39_path: Path,
92
+ an_p38_path: Path,
93
+ p311_path: Path,
94
+ p310_path: Path,
95
+ p39_path: Path,
96
+ p38_path: Path,
97
+ ) -> dict[tuple[str, Union[bool, None]], Variant]:
98
+ variants: dict[tuple[str, Union[bool, None]], Variant] = {}
43
99
  if an_p311_path.exists():
44
100
  v = Variant(
45
101
  path=an_p311_path,
@@ -223,15 +279,18 @@ class IncludeVariantsPreprocessor(Preprocessor):
223
279
  configs_str = line_match.group(2).strip()
224
280
  include_lines: list[tuple[int, int]] = []
225
281
  highlight_lines: list[tuple[int, int]] = []
282
+ title: Union[str, None] = None
226
283
  for config_match in re.finditer(re_config, configs_str):
227
284
  if config_match:
228
285
  name = config_match.group(1)
229
- ranges_str = config_match.group(2)
230
- ranges = parse_lines_index(ranges_str)
286
+ value_str = config_match.group(2)
231
287
  if name == "ln":
232
- include_lines.extend(ranges)
288
+ include_lines.extend(parse_lines_index(value_str))
233
289
  elif name == "hl":
234
- highlight_lines.extend(ranges)
290
+ highlight_lines.extend(parse_lines_index(value_str))
291
+ elif name == "title":
292
+ assert value_str.startswith('"') and value_str.endswith('"')
293
+ title = value_str[1:-1]
235
294
  use_hl_lines: list[tuple[int, int]] = []
236
295
  if highlight_lines:
237
296
  if include_lines:
@@ -245,6 +304,10 @@ class IncludeVariantsPreprocessor(Preprocessor):
245
304
  variants = calculate_variants(base_path)
246
305
  if len(variants) == 0:
247
306
  raise FileNotFoundError(f"Could not find any variants for {base_path}")
307
+ if len(variants) == 1:
308
+ folder_variants = calculate_variants_folder(base_path)
309
+ if len(folder_variants) > 1:
310
+ variants = folder_variants
248
311
  sorted_variants: list[Variant] = []
249
312
  preferred_variant = None
250
313
  for an in [True, False, None]:
@@ -296,10 +359,12 @@ class IncludeVariantsPreprocessor(Preprocessor):
296
359
  first_line = "```python"
297
360
  if use_hl_lines:
298
361
  first_line += f' hl_lines="{use_hl_lines_str}"'
362
+ if title:
363
+ first_line += f' title="{title}"'
299
364
 
300
365
  block_lines.extend(
301
366
  [
302
- f"//// tab | {preferred_variant.title}" "",
367
+ f"//// tab | {preferred_variant.title}",
303
368
  first_line,
304
369
  *internal_block_lines,
305
370
  "```",
@@ -313,6 +378,8 @@ class IncludeVariantsPreprocessor(Preprocessor):
313
378
  if highlight_lines:
314
379
  hl_lines_full_str = generate_hl_string(highlight_lines)
315
380
  first_line_full += f' hl_lines="{hl_lines_full_str}"'
381
+ if title:
382
+ first_line_full += f' title="{title}"'
316
383
  block_lines.extend(
317
384
  [
318
385
  "///// details | 👀 Full file preview",
@@ -330,6 +397,9 @@ class IncludeVariantsPreprocessor(Preprocessor):
330
397
  ]
331
398
  )
332
399
  if len(sorted_variants):
400
+ first_line_variant = "```python"
401
+ if title:
402
+ first_line_variant += f' title="{title}"'
333
403
  block_lines.extend(
334
404
  [
335
405
  "///// details | 🤓 Other versions and variants",
@@ -353,7 +423,7 @@ class IncludeVariantsPreprocessor(Preprocessor):
353
423
 
354
424
  block_lines.extend(
355
425
  [
356
- "```python",
426
+ first_line_variant,
357
427
  f"{{!{variant.path}!}}",
358
428
  "```",
359
429
  "////",
@@ -0,0 +1 @@
1
+ __version__ = "0.0.7"