topmark 0.6.2__tar.gz → 0.7.0__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 (82) hide show
  1. {topmark-0.6.2/src/topmark.egg-info → topmark-0.7.0}/PKG-INFO +55 -2
  2. {topmark-0.6.2 → topmark-0.7.0}/README.md +54 -1
  3. {topmark-0.6.2 → topmark-0.7.0}/pyproject.toml +1 -1
  4. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli/commands/version.py +27 -7
  5. topmark-0.7.0/src/topmark/utils/version.py +78 -0
  6. {topmark-0.6.2 → topmark-0.7.0/src/topmark.egg-info}/PKG-INFO +55 -2
  7. {topmark-0.6.2 → topmark-0.7.0}/src/topmark.egg-info/SOURCES.txt +2 -1
  8. {topmark-0.6.2 → topmark-0.7.0}/LICENSE +0 -0
  9. {topmark-0.6.2 → topmark-0.7.0}/setup.cfg +0 -0
  10. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/__init__.py +0 -0
  11. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/api/__init__.py +0 -0
  12. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/api/public_types.py +0 -0
  13. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/api/types.py +0 -0
  14. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli/__init__.py +0 -0
  15. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli/cli_types.py +0 -0
  16. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli/cmd_common.py +0 -0
  17. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli/commands/__init__.py +0 -0
  18. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli/commands/check.py +0 -0
  19. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli/commands/dump_config.py +0 -0
  20. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli/commands/filetypes.py +0 -0
  21. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli/commands/init_config.py +0 -0
  22. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli/commands/processors.py +0 -0
  23. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli/commands/show_defaults.py +0 -0
  24. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli/commands/strip.py +0 -0
  25. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli/config_resolver.py +0 -0
  26. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli/console.py +0 -0
  27. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli/console_helpers.py +0 -0
  28. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli/console_std.py +0 -0
  29. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli/errors.py +0 -0
  30. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli/io.py +0 -0
  31. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli/main.py +0 -0
  32. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli/options.py +0 -0
  33. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli/utils.py +0 -0
  34. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli_shared/__init__.py +0 -0
  35. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli_shared/console_api.py +0 -0
  36. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli_shared/exit_codes.py +0 -0
  37. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/cli_shared/utils.py +0 -0
  38. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/config/__init__.py +0 -0
  39. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/config/io.py +0 -0
  40. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/config/logging.py +0 -0
  41. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/config/topmark-default.toml +0 -0
  42. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/constants.py +0 -0
  43. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/file_resolver.py +0 -0
  44. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/filetypes/__init__.py +0 -0
  45. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/filetypes/base.py +0 -0
  46. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/filetypes/instances.py +0 -0
  47. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/filetypes/policy.py +0 -0
  48. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/filetypes/registry.py +0 -0
  49. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/pipeline/__init__.py +0 -0
  50. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/pipeline/context.py +0 -0
  51. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/pipeline/contracts.py +0 -0
  52. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/pipeline/pipelines.py +0 -0
  53. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/pipeline/processors/__init__.py +0 -0
  54. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/pipeline/processors/base.py +0 -0
  55. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/pipeline/processors/pound.py +0 -0
  56. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/pipeline/processors/slash.py +0 -0
  57. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/pipeline/processors/xml.py +0 -0
  58. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/pipeline/runner.py +0 -0
  59. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/pipeline/steps/__init__.py +0 -0
  60. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/pipeline/steps/builder.py +0 -0
  61. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/pipeline/steps/comparer.py +0 -0
  62. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/pipeline/steps/patcher.py +0 -0
  63. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/pipeline/steps/reader.py +0 -0
  64. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/pipeline/steps/renderer.py +0 -0
  65. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/pipeline/steps/resolver.py +0 -0
  66. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/pipeline/steps/scanner.py +0 -0
  67. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/pipeline/steps/stripper.py +0 -0
  68. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/pipeline/steps/updater.py +0 -0
  69. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/py.typed +0 -0
  70. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/registry/__init__.py +0 -0
  71. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/registry/filetypes.py +0 -0
  72. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/registry/processors.py +0 -0
  73. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/registry/registry.py +0 -0
  74. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/rendering/api.py +0 -0
  75. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/rendering/formats.py +0 -0
  76. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/utils/__init__.py +0 -0
  77. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/utils/diff.py +0 -0
  78. {topmark-0.6.2 → topmark-0.7.0}/src/topmark/utils/file.py +0 -0
  79. {topmark-0.6.2 → topmark-0.7.0}/src/topmark.egg-info/dependency_links.txt +0 -0
  80. {topmark-0.6.2 → topmark-0.7.0}/src/topmark.egg-info/entry_points.txt +0 -0
  81. {topmark-0.6.2 → topmark-0.7.0}/src/topmark.egg-info/requires.txt +0 -0
  82. {topmark-0.6.2 → topmark-0.7.0}/src/topmark.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: topmark
