markdown-include-variants 0.0.3__tar.gz → 0.0.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 (65) hide show
  1. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/.github/workflows/latest-changes.yml +1 -1
  2. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/.github/workflows/publish.yml +2 -2
  3. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/.github/workflows/smokeshow.yml +1 -1
  4. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/.github/workflows/test.yml +3 -3
  5. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/PKG-INFO +12 -2
  6. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/README.md +10 -0
  7. markdown_include_variants-0.0.5/docs_src/all_variants/tutorial001_an_py311.py +10 -0
  8. markdown_include_variants-0.0.5/docs_src/all_variants/tutorial001_py311.py +10 -0
  9. markdown_include_variants-0.0.5/docs_src/only_py_no_an/tutorial001_py311.py +10 -0
  10. markdown_include_variants-0.0.5/release-notes.md +54 -0
  11. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/src/markdown_include_variants/_main.py +77 -43
  12. markdown_include_variants-0.0.5/src/markdown_include_variants/_version.py +1 -0
  13. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/tests/test_all_variants.py +78 -23
  14. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/tests/test_another_preferred_variant.py +12 -1
  15. markdown_include_variants-0.0.5/tests/test_only_preview.py +33 -0
  16. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/tests/test_only_py_no_an.py +8 -4
  17. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/tests/test_simple_ln.py +45 -15
  18. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/tests/test_simple_ln_hl.py +27 -9
  19. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/tests/test_up_to_py39.py +3 -1
  20. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/uv.lock +1 -1
  21. markdown_include_variants-0.0.3/release-notes.md +0 -28
  22. markdown_include_variants-0.0.3/src/markdown_include_variants/_version.py +0 -1
  23. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/.github/DISCUSSION_TEMPLATE/questions.yml +0 -0
  24. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/.github/FUNDING.yml +0 -0
  25. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  26. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/.github/ISSUE_TEMPLATE/privileged.yml +0 -0
  27. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/.github/dependabot.yml +0 -0
  28. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/.github/labeler.yml +0 -0
  29. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/.github/workflows/issue-manager.yml +0 -0
  30. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/.github/workflows/labeler.yml +0 -0
  31. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/.gitignore +0 -0
  32. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/.pre-commit-config.yaml +0 -0
  33. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/.python-version +0 -0
  34. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/CITATION.cff +0 -0
  35. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/LICENSE +0 -0
  36. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/docs_src/all_variants/tutorial001.py +0 -0
  37. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/docs_src/all_variants/tutorial001_an.py +0 -0
  38. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/docs_src/all_variants/tutorial001_an_py310.py +0 -0
  39. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/docs_src/all_variants/tutorial001_an_py39.py +0 -0
  40. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/docs_src/all_variants/tutorial001_py310.py +0 -0
  41. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/docs_src/all_variants/tutorial001_py39.py +0 -0
  42. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/docs_src/no_py39/tutorial001.py +0 -0
  43. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/docs_src/no_py39/tutorial001_an.py +0 -0
  44. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/docs_src/no_py39/tutorial001_an_py310.py +0 -0
  45. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/docs_src/no_py39/tutorial001_py310.py +0 -0
  46. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/docs_src/only_py310/tutorial001_an_py310.py +0 -0
  47. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/docs_src/only_py310/tutorial001_py310.py +0 -0
  48. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/docs_src/only_py_no_an/tutorial001.py +0 -0
  49. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/docs_src/only_py_no_an/tutorial001_py310.py +0 -0
  50. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/docs_src/only_py_no_an/tutorial001_py39.py +0 -0
  51. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/docs_src/simple/tutorial001.py +0 -0
  52. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/docs_src/up_to_py39/tutorial001.py +0 -0
  53. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/docs_src/up_to_py39/tutorial001_an.py +0 -0
  54. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/docs_src/up_to_py39/tutorial001_an_py39.py +0 -0
  55. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/docs_src/up_to_py39/tutorial001_py39.py +0 -0
  56. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/pyproject.toml +0 -0
  57. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/scripts/format.sh +0 -0
  58. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/scripts/lint.sh +0 -0
  59. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/scripts/test.sh +0 -0
  60. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/src/markdown_include_variants/__init__.py +0 -0
  61. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/src/markdown_include_variants/py.typed +0 -0
  62. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/tests/test_no_py39.py +0 -0
  63. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/tests/test_only_py310.py +0 -0
  64. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/tests/test_simple_hl.py +0 -0
  65. {markdown_include_variants-0.0.3 → markdown_include_variants-0.0.5}/tests/test_simple_no_configs.py +0 -0
