Skip to content

Commit 4fe96d9

Browse files
committed
remove zsh dependency; prettify makefile doc presentation
1 parent f8d628a commit 4fe96d9

File tree

2 files changed

+30
-35
lines changed

2 files changed

+30
-35
lines changed

Makefile

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66
.DEFAULT_GOAL := help
77
default: help
88

9-
ifeq ("","$(shell command -v zsh)")
10-
$(error "zsh not found; you must install zsh first")
11-
endif
12-
SHELL:=zsh -eu -o pipefail -o null_glob
13-
149
COLOR_RESET=\033[0m
1510
COLOR_CYAN_BOLD=\033[1;36m
1611
define INFO_MESSAGE
@@ -22,8 +17,7 @@ endef
2217

2318
.PHONY: help
2419
help: ## Display help message
25-
@uvx python -c "import re; \
26-
[[print(f'✦ \033[36m{m[0]:<20}\033[0m {m[1]}') for m in re.findall(r'^([\sa-zA-Z_-]+):.*?## (.*)$$', open(makefile).read(), re.M)] for makefile in ('$(MAKEFILE_LIST)').strip().split()]" | sort
20+
@./sbin/makefile-extract-documentation ${MAKEFILE_LIST}
2721

2822
############################################################################
2923
#= SETUP, INSTALLATION, PACKAGING
@@ -42,6 +36,12 @@ build: ## Build package
4236
rm -fr dist
4337
uv build
4438

39+
.PHONY: publish
40+
publish: build ## publish package to PyPI
41+
$(call INFO_MESSAGE, "Publishing package")
42+
uv publish # Requires UV_PUBLISH_TOKEN or Trusted Publishing setup
43+
44+
4545
############################################################################
4646
#= FORMATTING, TESTING, AND CODE QUALITY
4747

@@ -78,14 +78,15 @@ docs-test: ## Test if documentation can be built without warnings or errors
7878
.PHONY: clean
7979
clean: ## Remove temporary and backup files
8080
$(call INFO_MESSAGE, "Remove temporary and backup files")
81-
rm -frv **/*~ **/*.bak
81+
find . \( -name "*~" -o -name "*.bak" \) -exec rm -frv {} +
8282

8383
.PHONY: cleaner
8484
cleaner: clean ## Remove files and directories that are easily rebuilt
8585
$(call INFO_MESSAGE, "Remove files and directories that are easily rebuilt")
8686
rm -frv .cache .DS_Store .pytest_cache .ruff_cache build coverage.xml dist docs/_build site
87-
rm -frv **/*.pyc **/__pycache__ **/*.egg-info
88-
rm -frv **/*.orig **/*.rej
87+
find . \( -name __pycache__ -type d \) -exec rm -frv {} +
88+
find . \( -name "*.pyc" -o -name "*.egg-info" \) -exec rm -frv {} +
89+
find . \( -name "*.orig" -o -name "*.rej" \) -exec rm -frv {} +
8990

9091
.PHONY: cleanest
9192
cleanest: cleaner ## Remove all files that can be rebuilt
Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
1-
#!/usr/bin/env perl
2-
# makefile-extract-documentation -- extract doc from a makefile
1+
#!/usr/bin/env python
2+
"""extract doc from a makefile"""
33

4-
# This script prints the header, up to the first empty line AND prints
5-
# line starting with #=, and indented by an optional number of >.
4+
# ############################################################################
5+
# #= BASIC USAGE
6+
#
7+
# .PHONY: help
8+
# help: ## Display help message
69

7-
my $print = 1;
8-
while (<>) {
9-
next if ($. == 1 and m/^\#!/);
10-
print if ($print or s/^\#=([>]*)\s+/' ' x length($1)/e);
11-
$print = 0 if m/^$/;
12-
}
10+
import fileinput
11+
import re
1312

13+
BOLD = "\033[1m"
14+
UNDERLINE = "\033[4m"
15+
SECTION_COLOR = "\033[93m"
16+
RESET = "\033[0m"
17+
COMMAND_COLOR = "\033[36m"
1418

15-
# <LICENSE>
16-
# Copyright 2021 Reece Hart ([email protected])
17-
#
18-
# Licensed under the Apache License, Version 2.0 (the "License");
19-
# you may not use this file except in compliance with the License.
20-
# You may obtain a copy of the License at
21-
#
22-
# http://www.apache.org/licenses/LICENSE-2.0
23-
#
24-
# Unless required by applicable law or agreed to in writing, software
25-
# distributed under the License is distributed on an "AS IS" BASIS,
26-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27-
# See the License for the specific language governing permissions and
28-
# limitations under the License.
29-
# </LICENSE>
19+
for line in fileinput.input(): # noqa: SIM115
20+
if m := re.match(r"#= (.+)", line):
21+
print(f"\n{BOLD}{UNDERLINE}{SECTION_COLOR}{m.group(1)}{RESET}")
22+
elif m := re.match(r"([-\s\w]+):.+?##\s+(.+)", line):
23+
print(f"{BOLD}{COMMAND_COLOR}{m.group(1):<20}{RESET}{m.group(2)}")

0 commit comments

Comments
 (0)