3
- Version: 0.6.2
3
+ Version: 0.7.0
4
4
  Summary: A Python CLI to inspect, validate, and manage license and copyright headers.
5
5
  Author-email: Olivier Biot <olivier.biot@gmail.com>
6
6
  License-Expression: MIT
@@ -79,6 +79,56 @@ Full documentation is available on Read the Docs: <https://topmark.readthedocs.i
79
79
  This README is the canonical, complete introduction for GitHub/PyPI. The docs site provides a
80
80
  concise landing page and deep links into topics (install, usage, CI, API, etc.).
81
81
 
82
+ ## 📝 Example headers
83
+
84
+ TopMark inserts headers that are tailored to the comment style and conventions of each file type. Here are examples of how TopMark headers appear in different file formats:
85
+
86
+ ```bash
87
+ #!/bin/bash
88
+
89
+ # topmark:header:start
90
+ #
91
+ # project : TopMark
92
+ # file : script.sh
93
+ # license : MIT
94
+ # copyright : (c) 2025 Olivier Biot
95
+
96
+ # topmark:header:end
97
+
98
+ echo "Hello, World!"
99
+ ```
100
+
101
+ ```xml
102
+ <?xml version="1.0" encoding="UTF-8"?>
103
+ <!--
104
+ topmark:header:start
105
+
106
+ project : TopMark
107
+ file : config.xml
108
+ license : MIT
109
+ copyright : (c) 2025 Olivier Biot
110
+
111
+ topmark:header:end
112
+ -->
113
+
114
+ <configuration>
115
+ <!-- XML content here -->
116
+ </configuration>
117
+ ```
118
+
119
+ ```javascript
120
+ // topmark:header:start
121
+ //
122
+ // project : TopMark
123
+ // file : app.js
124
+ // license : MIT
125
+ // copyright : (c) 2025 Olivier Biot
126
+ //
127
+ // topmark:header:end
128
+
129
+ console.log("Hello, World!");
130
+ ```
131
+
82
132
  ## ✨ Features
83
133
 
84
134
  - File header detection, insertion, and replacement
@@ -193,9 +243,12 @@ topmark show-defaults
193
243
  # Output a starter configuration to stdout
194
244
  topmark init-config
195
245
 
196
- # Show TopMark version in JSON format
246
+ # Output TopMark version (PEP 440) in JSON format
197
247
  topmark version --format json
198
248
 
249
+ # Output TopMark version (SemVer) to stdout
250
+ topmark version --semver
251
+
199
252
  # Apply changes to files in-place
200
253
  topmark check --apply src/
201
254
 
@@ -28,6 +28,56 @@ Full documentation is available on Read the Docs: <https://topmark.readthedocs.i
28
28
  This README is the canonical, complete introduction for GitHub/PyPI. The docs site provides a
29
29
  concise landing page and deep links into topics (install, usage, CI, API, etc.).
30
30
 