@@ -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.1
33
+ - uses: tiangolo/latest-changes@0.3.2
34
34
  with:
35
35
  token: ${{ secrets.GITHUB_TOKEN }}
36
36
  latest_changes_file: release-notes.md
@@ -3,7 +3,7 @@ name: Publish
3
3
  on:
4
4
  release:
5
5
  types:
6
- - created
6
+ - released
7
7
  workflow_dispatch:
8
8
  inputs:
9
9
  debug_enabled:
@@ -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.10.3
30
+ uses: pypa/gh-action-pypi-publish@v1.12.4
@@ -28,7 +28,7 @@ jobs:
28
28
  with:
29
29
  python-version: '3.9'
30
30
  - name: Setup uv
31
- uses: astral-sh/setup-uv@v3
31
+ uses: astral-sh/setup-uv@v6
32
32
  with:
33
33
  version: "0.4.15"
34
34
  enable-cache: true
@@ -26,7 +26,7 @@ jobs:
26
26
  with:
27
27
  python-version: "3.11"
28
28
  - name: Setup uv
29
- uses: astral-sh/setup-uv@v3
29
+ uses: astral-sh/setup-uv@v6
30
30
  with:
31
31
  version: "0.4.15"
32
32
  enable-cache: true
@@ -53,7 +53,7 @@ jobs:
53
53
  with:
54
54
  python-version: ${{ matrix.python-version }}
55
55
  - name: Setup uv
56
- uses: astral-sh/setup-uv@v3
56
+ uses: astral-sh/setup-uv@v6
57
57
  with:
58
58
  version: "0.4.15"
59
59
  enable-cache: true
@@ -86,7 +86,7 @@ jobs:
86
86
  with:
87
87
  python-version: '3.11'
88
88
  - name: Setup uv
89
- uses: astral-sh/setup-uv@v3
89
+ uses: astral-sh/setup-uv@v6
90
90
  with:
91
91
  version: "0.4.15"
92
92
  enable-cache: true
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: markdown-include-variants
3
- Version: 0.0.3
3
+ Version: 0.0.5
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
@@ -169,6 +169,16 @@ print("line 7")
169
169
 
170
170
  Notice that the comment above adds 2 extra lines, and only the desired lines are included, the result is that the actual highlighted line is the rendered line 4, but the source line 6, it's all calculated automatically. 🤓
171
171
 
172
+ ### Include Only File Preview
173
+
174
+ If you only want to generate the "File Preview" collapsed details section, without actually including a tab of source files, you can use `ln[0]`:
175
+
176
+ ```markdown
177
+ {* ./docs_src/first_steps/tutorial001_an_py310.py ln[0] *}
178
+ ```
179
+
180
+ This is useful for example at the beginning of a new page, in a recap of the last used file in the previous page.
181
+
172
182
  ## License
173
183
 
