topmark 0.2.0__tar.gz → 0.3.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.
- {topmark-0.2.0/src/topmark.egg-info → topmark-0.3.0}/PKG-INFO +175 -148
- topmark-0.3.0/README.md +377 -0
- {topmark-0.2.0 → topmark-0.3.0}/pyproject.toml +21 -15
- topmark-0.3.0/src/topmark/api/__init__.py +536 -0
- topmark-0.3.0/src/topmark/api/public_types.py +98 -0
- topmark-0.3.0/src/topmark/api/types.py +149 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/cli/__init__.py +5 -1
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/cli/cli_types.py +10 -9
- topmark-0.3.0/src/topmark/cli/cmd_common.py +228 -0
- topmark-0.3.0/src/topmark/cli/commands/check.py +399 -0
- topmark-0.3.0/src/topmark/cli/commands/dump_config.py +175 -0
- topmark-0.3.0/src/topmark/cli/commands/filetypes.py +236 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/cli/commands/init_config.py +13 -10
- topmark-0.3.0/src/topmark/cli/commands/processors.py +194 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/cli/commands/show_defaults.py +12 -8
- topmark-0.3.0/src/topmark/cli/commands/strip.py +347 -0
- topmark-0.3.0/src/topmark/cli/commands/version.py +63 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/cli/config_resolver.py +3 -0
- topmark-0.3.0/src/topmark/cli/errors.py +100 -0
- topmark-0.3.0/src/topmark/cli/io.py +295 -0
- topmark-0.3.0/src/topmark/cli/main.py +121 -0
- topmark-0.3.0/src/topmark/cli/options.py +542 -0
- topmark-0.3.0/src/topmark/cli/utils.py +148 -0
- topmark-0.3.0/src/topmark/cli_shared/__init__.py +11 -0
- topmark-0.3.0/src/topmark/cli_shared/exit_codes.py +72 -0
- topmark-0.3.0/src/topmark/cli_shared/utils.py +417 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/config/__init__.py +78 -57
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/config/logging.py +1 -1
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/constants.py +1 -1
- topmark-0.3.0/src/topmark/file_resolver.py +288 -0
- topmark-0.3.0/src/topmark/filetypes/base.py +190 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/filetypes/instances.py +137 -24
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/filetypes/registry.py +3 -7
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/pipeline/context.py +65 -17
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/pipeline/pipelines.py +19 -3
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/pipeline/processors/__init__.py +7 -5
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/pipeline/processors/base.py +338 -142
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/pipeline/processors/pound.py +11 -15
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/pipeline/processors/slash.py +12 -14
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/pipeline/processors/xml.py +144 -30
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/pipeline/runner.py +1 -2
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/pipeline/steps/builder.py +4 -1
- topmark-0.3.0/src/topmark/pipeline/steps/comparer.py +129 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/pipeline/steps/patcher.py +18 -78
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/pipeline/steps/reader.py +45 -8
- topmark-0.3.0/src/topmark/pipeline/steps/renderer.py +113 -0
- topmark-0.3.0/src/topmark/pipeline/steps/resolver.py +295 -0
- topmark-0.3.0/src/topmark/pipeline/steps/stripper.py +76 -0
- topmark-0.3.0/src/topmark/pipeline/steps/updater.py +221 -0
- topmark-0.3.0/src/topmark/registry/__init__.py +50 -0
- topmark-0.3.0/src/topmark/registry/filetypes.py +196 -0
- topmark-0.3.0/src/topmark/registry/processors.py +193 -0
- topmark-0.3.0/src/topmark/registry/registry.py +177 -0
- topmark-0.3.0/src/topmark/utils/diff.py +106 -0
- {topmark-0.2.0 → topmark-0.3.0/src/topmark.egg-info}/PKG-INFO +175 -148
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark.egg-info/SOURCES.txt +18 -1
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark.egg-info/requires.txt +3 -2
- topmark-0.2.0/README.md +0 -351
- topmark-0.2.0/src/topmark/cli/commands/default.py +0 -336
- topmark-0.2.0/src/topmark/cli/commands/dump_config.py +0 -108
- topmark-0.2.0/src/topmark/cli/commands/filetypes.py +0 -39
- topmark-0.2.0/src/topmark/cli/commands/version.py +0 -32
- topmark-0.2.0/src/topmark/cli/main.py +0 -475
- topmark-0.2.0/src/topmark/cli/options.py +0 -276
- topmark-0.2.0/src/topmark/cli/utils.py +0 -245
- topmark-0.2.0/src/topmark/file_resolver.py +0 -228
- topmark-0.2.0/src/topmark/filetypes/base.py +0 -97
- topmark-0.2.0/src/topmark/pipeline/steps/comparer.py +0 -73
- topmark-0.2.0/src/topmark/pipeline/steps/renderer.py +0 -64
- topmark-0.2.0/src/topmark/pipeline/steps/resolver.py +0 -142
- topmark-0.2.0/src/topmark/pipeline/steps/updater.py +0 -183
- {topmark-0.2.0 → topmark-0.3.0}/LICENSE +0 -0
- {topmark-0.2.0 → topmark-0.3.0}/setup.cfg +0 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/__init__.py +0 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/cli/commands/__init__.py +0 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/config/topmark-default.toml +0 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/filetypes/__init__.py +0 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/filetypes/policy.py +0 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/pipeline/__init__.py +0 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/pipeline/contracts.py +0 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/pipeline/steps/__init__.py +0 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/pipeline/steps/scanner.py +0 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/py.typed +0 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/rendering/api.py +0 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/rendering/formats.py +0 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/utils/__init__.py +0 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark/utils/file.py +0 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark.egg-info/dependency_links.txt +0 -0
- {topmark-0.2.0 → topmark-0.3.0}/src/topmark.egg-info/entry_points.txt +0 -0
- {topmark-0.2.0 → topmark-0.3.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.
|
|
3
|
+
Version: 0.3.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
|
|
@@ -24,7 +24,6 @@ Requires-Dist: click
|
|
|
24
24
|
Provides-Extra: dev
|
|
25
25
|
Requires-Dist: ruff; extra == "dev"
|
|
26
26
|
Requires-Dist: pylint; extra == "dev"
|
|
27
|
-
Requires-Dist: mypy; extra == "dev"
|
|
28
27
|
Requires-Dist: pyright; extra == "dev"
|
|
29
28
|
Requires-Dist: mdformat; extra == "dev"
|
|
30
29
|
Requires-Dist: mdformat-tables; extra == "dev"
|
|
@@ -38,12 +37,14 @@ Provides-Extra: docs
|
|
|
38
37
|
Requires-Dist: mkdocs>=1.6; extra == "docs"
|
|
39
38
|
Requires-Dist: mkdocs-material>=9.5; extra == "docs"
|
|
40
39
|
Requires-Dist: mkdocstrings[python]>=0.25; extra == "docs"
|
|
40
|
+
Requires-Dist: mkdocs-autorefs>=0.5; extra == "docs"
|
|
41
41
|
Requires-Dist: pymdown-extensions>=10.8; extra == "docs"
|
|
42
|
+
Requires-Dist: mkdocs-gen-files<0.6,>=0.5; extra == "docs"
|
|
43
|
+
Requires-Dist: ruff; extra == "docs"
|
|
42
44
|
Provides-Extra: test
|
|
43
45
|
Requires-Dist: pytest; extra == "test"
|
|
44
46
|
Requires-Dist: pytest-xdist; extra == "test"
|
|
45
47
|
Provides-Extra: typing
|
|
46
|
-
Requires-Dist: mypy; extra == "typing"
|
|
47
48
|
Requires-Dist: types-toml; extra == "typing"
|
|
48
49
|
Dynamic: license-file
|
|
49
50
|
|
|
@@ -70,6 +71,13 @@ topmark:header:end
|
|
|
70
71
|
codebases. It helps maintain consistent header metadata across projects by supporting per-file-type
|
|
71
72
|
header formats, customizable fields, inclusion/exclusion rules, and dry-run safety.
|
|
72
73
|
|
|
74
|
+
## 📚 Documentation
|
|
75
|
+
|
|
76
|
+
Full documentation is available on Read the Docs: <https://topmark.readthedocs.io>
|
|
77
|
+
|
|
78
|
+
This README is the canonical, complete introduction for GitHub/PyPI. The docs site provides a
|
|
79
|
+
concise landing page and deep links into topics (install, usage, CI, API, etc.).
|
|
80
|
+
|
|
73
81
|
## ✨ Features
|
|
74
82
|
|
|
75
83
|
- File header detection, insertion, and replacement
|
|
@@ -86,7 +94,7 @@ header formats, customizable fields, inclusion/exclusion rules, and dry-run safe
|
|
|
86
94
|
- CI-friendly design for safe automated use
|
|
87
95
|
- Strict static typing with mypy and Pyright, using PEP 604 union syntax
|
|
88
96
|
- Google-style docstrings without redundant type declarations
|
|
89
|
-
-
|
|
97
|
+
- Full header removal (`topmark strip`)
|
|
90
98
|
- Preserves original newline style (LF/CRLF/CR) and BOM
|
|
91
99
|
- Idempotent updates (re-running does not change already-correct files)
|
|
92
100
|
|
|
@@ -113,46 +121,60 @@ pip install topmark
|
|
|
113
121
|
## ⚙️ Usage
|
|
114
122
|
|
|
115
123
|
```bash
|
|
116
|
-
topmark [OPTIONS] [PATHS]...
|
|
124
|
+
topmark [SUBCOMMAND] [OPTIONS] [PATHS]...
|
|
117
125
|
```
|
|
118
126
|
|
|
119
127
|
TopMark uses Click 8.2 and supports shell completions. The base command performs a dry‑run *check*
|
|
120
128
|
by default and applies changes when `--apply` is provided.
|
|
121
129
|
|
|
130
|
+
The `strip` subcommand is provided to remove entire headers.
|
|
131
|
+
|
|
122
132
|
Logging verbosity is controlled globally:
|
|
123
133
|
|
|
124
134
|
- `-v`, `--verbose`: Increase verbosity (can be repeated)
|
|
125
135
|
- `-q`, `--quiet`: Suppress most output (overrides verbosity)
|
|
126
136
|
|
|
127
|
-
All other options
|
|
128
|
-
subcommands like `check` or `apply`.
|
|
137
|
+
All other options are specific to individual subcommands.
|
|
129
138
|
|
|
130
|
-
|
|
139
|
+
______________________________________________________________________
|
|
131
140
|
|
|
132
|
-
|
|
141
|
+
### Subcommands
|
|
142
|
+
|
|
143
|
+
| Command | Description |
|
|
144
|
+
| --------------- | -------------------------------------------------- |
|
|
145
|
+
| `dump-config` | Show the resolved configuration in TOML format |
|
|
146
|
+
| `filetypes` | List supported file types and their comment styles |
|
|
147
|
+
| `processors` | List registered header processors and file types |
|
|
148
|
+
| `strip` | Remove TopMark headers from files (destructive) |
|
|
149
|
+
| `version` | Print TopMark version |
|
|
150
|
+
| `show-defaults` | Show default config (without merging) |
|
|
151
|
+
| `init-config` | Output a starter configuration file |
|
|
133
152
|
|
|
134
|
-
|
|
135
|
-
- `--skip-unsupported` — hide unsupported file types and files matched by known types that
|
|
136
|
-
intentionally **do not** support headers (e.g., strict JSON). They remain **recognized** but are
|
|
137
|
-
not listed in results.
|
|
153
|
+
______________________________________________________________________
|
|
138
154
|
|
|
139
155
|
### Examples
|
|
140
156
|
|
|
141
157
|
```bash
|
|
142
158
|
# Check Python files in the src/ directory
|
|
143
|
-
topmark --file-type python src/
|
|
159
|
+
topmark check --file-type python src/
|
|
144
160
|
|
|
145
161
|
# Use exclusion patterns, and compute relative paths from src
|
|
146
|
-
topmark --file-type python --exclude .venv --relative-to src src/
|
|
162
|
+
topmark check --file-type python --exclude .venv --relative-to src src/
|
|
147
163
|
|
|
148
164
|
# Add one verbosity level to topmark, use exclusion patterns from .gitignore
|
|
149
|
-
topmark -v --file-type python --exclude-from .gitignore src/
|
|
165
|
+
topmark -v check --file-type python --exclude-from .gitignore src/
|
|
166
|
+
|
|
167
|
+
# Read a list of files from STDIN, generate summary
|
|
168
|
+
find . -name "*.py" | topmark check --file-type python --files-from - --summary
|
|
150
169
|
|
|
151
|
-
#
|
|
152
|
-
|
|
170
|
+
# Process all files that are either staged, or untracked but not ignored in a Git repo (needs dedulication with `sort -u`)
|
|
171
|
+
git ls-files -c -o --exclude-standard | sort -u | topmark check --files-from - --apply
|
|
153
172
|
|
|
154
|
-
#
|
|
155
|
-
|
|
173
|
+
# Read a single file's *content* from STDIN and render the resultng unified diff
|
|
174
|
+
cat README.md | topmark - --stdin-filename README.md --diff
|
|
175
|
+
|
|
176
|
+
# Read a single file's *content* from STDIN and print the updated content to stdout
|
|
177
|
+
cat README.md | topmark - --stdin-filename README.md --apply
|
|
156
178
|
|
|
157
179
|
# Dump the merged configuration (after loading all applicable config layers)
|
|
158
180
|
topmark dump-config --file-type python --exclude .venv --exclude-from .gitignore
|
|
@@ -163,180 +185,186 @@ topmark show-defaults
|
|
|
163
185
|
# Output a starter configuration to stdout
|
|
164
186
|
topmark init-config
|
|
165
187
|
|
|
166
|
-
# Show TopMark version
|
|
167
|
-
topmark version
|
|
188
|
+
# Show TopMark version in JSON format
|
|
189
|
+
topmark version --format json
|
|
168
190
|
|
|
169
191
|
# Apply changes to files in-place
|
|
170
|
-
topmark --apply src/
|
|
192
|
+
topmark check --apply src/
|
|
193
|
+
|
|
194
|
+
# Remove headers from files (dry-run)
|
|
195
|
+
topmark strip src/
|
|
196
|
+
|
|
197
|
+
# Remove headers from files and apply changes
|
|
198
|
+
topmark strip --apply src/
|
|
171
199
|
|
|
172
200
|
# CI-friendly summary: only show issues; ignore unsupported types
|
|
173
|
-
topmark --skip-compliant --skip-unsupported src/
|
|
201
|
+
topmark check --skip-compliant --skip-unsupported src/
|
|
202
|
+
|
|
203
|
+
# Apply fixes, don't report unsupported files, muted output (useful for pre-commit)
|
|
204
|
+
topmark check --apply --skip-unsupported --quiet
|
|
205
|
+
|
|
206
|
+
# Show supported file types in MarkDown format, providing detailed output:
|
|
207
|
+
topmark filetypes --format markdown --long
|
|
208
|
+
|
|
209
|
+
# Show registered header processors (brief)
|
|
210
|
+
topmark processors
|
|
174
211
|
|
|
175
|
-
#
|
|
176
|
-
topmark
|
|
212
|
+
# Detailed Markdown listing of processors and their file types
|
|
213
|
+
topmark processors --format markdown --long
|
|
177
214
|
```
|
|
178
215
|
|
|
179
|
-
|
|
216
|
+
______________________________________________________________________
|
|
180
217
|
|
|
181
|
-
|
|
218
|
+
## 🔌 Public API (stable)
|
|
182
219
|
|
|
183
|
-
|
|
220
|
+
TopMark exposes a small, stable Python API for integrations. Import from `topmark.api` for core
|
|
221
|
+
operations, and use the registry facade for read-only discovery.
|
|
184
222
|
|
|
185
|
-
|
|
223
|
+
### Quickstart
|
|
186
224
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
shebang **and** encoding line.
|
|
191
|
-
- Otherwise, place the header **at the top of the file**.
|
|
192
|
-
- Ensure **one trailing blank line** after the header block when the next line is not already blank.
|
|
225
|
+
```python
|
|
226
|
+
from pathlib import Path
|
|
227
|
+
from topmark import api
|
|
193
228
|
|
|
194
|
-
|
|
229
|
+
# Check (dry-run by default)
|
|
230
|
+
result = api.check([Path("src")])
|
|
231
|
+
print(result.summary) # {"unchanged": N, "error": M, ...}
|
|
232
|
+
print(result.had_errors) # True/False
|
|
195
233
|
|
|
196
|
-
|
|
197
|
-
|
|
234
|
+
# Apply changes explicitly
|
|
235
|
+
applied = api.check([Path("src")], apply=True)
|
|
236
|
+
|
|
237
|
+
# Remove headers
|
|
238
|
+
stripped = api.strip([Path("src")], apply=False)
|
|
239
|
+
```
|
|
198
240
|
|
|
199
|
-
|
|
200
|
-
#
|
|
201
|
-
# file :
|
|
202
|
-
# file_relpath :
|
|
203
|
-
#
|
|
204
|
-
# topmark:header:end
|
|
241
|
+
### Registry facade (read-only)
|
|
205
242
|
|
|
206
|
-
|
|
243
|
+
```python
|
|
244
|
+
from topmark.registry import Registry
|
|
245
|
+
|
|
246
|
+
fts = Registry.filetypes() # Mapping[str, FileType]
|
|
247
|
+
procs = Registry.processors() # Mapping[str, HeaderProcessor]
|
|
248
|
+
for b in Registry.bindings(): # (filetype, optional processor)
|
|
249
|
+
print(b.filetype.name, bool(b.processor))
|
|
207
250
|
```
|
|
208
251
|
|
|
209
|
-
|
|
252
|
+
> **Note:** `Registry` is **not** re-exported from `topmark.api`; import it from `topmark.registry`.
|
|
210
253
|
|
|
211
|
-
|
|
254
|
+
### Version helper
|
|
212
255
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
256
|
+
```python
|
|
257
|
+
from topmark import api
|
|
258
|
+
print(api.version()) # e.g. "0.3.0"
|
|
259
|
+
```
|
|
217
260
|
|
|
218
|
-
|
|
219
|
-
<!--
|
|
220
|
-
topmark:header:start
|
|
261
|
+
### Stability
|
|
221
262
|
|
|
222
|
-
|
|
223
|
-
|
|
263
|
+
- `topmark.api` and the `Registry` facade are covered by semantic versioning.
|
|
264
|
+
- Low-level registries (`FileTypeRegistry`, `HeaderProcessorRegistry`) remain available for
|
|
265
|
+
plugins/tests but are **advanced** and may change between minor versions.
|
|
224
266
|
|
|
225
|
-
|
|
226
|
-
|
|
267
|
+
### Adding & updating headers
|
|
268
|
+
|
|
269
|
+
Use the `topmark check` command to insert or update headers. It’s **dry‑run by default**; add
|
|
270
|
+
`--apply` to write changes. Placement follows file‑type policy (shebang/encoding for Python, XML
|
|
271
|
+
declaration for XML/HTML, etc.). Newline style and BOM are preserved; runs are idempotent.
|
|
227
272
|
|
|
228
|
-
|
|
273
|
+
#### Quick examples
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
# Preview (exit code 2 when changes are pending)
|
|
277
|
+
topmark src/
|
|
278
|
+
|
|
279
|
+
# Apply in place
|
|
280
|
+
topmark check --apply src/
|
|
229
281
|
```
|
|
230
282
|
|
|
231
|
-
|
|
283
|
+
> For full details, options, examples, and exit codes, see the dedicated guide:
|
|
284
|
+
> **[Adding & updating headers with `topmark`](docs/usage/commands/topmark.md)**
|
|
232
285
|
|
|
233
|
-
|
|
234
|
-
(LF/CRLF/CR).
|
|
235
|
-
- **BOM preservation:** If a UTF‑8 BOM is present, it is preserved.
|
|
236
|
-
- **Idempotency:** Re-running TopMark on a file with a correct header makes **no changes**.
|
|
286
|
+
### Removing headers with `strip`
|
|
237
287
|
|
|
238
|
-
|
|
288
|
+
Use `topmark strip` to remove the entire TopMark header block. The command is **dry-run by
|
|
289
|
+
default**; add `--apply` to write changes. It preserves newline style and BOM, and keeps XML
|
|
290
|
+
declarations and Markdown code fences intact.
|
|
239
291
|
|
|
240
|
-
|
|
292
|
+
#### Quick examples
|
|
241
293
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
| `--relative-to` | Set base path for relative header fields |
|
|
246
|
-
| `--include` | Include paths or glob patterns |
|
|
247
|
-
| `--include-from` | Read inclusion patterns from file |
|
|
248
|
-
| `--exclude` | Exclude paths or glob patterns |
|
|
249
|
-
| `--exclude-from` | Read exclusion patterns from file |
|
|
250
|
-
| `--stdin` | Read file paths from stdin |
|
|
251
|
-
| `--apply` | Actually modify files instead of dry-run |
|
|
252
|
-
| `-v, --verbose` | Increase verbosity (can be repeated) |
|
|
253
|
-
| `-q, --quiet` | Suppress most output |
|
|
294
|
+
```bash
|
|
295
|
+
# Preview (exit code 2 when removals are pending)
|
|
296
|
+
topmark strip src/
|
|
254
297
|
|
|
255
|
-
|
|
298
|
+
# Apply in place
|
|
299
|
+
topmark strip --apply src/
|
|
300
|
+
```
|
|
256
301
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
| `dump-config` | Show the resolved configuration in TOML format |
|
|
260
|
-
| `filetypes` | List supported file types and their comment styles |
|
|
261
|
-
| `version` | Print TopMark version |
|
|
262
|
-
| `show-defaults` | Show default config (without merging) |
|
|
263
|
-
| `init-config` | Output a starter configuration file |
|
|
302
|
+
> For full details, options, examples, and exit codes, see the dedicated guide:
|
|
303
|
+
> **[Removing headers with `topmark strip`](docs/usage/commands/strip.md)**
|
|
264
304
|
|
|
265
|
-
|
|
305
|
+
### Dumping the merged configuration
|
|
266
306
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
| XmlHeaderProcessor | html, markdown, svelte, svg, vue, xhtml, xml, xsl, xslt, yaml |
|
|
307
|
+
Use `topmark dump-config` to print the **effective** configuration (defaults → discovered config →
|
|
308
|
+
`--config` files → CLI flags) as TOML. This command is **file‑agnostic**: positional paths and
|
|
309
|
+
`--files-from` are ignored; filter flags (`--include/--exclude`, `--include-from/--exclude-from`)
|
|
310
|
+
are honored.
|
|
272
311
|
|
|
273
|
-
|
|
274
|
-
|
|
312
|
+
```bash
|
|
313
|
+
# Dump merged configuration
|
|
314
|
+
topmark dump-config
|
|
275
315
|
|
|
276
|
-
|
|
316
|
+
# Include/exclude filters still apply
|
|
317
|
+
topmark dump-config --exclude .venv --exclude-from .gitignore
|
|
277
318
|
|
|
278
|
-
|
|
279
|
-
topmark
|
|
319
|
+
# Read patterns from STDIN
|
|
320
|
+
printf "*.py\n" | topmark dump-config --include-from -
|
|
280
321
|
```
|
|
281
322
|
|
|
282
|
-
|
|
323
|
+
> For details and notes, see:
|
|
324
|
+
> **[Dumping the merged configuration with `dump-config`](docs/usage/commands/dump_config.md)**
|
|
283
325
|
|
|
284
|
-
|
|
326
|
+
### Listing supported file types
|
|
285
327
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
**patterns** over simple **extensions**,
|
|
289
|
-
- breaks ties in favor of **headerable** types (those without `skip_processing=True`).
|
|
328
|
+
Use `topmark filetypes` to see the identifiers you can pass to `--file-type` and the associated
|
|
329
|
+
comment styles TopMark will use when rendering headers.
|
|
290
330
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
331
|
+
```bash
|
|
332
|
+
# Show available file type identifiers
|
|
333
|
+
topmark filetypes
|
|
294
334
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
335
|
+
# Then restrict processing to one or more types
|
|
336
|
+
topmark check --file-type python src/
|
|
337
|
+
topmark check --file-type markdown --file-type env docs/ config/
|
|
338
|
+
```
|
|
299
339
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
processors provide a text‑offset path; `XmlHeaderProcessor` uses this and signals **no line
|
|
303
|
-
anchor**.
|
|
340
|
+
> For details, see:
|
|
341
|
+
> **[Listing supported file types with `filetypes`](docs/usage/commands/filetypes.md)**
|
|
304
342
|
|
|
305
|
-
##
|
|
343
|
+
## 📐 Header placement rules
|
|
306
344
|
|
|
307
|
-
TopMark
|
|
308
|
-
|
|
309
|
-
```yaml
|
|
310
|
-
# .pre-commit-config.yaml (in a consuming repository)
|
|
311
|
-
repos:
|
|
312
|
-
- repo: https://github.com/shutterfreak/topmark
|
|
313
|
-
rev: v0.2.0 # pin to a released tag
|
|
314
|
-
hooks:
|
|
315
|
-
- id: topmark-check
|
|
316
|
-
# Optional: limit scope to supported text types
|
|
317
|
-
# files: '\\.(py|md|toml|ya?ml|sh|Makefile)$'
|
|
318
|
-
```
|
|
345
|
+
TopMark is comment-aware and places the header block according to the file type and its policy.
|
|
319
346
|
|
|
320
|
-
|
|
347
|
+
The complete header placement rules are documented in the usage guide:
|
|
321
348
|
|
|
322
|
-
-
|
|
323
|
-
- **`topmark-apply`** — destructive, requires `--apply`. Marked `manual` so it only runs when you
|
|
324
|
-
call it explicitly.
|
|
349
|
+
- [Header placement rules](docs/usage/header-placement.md)
|
|
325
350
|
|
|
326
|
-
|
|
351
|
+
## 🧩 Supported file types
|
|
327
352
|
|
|
328
|
-
|
|
329
|
-
# On the whole repo
|
|
330
|
-
pre-commit run topmark-apply --all-files --hook-stage manual
|
|
353
|
+
See the full list and resolver behavior in the dedicated guide:
|
|
331
354
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
355
|
+
- [Supported file types](docs/usage/filetypes.md)
|
|
356
|
+
|
|
357
|
+
## 🪝 Pre-commit integration
|
|
358
|
+
|
|
359
|
+
TopMark ships with pre-commit hooks to validate or update file headers.
|
|
360
|
+
|
|
361
|
+
- **`topmark-check`** — runs automatically at `pre-commit` / `pre-push`, fails if headers need
|
|
362
|
+
changes.
|
|
363
|
+
- **`topmark-apply`** — manual only; applies fixes and may modify files.
|
|
364
|
+
|
|
365
|
+
For configuration examples, hook policies, and troubleshooting, see the dedicated guide:
|
|
335
366
|
|
|
336
|
-
|
|
337
|
-
argument-length limits. You may see repeated banners (e.g., “Processing N file(s)”) as the hook runs
|
|
338
|
-
once per batch. To run **once** per repo, set `pass_filenames: false` in the hook manifest and let
|
|
339
|
-
TopMark discover files itself.
|
|
367
|
+
- [Using TopMark with pre-commit](docs/usage/pre-commit.md)
|
|
340
368
|
|
|
341
369
|
## 🛠 Configuration
|
|
342
370
|
|
|
@@ -348,9 +376,9 @@ You can specify one or more `--config` files, or rely on local fallback resoluti
|
|
|
348
376
|
TopMark reads configuration from one or more TOML files. Configuration is merged from:
|
|
349
377
|
|
|
350
378
|
1. Built-in defaults
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
379
|
+
1. Local project config (if not disabled via `--no-config`)
|
|
380
|
+
1. Additional files via `--config`
|
|
381
|
+
1. CLI overrides
|
|
354
382
|
|
|
355
383
|
Example configuration snippet (`topmark.toml`):
|
|
356
384
|
|
|
@@ -396,5 +424,4 @@ type checks in each environment.
|
|
|
396
424
|
|
|
397
425
|
MIT License © 2025 Olivier Biot
|
|
398
426
|
|
|
399
|
-
|
|
400
|
-
read from `pyproject.toml`.
|
|
427
|
+
> **[LICENSE (MIT)](LICENSE)**
|