31
+ ## 📝 Example headers
32
+
33
+ TopMark inserts headers that are tailored to the comment style and conventions of each file type. Here are examples of how TopMark headers appear in different file formats:
34
+
35
+ ```bash
36
+ #!/bin/bash
37
+
38
+ # topmark:header:start
39
+ #
40
+ # project : TopMark
41
+ # file : script.sh
42
+ # license : MIT
43
+ # copyright : (c) 2025 Olivier Biot
44
+
45
+ # topmark:header:end
46
+
47
+ echo "Hello, World!"
48
+ ```
49
+
50
+ ```xml
51
+ <?xml version="1.0" encoding="UTF-8"?>
52
+ <!--
53
+ topmark:header:start
54
+
55
+ project : TopMark
56
+ file : config.xml
57
+ license : MIT
58
+ copyright : (c) 2025 Olivier Biot
59
+
60
+ topmark:header:end
61
+ -->
62
+
63
+ <configuration>
64
+ <!-- XML content here -->
65
+ </configuration>
66
+ ```
67
+
68
+ ```javascript
69
+ // topmark:header:start
70
+ //
71
+ // project : TopMark
72
+ // file : app.js
73
+ // license : MIT
74
+ // copyright : (c) 2025 Olivier Biot
75
+ //
76
+ // topmark:header:end
77
+
78
+ console.log("Hello, World!");
79
+ ```
80
+
31
81
  ## ✨ Features
32
82
 
33
83
  - File header detection, insertion, and replacement
@@ -142,9 +192,12 @@ topmark show-defaults
142
192
  # Output a starter configuration to stdout
143
193
  topmark init-config
144
194
 
145
- # Show TopMark version in JSON format
195
+ # Output TopMark version (PEP 440) in JSON format
146
196
  topmark version --format json
147
197
 
198
+ # Output TopMark version (SemVer) to stdout
199
+ topmark version --semver
200
+
148
201
  # Apply changes to files in-place
149
202
  topmark check --apply src/
150
203
 
@@ -10,7 +10,7 @@
10
10
 
11
11
  [project]
12
12
  name = "topmark"
13
- version = "0.6.2"
13
+ version = "0.7.0" # PEP 440: "X.Y.Z.devN", "X.Y.ZrcN", or "X.Y.Z"
14
14
  description = "A Python CLI to inspect, validate, and manage license and copyright headers."
15
15
  authors = [{ name = "Olivier Biot", email = "olivier.biot@gmail.com" }]
16
16
  license = "MIT"
@@ -23,6 +23,7 @@ from topmark.cli.cli_types import EnumChoiceParam
23
23
  from topmark.cli.cmd_common import get_effective_verbosity
24
24
  from topmark.cli_shared.utils import OutputFormat
25
25
  from topmark.constants import TOPMARK_VERSION
26
+ from topmark.utils.version import pep440_to_semver
26
27
 
27
28
  if TYPE_CHECKING:
28
29
  from topmark.cli_shared.console_api import ConsoleLike
@@ -32,6 +33,12 @@ if TYPE_CHECKING:
32
33
  name="version",
33
34
  help="Show the current version of TopMark.",
34
35
  )