174
184
  This project is licensed under the terms of the [MIT license](https://github.com/tiangolo/markdown-include-variants/blob/main/LICENSE).
@@ -152,6 +152,16 @@ print("line 7")
152
152
 
153
153
  Notice that the comment above adds 2 extra lines, and only the desired lines are included, the result is that the actual highlighted line is the rendered line 4, but the source line 6, it's all calculated automatically. 🤓
154
154
 
155
+ ### Include Only File Preview
156
+
157
+ If you only want to generate the "File Preview" collapsed details section, without actually including a tab of source files, you can use `ln[0]`:
158
+
159
+ ```markdown
160
+ {* ./docs_src/first_steps/tutorial001_an_py310.py ln[0] *}
161
+ ```
162
+
163
+ This is useful for example at the beginning of a new page, in a recap of the last used file in the previous page.
164
+
155
165
  ## License
156
166
 
157
167
  This project is licensed under the terms of the [MIT license](https://github.com/tiangolo/markdown-include-variants/blob/main/LICENSE).
@@ -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("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("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,54 @@
1
+ # Release Notes
2
+
3
+ ## Latest Changes
4
+
5
+ ## 0.0.5
6
+
7
+ ### Features
8
+
9
+ * ✨ Support Python 3.11. PR [#28](https://github.com/tiangolo/markdown-include-variants/pull/28) by [@svlandeg](https://github.com/svlandeg).
10
+
11
+ ### Internal
12
+
13
+ * ⬆ Bump astral-sh/setup-uv from 5 to 6. PR [#22](https://github.com/tiangolo/markdown-include-variants/pull/22) by [@dependabot[bot]](https://github.com/apps/dependabot).
14
+ * ⬆ Bump pypa/gh-action-pypi-publish from 1.12.3 to 1.12.4. PR [#21](https://github.com/tiangolo/markdown-include-variants/pull/21) by [@dependabot[bot]](https://github.com/apps/dependabot).
15
+ * 👷 Publish on release released. PR [#20](https://github.com/tiangolo/markdown-include-variants/pull/20) by [@tiangolo](https://github.com/tiangolo).
16
+
17
+ ## 0.0.4
18
+
19
+ ### Features
20
+
21
+ * ✨ Include variant tab in full file preview. PR [#19](https://github.com/tiangolo/markdown-include-variants/pull/19) by [@tiangolo](https://github.com/tiangolo).
22
+ * ✨ Support including only a file preview. PR [#18](https://github.com/tiangolo/markdown-include-variants/pull/18) by [@tiangolo](https://github.com/tiangolo).
23
+
24
+ ### Internal
25
+
26
+ * ⬆ Bump astral-sh/setup-uv from 3 to 5. PR [#17](https://github.com/tiangolo/markdown-include-variants/pull/17) by [@dependabot[bot]](https://github.com/apps/dependabot).
27
+ * ⬆ Bump tiangolo/latest-changes from 0.3.1 to 0.3.2. PR [#14](https://github.com/tiangolo/markdown-include-variants/pull/14) by [@dependabot[bot]](https://github.com/apps/dependabot).
28
+ * ⬆ Bump pypa/gh-action-pypi-publish from 1.11.0 to 1.12.3. PR [#16](https://github.com/tiangolo/markdown-include-variants/pull/16) by [@dependabot[bot]](https://github.com/apps/dependabot).
29
+ * ⬆ Bump pypa/gh-action-pypi-publish from 1.10.3 to 1.11.0. PR [#11](https://github.com/tiangolo/markdown-include-variants/pull/11) by [@dependabot[bot]](https://github.com/apps/dependabot).
30
+
31
+ ## 0.0.3
32
+
33
+ ### Features
34
+
35
+ * ✨ Add highlight for full file preview. PR [#10](https://github.com/tiangolo/markdown-include-variants/pull/10) by [@tiangolo](https://github.com/tiangolo).
36
+
37
+ ## 0.0.2
38
+
39
+ ### Refactors
40
+
41
+ * ♻️ Make the preferred variant the one used in the include. PR [#9](https://github.com/tiangolo/markdown-include-variants/pull/9) by [@tiangolo](https://github.com/tiangolo).
42
+
43
+ ### Docs
44
+
45
+ * 📝 Fix MkDocs config example. PR [#8](https://github.com/tiangolo/markdown-include-variants/pull/8) by [@tiangolo](https://github.com/tiangolo).
46
+ * 📝 Update README with mkdocs.yml configs. PR [#6](https://github.com/tiangolo/markdown-include-variants/pull/6) by [@tiangolo](https://github.com/tiangolo).
47
+
48
+ ### Internal
49
+
50
+ * ⬆ Bump pypa/gh-action-pypi-publish from 1.9.0 to 1.10.3. PR [#1](https://github.com/tiangolo/markdown-include-variants/pull/1) by [@dependabot[bot]](https://github.com/apps/dependabot).
51
+ * 👷 Tweak labeler GitHub Action. PR [#7](https://github.com/tiangolo/markdown-include-variants/pull/7) by [@tiangolo](https://github.com/tiangolo).
52
+ * 👷 Fix smokeshow setup. PR [#4](https://github.com/tiangolo/markdown-include-variants/pull/4) by [@tiangolo](https://github.com/tiangolo).
53
+ * 👷 Tweak labeler GitHub Action to not change labels on manual labels. PR [#5](https://github.com/tiangolo/markdown-include-variants/pull/5) by [@tiangolo](https://github.com/tiangolo).
54
+ * 👷 Tweak CI and types. PR [#2](https://github.com/tiangolo/markdown-include-variants/pull/2) by [@tiangolo](https://github.com/tiangolo).
@@ -12,7 +12,7 @@ class Variant:
12
12
  path: Path
13
13
  title: str
14
14
  is_annotated: Union[bool, None]
15
- version: Literal["py38", "py39", "py310"]
15
+ version: Literal["py38", "py39", "py310", "py311"]
16
16
 
17
17
 
18
18
  def remove_suffixes(base_name: str, suffixes: list[str]) -> str:
@@ -25,18 +25,45 @@ def remove_suffixes(base_name: str, suffixes: list[str]) -> str:
25
25
 
26
26
  def calculate_variants(base_path: Path) -> dict[tuple[str, Union[bool, None]], Variant]:
27
27
  preferred_name = base_path.stem
28
- base_name = remove_suffixes(preferred_name, ["_an", "_py39", "_py310"])
28
+ base_name = remove_suffixes(preferred_name, ["_an", "_py39", "_py310", "_py311"])
29
29
  base_dir = base_path.parent
30
30
  variants: dict[tuple[str, Union[bool, None]], Variant] = {}
31
31
  an = "_an"
32
32
  py39 = "_py39"
33
33
  py310 = "_py310"
34
+ py311 = "_py311"
35
+ an_p311_path = base_dir / f"{base_name}{an}{py311}.py"
34
36
  an_p310_path = base_dir / f"{base_name}{an}{py310}.py"
35
37
  an_p39_path = base_dir / f"{base_name}{an}{py39}.py"
36
38
  an_p38_path = base_dir / f"{base_name}{an}.py"
39
+ p311_path = base_dir / f"{base_name}{py311}.py"
37
40
  p310_path = base_dir / f"{base_name}{py310}.py"
38
41
  p39_path = base_dir / f"{base_name}{py39}.py"
39
42
  p38_path = base_dir / f"{base_name}.py"
43
+ if an_p311_path.exists():
44
+ v = Variant(
45
+ path=an_p311_path,
46
+ title="Python 3.11+",
47
+ is_annotated=True,
48
+ version="py311",
49
+ )
50
+ variants[(v.version, v.is_annotated)] = v
51
+ if p311_path.exists():
52
+ v = Variant(
53
+ path=p311_path,
54
+ title="Python 3.11+ - non-Annotated",
55
+ is_annotated=False,
56
+ version="py311",
57
+ )
58
+ variants[(v.version, v.is_annotated)] = v
59
+ elif p311_path.exists():
60
+ v = Variant(
61
+ path=p311_path,
62
+ title="Python 3.11+",
63
+ is_annotated=None,
64
+ version="py311",
65
+ )
66
+ variants[(v.version, v.is_annotated)] = v
40
67
  if an_p310_path.exists():
41
68
  v = Variant(
42
69
  path=an_p310_path,
@@ -221,7 +248,7 @@ class IncludeVariantsPreprocessor(Preprocessor):
221
248
  sorted_variants: list[Variant] = []
222
249
  preferred_variant = None
223
250
  for an in [True, False, None]:
224
- for version in ["py310", "py39", "py38"]:
251
+ for version in ["py311", "py310", "py39", "py38"]:
225
252
  v = variants.get((version, an))
226
253
  if v:
227
254
  if v.path == base_path:
@@ -237,47 +264,50 @@ class IncludeVariantsPreprocessor(Preprocessor):
237
264
  internal_block_lines.append(
238
265
  f"{{!{preferred_variant.path}!}}",
239
266
  )
240
- for i, line_group in enumerate(include_lines):
241
- if i == 0 and line_group[0] > 1:
242
- internal_block_lines.extend(
243
- [
244
- "# Code above omitted 👆",
245
- "",
246
- ]
247
- )
248
- if i >= 1:
249
- internal_block_lines.extend(
250
- [
251
- "",
252
- "# Code here omitted 👈",
253
- "",
254
- ]
255
- )
256
- internal_block_lines.append(
257
- f"{{!{preferred_variant.path}[ln:{line_group[0]}-{line_group[1]}]!}}"
258
- )
259
- if i == len(include_lines) - 1 and line_group[1] < len(content_lines):
260
- internal_block_lines.extend(
261
- [
262
- "",
263
- "# Code below omitted 👇",
264
- ]
267
+ if include_lines != [(0, 0)]:
268
+ for i, line_group in enumerate(include_lines):
269
+ if i == 0 and line_group[0] > 1:
270
+ internal_block_lines.extend(
271
+ [
272
+ "# Code above omitted 👆",
273
+ "",
274
+ ]
275
+ )
276
+ if i >= 1:
277
+ internal_block_lines.extend(
278
+ [
279
+ "",
280
+ "# Code here omitted 👈",
281
+ "",
282
+ ]
283
+ )
284
+ internal_block_lines.append(
285
+ f"{{!{preferred_variant.path}[ln:{line_group[0]}-{line_group[1]}]!}}"
265
286
  )
266
- first_line = "```python"
267
- if use_hl_lines:
268
- first_line += f' hl_lines="{use_hl_lines_str}"'
287
+ if i == len(include_lines) - 1 and line_group[1] < len(
288
+ content_lines
289
+ ):
290
+ internal_block_lines.extend(
291
+ [
292
+ "",
293
+ "# Code below omitted 👇",
294
+ ]
295
+ )
296
+ first_line = "```python"
297
+ if use_hl_lines:
298
+ first_line += f' hl_lines="{use_hl_lines_str}"'
269
299
 
270
- block_lines.extend(
271
- [
272
- f"//// tab | {preferred_variant.title}" "",
273
- first_line,
274
- *internal_block_lines,
275
- "```",
276
- "",
277
- "////",
278
- "",
279
- ]
280
- )
300
+ block_lines.extend(
301
+ [
302
+ f"//// tab | {preferred_variant.title}" "",
303
+ first_line,
304
+ *internal_block_lines,
305
+ "```",
306
+ "",
307
+ "////",
308
+ "",
309
+ ]
310
+ )
281
311
  if include_lines:
282
312
  first_line_full = "```python"
283
313
  if highlight_lines:
@@ -285,7 +315,9 @@ class IncludeVariantsPreprocessor(Preprocessor):
285
315
  first_line_full += f' hl_lines="{hl_lines_full_str}"'
286
316
  block_lines.extend(
287
317
  [
288
- "//// details | 👀 Full file preview",
318
+ "///// details | 👀 Full file preview",
319
+ "",
320
+ f"//// tab | {preferred_variant.title}",
289
321
  "",
290
322
  first_line_full,
291
323
  f"{{!{preferred_variant.path}!}}",
@@ -293,6 +325,8 @@ class IncludeVariantsPreprocessor(Preprocessor):
293
325
  "",
294
326
  "////",
295
327
  "",
328
+ "/////",
329
+ "",
296
330
  ]
297
331
  )
298
332
  if len(sorted_variants):
@@ -0,0 +1 @@
1
+ __version__ = "0.0.5"
@@ -12,7 +12,7 @@ from markdown_include_variants import IncludeVariantsExtension
12
12
  def test_all_variants_plain():
13
13
  input_md = inspect.cleandoc(
14
14
  """
15
- {* docs_src/all_variants/tutorial001_an_py310.py *}
15
+ {* docs_src/all_variants/tutorial001_an_py311.py *}
16
16
  """
17
17
  )
18
18
 
@@ -20,12 +20,16 @@ def test_all_variants_plain():
20
20
  assert result == snapshot(
21
21
  inspect.cleandoc(
22
22
  """
23
- <p>//// tab | Python 3.10+
23
+ <p>//// tab | Python 3.11+
24
24
  <code>python
25
- {!docs_src/all_variants/tutorial001_an_py310.py!}</code></p>
25
+ {!docs_src/all_variants/tutorial001_an_py311.py!}</code></p>
26
26
  <p>////</p>
27
27
  <p>///// details | 🤓 Other versions and variants</p>
28
- <p>//// tab | Python 3.9+</p>
28
+ <p>//// tab | Python 3.10+</p>
29
+ <p><code>python
30
+ {!docs_src/all_variants/tutorial001_an_py310.py!}</code>
31
+ ////
32
+ //// tab | Python 3.9+</p>
29
33
  <p><code>python
30
34
  {!docs_src/all_variants/tutorial001_an_py39.py!}</code>
31
35
  ////
@@ -33,6 +37,13 @@ def test_all_variants_plain():
33
37
  <p><code>python
34
38
  {!docs_src/all_variants/tutorial001_an.py!}</code>
35
39
  ////
40
+ //// tab | Python 3.11+ - non-Annotated</p>
41
+ <p>/// tip</p>
42
+ <p>Prefer to use the <code>Annotated</code> version if possible.</p>
43
+ <p>///</p>
44
+ <p><code>python
45
+ {!docs_src/all_variants/tutorial001_py311.py!}</code>
46
+ ////
36
47
  //// tab | Python 3.10+ - non-Annotated</p>
37
48
  <p>/// tip</p>
38
49
  <p>Prefer to use the <code>Annotated</code> version if possible.</p>
@@ -63,7 +74,7 @@ def test_all_variants_plain():
63
74
  def test_all_variants_ln_hl():
64
75
  input_md = inspect.cleandoc(
65
76
  """
66
- {* docs_src/all_variants/tutorial001_an_py310.py ln[3:5] hl[4:5] *}
77
+ {* docs_src/all_variants/tutorial001_an_py311.py ln[3:5] hl[4:5] *}
67
78
  """
68
79
  )
69
80
 
@@ -71,19 +82,25 @@ def test_all_variants_ln_hl():
71
82
  assert result == snapshot(
72
83
  inspect.cleandoc(
73
84
  """
74
- <p>//// tab | Python 3.10+
85
+ <p>//// tab | Python 3.11+
75
86
  ```python hl_lines="4-5"</p>
76
87
  <h1>Code above omitted 👆</h1>
77
- <p>{!docs_src/all_variants/tutorial001_an_py310.py[ln:3-5]!}</p>
88
+ <p>{!docs_src/all_variants/tutorial001_an_py311.py[ln:3-5]!}</p>
78
89
  <h1>Code below omitted 👇</h1>
79
90
  <p>```</p>
80
91
  <p>////</p>
81
- <p>//// details | 👀 Full file preview</p>
92
+ <p>///// details | 👀 Full file preview</p>
93
+ <p>//// tab | Python 3.11+</p>
82
94
  <p><code>python hl_lines="4-5"
83
- {!docs_src/all_variants/tutorial001_an_py310.py!}</code></p>
95
+ {!docs_src/all_variants/tutorial001_an_py311.py!}</code></p>
84
96
  <p>////</p>
97
+ <p>/////</p>
85
98
  <p>///// details | 🤓 Other versions and variants</p>
86
- <p>//// tab | Python 3.9+</p>
99
+ <p>//// tab | Python 3.10+</p>
100
+ <p><code>python
101
+ {!docs_src/all_variants/tutorial001_an_py310.py!}</code>
102
+ ////
103
+ //// tab | Python 3.9+</p>
87
104
  <p><code>python
88
105
  {!docs_src/all_variants/tutorial001_an_py39.py!}</code>
89
106
  ////
@@ -91,6 +108,13 @@ def test_all_variants_ln_hl():
91
108
  <p><code>python
92
109
  {!docs_src/all_variants/tutorial001_an.py!}</code>
93
110
  ////
111
+ //// tab | Python 3.11+ - non-Annotated</p>
112
+ <p>/// tip</p>
113
+ <p>Prefer to use the <code>Annotated</code> version if possible.</p>
114
+ <p>///</p>
115
+ <p><code>python
116
+ {!docs_src/all_variants/tutorial001_py311.py!}</code>
117
+ ////
94
118
  //// tab | Python 3.10+ - non-Annotated</p>
95
119
  <p>/// tip</p>
96
120
  <p>Prefer to use the <code>Annotated</code> version if possible.</p>
@@ -121,7 +145,7 @@ def test_all_variants_ln_hl():
121
145
  def test_all_variants_ln_hl_include():
122
146
  input_md = inspect.cleandoc(
123
147
  """
124
- {* docs_src/all_variants/tutorial001_an_py310.py ln[3:5] hl[4:5] *}
148
+ {* docs_src/all_variants/tutorial001_an_py311.py ln[3:5] hl[4:5] *}
125
149
  """
126
150
  )
127
151
 
@@ -137,31 +161,46 @@ def test_all_variants_ln_hl_include():
137
161
  assert result == snapshot(
138
162
  inspect.cleandoc(
139
163
  """
140
- <p>//// tab | Python 3.10+
164
+ <p>//// tab | Python 3.11+
141
165
  <div class="highlight"><pre><span></span><code><span class="c1"># Code above omitted 👆</span>
142
166
 
143
- <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py310 line 3&quot;</span><span class="p">)</span>
144
- <span class="hll"><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py310 line 4&quot;</span><span class="p">)</span>
145
- </span><span class="hll"><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py310 line 5&quot;</span><span class="p">)</span>
167
+ <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py311 line 3&quot;</span><span class="p">)</span>
168
+ <span class="hll"><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py311 line 4&quot;</span><span class="p">)</span>
169
+ </span><span class="hll"><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py311 line 5&quot;</span><span class="p">)</span>
146
170
  </span>
147
171
  <span class="c1"># Code below omitted 👇</span>
148
172
  </code></pre></div></p>
149
173
  <p>////</p>
150
- <p>//// details | 👀 Full file preview</p>
151
- <div class="highlight"><pre><span></span><code><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py310 line 1&quot;</span><span class="p">)</span>
174
+ <p>///// details | 👀 Full file preview</p>
175
+ <p>//// tab | Python 3.11+</p>
176
+ <div class="highlight"><pre><span></span><code><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py311 line 1&quot;</span><span class="p">)</span>
177
+ <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py311 line 2&quot;</span><span class="p">)</span>
178
+ <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py311 line 3&quot;</span><span class="p">)</span>
179
+ <span class="hll"><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py311 line 4&quot;</span><span class="p">)</span>
180
+ </span><span class="hll"><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py311 line 5&quot;</span><span class="p">)</span>
181
+ </span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py311 line 6&quot;</span><span class="p">)</span>
182
+ <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py311 line 7&quot;</span><span class="p">)</span>
183
+ <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py311 line 8&quot;</span><span class="p">)</span>
184
+ <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py311 line 9&quot;</span><span class="p">)</span>
185
+ <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py311 line 10&quot;</span><span class="p">)</span>
186
+ </code></pre></div>
187
+ <p>////</p>
188
+ <p>/////</p>
189
+ <p>///// details | 🤓 Other versions and variants</p>
190
+ <p>//// tab | Python 3.10+</p>
191
+ <p><div class="highlight"><pre><span></span><code><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py310 line 1&quot;</span><span class="p">)</span>
152
192
  <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py310 line 2&quot;</span><span class="p">)</span>
153
193
  <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py310 line 3&quot;</span><span class="p">)</span>
154
- <span class="hll"><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py310 line 4&quot;</span><span class="p">)</span>
155
- </span><span class="hll"><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py310 line 5&quot;</span><span class="p">)</span>
156
- </span><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py310 line 6&quot;</span><span class="p">)</span>
194
+ <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py310 line 4&quot;</span><span class="p">)</span>
195
+ <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py310 line 5&quot;</span><span class="p">)</span>
196
+ <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py310 line 6&quot;</span><span class="p">)</span>
157
197
  <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py310 line 7&quot;</span><span class="p">)</span>
158
198
  <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py310 line 8&quot;</span><span class="p">)</span>
159
199
  <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py310 line 9&quot;</span><span class="p">)</span>
160
200
  <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py310 line 10&quot;</span><span class="p">)</span>
161
201
  </code></pre></div>
162
- <p>////</p>
163
- <p>///// details | 🤓 Other versions and variants</p>
164
- <p>//// tab | Python 3.9+</p>
202
+ ////
203
+ //// tab | Python 3.9+</p>
165
204
  <p><div class="highlight"><pre><span></span><code><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py39 line 1&quot;</span><span class="p">)</span>
166
205
  <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py39 line 2&quot;</span><span class="p">)</span>
167
206
  <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an py39 line 3&quot;</span><span class="p">)</span>
@@ -187,6 +226,22 @@ def test_all_variants_ln_hl_include():
187
226
  <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;an line 10&quot;</span><span class="p">)</span>
188
227
  </code></pre></div>
189
228
  ////
229
+ //// tab | Python 3.11+ - non-Annotated</p>
230
+ <p>/// tip</p>
231
+ <p>Prefer to use the <code>Annotated</code> version if possible.</p>
232
+ <p>///</p>
233
+ <p><div class="highlight"><pre><span></span><code><span class="nb">print</span><span class="p">(</span><span class="s2">&quot;py311 line 1&quot;</span><span class="p">)</span>
234
+ <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;py311 line 2&quot;</span><span class="p">)</span>
235
+ <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;py311 line 3&quot;</span><span class="p">)</span>
236
+ <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;py311 line 4&quot;</span><span class="p">)</span>
237
+ <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;py311 line 5&quot;</span><span class="p">)</span>
238
+ <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;py311 line 6&quot;</span><span class="p">)</span>
239
+ <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;py311 line 7&quot;</span><span class="p">)</span>
240
+ <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;py311 line 8&quot;</span><span class="p">)</span>
241
+ <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;py311 line 9&quot;</span><span class="p">)</span>
242
+ <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;py311 line 10&quot;</span><span class="p">)</span>
243
+ </code></pre></div>
244
+ ////
190
245
  //// tab | Python 3.10+ - non-Annotated</p>
191
246
  <p>/// tip</p>
192
247
  <p>Prefer to use the <code>Annotated</code> version if possible.</p>
@@ -22,7 +22,11 @@ def test_all_variants_plain():
22
22
  {!docs_src/all_variants/tutorial001_an_py39.py!}</code></p>
23
23
  <p>////</p>
24
24
  <p>///// details | 🤓 Other versions and variants</p>
25
- <p>//// tab | Python 3.10+</p>
25
+ <p>//// tab | Python 3.11+</p>
26
+ <p><code>python
27
+ {!docs_src/all_variants/tutorial001_an_py311.py!}</code>
28
+ ////
29
+ //// tab | Python 3.10+</p>
26
30
  <p><code>python
27
31
  {!docs_src/all_variants/tutorial001_an_py310.py!}</code>
28
32
  ////
@@ -30,6 +34,13 @@ def test_all_variants_plain():
30
34
  <p><code>python
31
35
  {!docs_src/all_variants/tutorial001_an.py!}</code>
32
36
  ////
37
+ //// tab | Python 3.11+ - non-Annotated</p>
38
+ <p>/// tip</p>
39
+ <p>Prefer to use the <code>Annotated</code> version if possible.</p>
40
+ <p>///</p>
41
+ <p><code>python
42
+ {!docs_src/all_variants/tutorial001_py311.py!}</code>
43
+ ////
33
44
  //// tab | Python 3.10+ - non-Annotated</p>
34
45
  <p>/// tip</p>
35
46
  <p>Prefer to use the <code>Annotated</code> version if possible.</p>
@@ -0,0 +1,33 @@
1
+ import inspect
2
+
3
+ import markdown
4
+ from inline_snapshot import snapshot
5
+
6
+ from markdown_include_variants import IncludeVariantsExtension
7
+
8
+
9
+ def test_only_preview():
10
+ input_md = inspect.cleandoc(
11
+ """
12
+ {* docs_src/simple/tutorial001.py ln[0] *}
13
+ """
14
+ )
15
+
16
+ result = markdown.markdown(
17
+ input_md,
18
+ extensions=[
19
+ IncludeVariantsExtension(),
20
+ ],
21
+ )
22
+ assert result == snapshot(
23
+ inspect.cleandoc(
24
+ """
25
+ <p>///// details | 👀 Full file preview</p>
26
+ <p>//// tab | Python 3.8+</p>
27
+ <p><code>python
28
+ {!docs_src/simple/tutorial001.py!}</code></p>
29
+ <p>////</p>
30
+ <p>/////</p>
31
+ """
32
+ )
33
+ )