Skip to content

Commit c61af90

Browse files
committed
added arguments --min-version and --squash-patches
1 parent 38bfc71 commit c61af90

File tree

4 files changed

+62
-8
lines changed

4 files changed

+62
-8
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## v0.17.0 - 2024-04-21
4+
5+
- added arguments `--min-version` and `--squash-patches` for more control over `--git-tags` mode
6+
37
## v0.16.0 - 2024-01-28
48

59
- added multi-version mode argument `--git-tags`

README.md

+13-4
Original file line numberDiff line numberDiff line change
@@ -69,14 +69,16 @@ Poxy is a command-line application.
6969
```
7070
usage: poxy [-h] [-v] [--html | --no-html] [--ppinclude <regex>] [--ppexclude <regex>]
7171
[--theme {light,dark,custom}] [--threads N] [--version] [--xml | --no-xml]
72-
[--werror | --no-werror] [--bug-report] [--git-tags] [config]
72+
[--werror | --no-werror] [--bug-report] [--git-tags]
73+
[--squash-patches | --no-squash-patches] [--min-version <version>]
74+
[config]
7375
7476
_ __ _____ ___ _
7577
| '_ \ / _ \ \/ / | | |
7678
| |_) | (_) > <| |_| |
7779
| .__/ \___/_/\_\\__, |
7880
| | __/ |
79-
|_| |___/ v0.16.0 - github.com/marzer/poxy
81+
|_| |___/ v0.17.0 - github.com/marzer/poxy
8082
8183
Generate fancy C++ documentation.
8284
@@ -88,15 +90,22 @@ options:
8890
-v, --verbose enable very noisy diagnostic output
8991
--html, --no-html specify whether HTML output is required
9092
--ppinclude <regex> pattern matching HTML file names to post-process (default: all)
91-
--ppexclude <regex> pattern matching HTML file names to exclude from post-processing (default: none)
93+
--ppexclude <regex> pattern matching HTML file names to exclude from post-processing (default: None)
9294
--theme {light,dark,custom}
9395
sets the default visual theme (default: read from config)
9496
--threads N set the number of threads to use (default: automatic)
9597
--version print the version and exit
9698
--xml, --no-xml specify whether XML output is required
97-
--werror, --no-werror treat warnings as errors (default: read from config)
99+
--werror, --no-werror
100+
treat warnings as errors (default: read from config)
98101
--bug-report captures all output in a zip file for easier bug reporting.
99102
--git-tags add git-tag-based semver version switcher to the generated HTML
103+
--squash-patches, --no-squash-patches
104+
when using --git-tags and two version tags differ by a patch number,
105+
generate docs for the highest one only (default: True)
106+
--min-version <version>
107+
sets the minimum version number to emit when using --git-tags,
108+
or a negative integer to mean "the last N versions". (default: None)
100109
```
101110

102111
The basic three-step to using Poxy is similar to Doxygen:

src/poxy/main.py

+44-3
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def multi_version_git_tags(args: argparse.Namespace):
141141
tags = sorted(tags, key=lambda t: t[1], reverse=True)
142142
tags.insert(0, (default_branch, (999999, 999999, 999999, 999999)))
143143

144-
if 0:
144+
if args.squash_patches:
145145
# squash patch/rev differences
146146
seen_versions = set()
147147
for i in range(len(tags)):
@@ -152,14 +152,42 @@ def multi_version_git_tags(args: argparse.Namespace):
152152
seen_versions.add(normalized_version)
153153
tags = [t for t in tags if t]
154154

155+
if args.min_version is not None:
156+
args.min_version = re.sub(r'[ \t]+', '', str(args.min_version).strip())
157+
m = re.fullmatch(r'^[vV]?([0-9]+)(?:[.]([0-9]+)(?:[.]([0-9]+)(?:[.]([0-9]+))?)?)?$', args.min_version)
158+
if m:
159+
min_ver = (
160+
(int(m[1] if m[1] else 0)),
161+
(int(m[2] if m[2] else 0)),
162+
(int(m[3] if m[3] else 0)),
163+
(int(m[4] if m[4] else 0)),
164+
)
165+
tags = [t for t in tags if t[1] >= min_ver]
166+
else:
167+
try:
168+
max_vers = int(args.min_version)
169+
assert max_vers < 0
170+
tags = tags[:-max_vers]
171+
except:
172+
raise Error(rf'min-version: expected semver tag or negative integer')
173+
155174
tags = [t for t, _ in tags]
156175
print("Versions:")
157176
print("\n".join([rf' {t}' for t in tags]))
158177

159178
worker_args = [
160179
arg
161180
for arg in sys.argv[1:]
162-
if arg not in (r'--bug-report', r'--git-tags', r'--worker', r'--versions-in-navbar', r'--verbose', r'-v')
181+
if arg
182+
not in (
183+
r'--bug-report',
184+
r'--git-tags',
185+
r'--worker',
186+
r'--versions-in-navbar',
187+
r'--verbose',
188+
r'-v',
189+
r'--higest-patch-only',
190+
)
163191
]
164192
for key in (r'--output-dir', r'--temp-dir', r'--copy-config-to'):
165193
pos = -1
@@ -430,7 +458,7 @@ def main(invoker=True):
430458
type=str,
431459
default=None,
432460
metavar=r'<regex>',
433-
help=r"pattern matching HTML file names to exclude from post-processing (default: none)",
461+
help=r"pattern matching HTML file names to exclude from post-processing (default: %(default)s)",
434462
)
435463
args.add_argument(
436464
r'--theme', #
@@ -456,6 +484,19 @@ def main(invoker=True):
456484
args.add_argument(
457485
r'--git-tags', action=r'store_true', help=r"add git-tag-based semver version switcher to the generated HTML" #
458486
)
487+
make_boolean_optional_arg(
488+
args,
489+
r'squash-patches',
490+
default=True,
491+
help='when using --git-tags and two version tags differ by a patch number,\ngenerate docs for the highest one only (default: %(default)s)',
492+
)
493+
args.add_argument(
494+
r'--min-version',
495+
type=str,
496+
default=None,
497+
metavar='<version>',
498+
help='sets the minimum version number to emit when using --git-tags,\nor a negative integer to mean "the last N versions". (default: %(default)s)',
499+
)
459500

460501
# --------------------------------------------------------------
461502
# hidden/developer-only/deprecated/diagnostic arguments

src/poxy/version.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.16.0
1+
0.17.0

0 commit comments

Comments
 (0)