36
+ @click.option(
37
+ "--semver",
38
+ is_flag=True,
39
+ default=False,
40
+ help="Render the version as SemVer instead of PEP 440 (maps rc→-rc.N, dev→-dev.N).",
41
+ )
35
42
  @click.option(
36
43
  "--format",
37
44
  "output_format",
@@ -42,6 +49,7 @@ if TYPE_CHECKING:
42
49
  def version_command(
43
50
  *,
44
51
  output_format: OutputFormat | None = None,
52
+ semver: bool = False,
45
53
  ) -> None:
46
54
  """Show the current version of TopMark.
47
55
 
@@ -49,6 +57,7 @@ def version_command(
49
57
 
50
58
  Args:
51
59
  output_format (OutputFormat | None): Optional output format (plain text or markdown).
60
+ semver (bool): Return version identifier in `semver` if True, PEP440 (default) if False.
52
61
  """
53
62
  ctx = click.get_current_context()
54
63
  ctx.ensure_object(dict)
@@ -57,21 +66,32 @@ def version_command(
57
66
  # Determine effective program-output verbosity for gating extra details
58
67
  vlevel = get_effective_verbosity(ctx)
59
68
 
60
- topmark_version = TOPMARK_VERSION
69
+ topmark_version: str = TOPMARK_VERSION
61
70
  fmt: OutputFormat = output_format or OutputFormat.DEFAULT
62
-
71
+ version_text: str = topmark_version
72
+ if semver:
73
+ try:
74
+ version_text = pep440_to_semver(topmark_version)
75
+ except ValueError as exc:
76
+ # Fall back to raw version; if verbose, surface the reason.
77
+ if vlevel > 0:
78
+ console.print(console.styled(f"[warn] {exc}", bold=True))
79
+
80
+ format: str = "semver" if semver else "pep440"
63
81
  if fmt in (OutputFormat.JSON, OutputFormat.NDJSON):
64
82
  import json
65
83
 
66
- console.print(json.dumps({"topmark_version": topmark_version}))
84
+ console.print(json.dumps({"version": version_text, "format": format}))
67
85
  elif fmt == OutputFormat.MARKDOWN:
68
86
  console.print("# TopMark Version\n")
69
- console.print(f"**TopMark version {topmark_version}**")
87
+ console.print(f"**TopMark version ({format}): {version_text}**")
70
88
  else: # Plain text (default)
71
89
  if vlevel > 0:
72
- console.print(console.styled("TopMark version:\n", bold=True, underline=True))
73
- console.print(f" {console.styled(topmark_version, bold=True)}")
90
+ console.print(
91
+ console.styled(f"TopMark version ({format}):\n", bold=True, underline=True)
92
+ )
93
+ console.print(f" {console.styled(version_text, bold=True)}")
74
94
  else:
75
- console.print(console.styled(topmark_version, bold=True))
95
+ console.print(console.styled(version_text, bold=True))
76
96
 
77
97
  # No explicit return needed for Click commands.
@@ -0,0 +1,78 @@
1
+ # topmark:header:start
2
+ #
3
+ # project : TopMark
4
+ # file : version.py
5
+ # file_relpath : src/topmark/utils/version.py
6
+ # license : MIT
7
+ # copyright : (c) 2025 Olivier Biot
8
+ #
9
+ # topmark:header:end
10
+
11
+ """Version utilities for TopMark."""
12
+
13
+ import re
14
+
15
+ # Recognize the subset of PEP 440 we actually emit:
16
+ # X.Y.Z
17
+ # X.Y.ZrcN
18
+ # X.Y.ZaN / X.Y.ZbN
19
+ # X.Y.Z.devN
20
+ # +local (optional)
21
+ # We deliberately do NOT accept .postN here (no clean SemVer equivalent).
22
+ _PEP440_RE: re.Pattern[str] = re.compile(
23
+ r"""
24
+ ^
25
+ (?P<major>0|[1-9]\d*)\.
26
+ (?P<minor>0|[1-9]\d*)\.
27
+ (?P<patch>0|[1-9]\d*)
28
+ (?:
29
+ (?P<pre_label>a|b|rc)(?P<pre_num>\d+)
30
+ )?
31
+ (?:
32
+ \.post(?P<post>\d+)
33
+ )?
34
+ (?:
35
+ \.dev(?P<dev>\d+)
36
+ )?
37
+ (?:
38
+ \+(?P<local>[0-9A-Za-z]+(?:\.[0-9A-Za-z]+)*)
39
+ )?
40
+ $
41
+ """,
42
+ re.VERBOSE,
43
+ )
44
+
45
+
46
+ def pep440_to_semver(pep440_version: str) -> str:
47
+ """Convert (our) PEP 440 to SemVer.
48
+
49
+ Maps:
50
+ rcN -> -rc.N
51
+ aN -> -alpha.N
52
+ bN -> -beta.N
53
+ devN -> -dev.N (after any pre-release)
54
+ +local kept as-is
55
+
56
+ Args:
57
+ pep440_version (str): The version in PEP 440 format
58
+
59
+ Returns:
60
+ str: The version in SemVer format.
61
+
62
+ Raises:
63
+ ValueError: on post releases.
64
+ """
65
+ m: re.Match[str] | None = _PEP440_RE.match(pep440_version)
66
+ if not m:
67
+ raise ValueError(f"Not a recognized PEP 440 version: {pep440_version!r}")
68
+ if m.group("post") is not None:
69
+ raise ValueError(f"Post-releases are not valid SemVer: {pep440_version!r}")
70
+ major, minor, patch = m.group("major"), m.group("minor"), m.group("patch")
71
+ base: str = f"{major}.{minor}.{patch}"
72
+ pre = ""
73
+ if m.group("pre_label"):
74
+ lbl: str = {"a": "alpha", "b": "beta", "rc": "rc"}[m.group("pre_label")]
75
+ pre: str = f"-{lbl}.{m.group('pre_num')}"
76
+ dev: str = f"{'.' if pre else '-'}dev.{m.group('dev')}" if m.group("dev") else ""
77
+ local: str = f"+{m.group('local')}" if m.group("local") else ""
78
+ return f"{base}{pre}{dev}{local}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: topmark
3
- Version: 0.6.2
3
+ Version: 0.7.0
4
4
  Summary: A Python CLI to inspect, validate, and manage license and copyright headers.
5
5
  Author-email: Olivier Biot <olivier.biot@gmail.com>
6
6
  License-Expression: MIT
@@ -79,6 +79,56 @@ Full documentation is available on Read the Docs: <https://topmark.readthedocs.i
79
79
  This README is the canonical, complete introduction for GitHub/PyPI. The docs site provides a
80
80
  concise landing page and deep links into topics (install, usage, CI, API, etc.).
81
81
 
82
+ ## 📝 Example headers
83
+
84
+ TopMark inserts headers that are tailored to the comment style and conventions of each file type. Here are examples of how TopMark headers appear in different file formats:
85
+
86
+ ```bash
87
+ #!/bin/bash
88
+
89
+ # topmark:header:start
90
+ #
91
+ # project : TopMark
92
+ # file : script.sh
93
+ # license : MIT
94
+ # copyright : (c) 2025 Olivier Biot
95
+
96
+ # topmark:header:end
97
+
98
+ echo "Hello, World!"
99
+ ```
100
+
101
+ ```xml
102
+ <?xml version="1.0" encoding="UTF-8"?>
103
+ <!--
104
+ topmark:header:start
105
+
106
+ project : TopMark
107
+ file : config.xml
108
+ license : MIT
109
+ copyright : (c) 2025 Olivier Biot
110
+
111
+ topmark:header:end
112
+ -->
113
+
114
+ <configuration>
115
+ <!-- XML content here -->
116
+ </configuration>
117
+ ```
118
+
119
+ ```javascript
120
+ // topmark:header:start
121
+ //
122
+ // project : TopMark
123
+ // file : app.js
124
+ // license : MIT
125
+ // copyright : (c) 2025 Olivier Biot
126
+ //
127
+ // topmark:header:end
128
+
129
+ console.log("Hello, World!");
130
+ ```
131
+
82
132
  ## ✨ Features
83
133
 
84
134
  - File header detection, insertion, and replacement
@@ -193,9 +243,12 @@ topmark show-defaults
193
243
  # Output a starter configuration to stdout
194
244
  topmark init-config
195
245
 
196
- # Show TopMark version in JSON format
246
+ # Output TopMark version (PEP 440) in JSON format
197
247
  topmark version --format json
198
248
 
249
+ # Output TopMark version (SemVer) to stdout
250
+ topmark version --semver
251
+
199
252
  # Apply changes to files in-place
200
253
  topmark check --apply src/
201
254
 
@@ -76,4 +76,5 @@ src/topmark/rendering/api.py
76
76
  src/topmark/rendering/formats.py
77
77
  src/topmark/utils/__init__.py
78
78
  src/topmark/utils/diff.py
79
- src/topmark/utils/file.py
79
+ src/topmark/utils/file.py
80
+ src/topmark/utils/version.py
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes