-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMAKEFILE
More file actions
289 lines (252 loc) · 8.63 KB
/
Copy pathMAKEFILE
File metadata and controls
289 lines (252 loc) · 8.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# tenets Development Makefile
# Simplifies common development tasks
.PHONY: help install dev install-light install-ml install-viz test lint format clean build docs docs-serve docs-deploy docs-build release viz
# Default target
help:
@echo "tenets Development Commands:"
@echo ""
@echo "Installation:"
@echo " make install - Install tenets in production mode"
@echo " make dev - Install tenets in development mode with all extras"
@echo " make install-light - Install with light NLP features (RAKE, TF-IDF)"
@echo " make install-ml - Install with ML features (ranking, summarization)"
@echo " make install-viz - Install with visualization features"
@echo ""
@echo "Testing & Quality:"
@echo " make test - Run all tests"
@echo " make test-fast - Run tests excluding slow ones"
@echo " make test-ranking - Run ranking tests"
@echo " make test-summary - Run summarization tests"
@echo " make lint - Run all linters"
@echo " make format - Auto-format code"
@echo ""
@echo "Documentation:"
@echo " make docs - Build and serve docs locally (http://localhost:8000)"
@echo " make docs-build - Build docs to site/ directory"
@echo " make docs-serve - Serve docs with live reload"
@echo " make docs-deploy - Deploy docs to GitHub Pages (requires permissions)"
@echo ""
@echo "Visualization:"
@echo " make viz-deps - Visualize project dependencies"
@echo " make viz-complex - Visualize code complexity"
@echo ""
@echo "Build & Release:"
@echo " make build - Build distribution packages"
@echo " make clean - Remove build artifacts"
@echo " make release - Create a new release (interactive)"
# Install production dependencies
install:
pip install --upgrade pip
pip install -e .
# Install development environment
dev:
pip install --upgrade pip
pip install -e ".[all,dev,test]"
pip install mkdocs mkdocs-material mkdocs-material-extensions
pip install pymdown-extensions mkdocs-minify-plugin
pre-commit install
pre-commit install --hook-type commit-msg
pre-commit install --hook-type push
@echo "✓ Development environment ready!"
# Install with light NLP features (RAKE, TF-IDF, etc.)
install-light:
pip install --upgrade pip
pip install -e ".[light]"
@echo "✓ Light NLP features installed (RAKE keyword extraction, TF-IDF ranking)"
# Install with ML features
install-ml:
pip install --upgrade pip
pip install -e ".[ml]"
@echo "✓ ML features installed (advanced ranking & summarization)"
# Install with visualization features
install-viz:
pip install --upgrade pip
pip install -e ".[viz]"
@echo "✓ Visualization features installed"
# Run all tests
test:
pytest -v --cov=tenets --cov-report=term-missing --cov-report=html
# Run fast tests only
test-fast:
pytest -v -m "not slow" --cov=tenets
# Run ranking tests
test-ranking:
pytest -v tests/test_ranking/ --cov=tenets.core.ranking
# Run summarization tests
test-summary:
pytest -v tests/test_summarizer/ --cov=tenets.core.summarizer
# Run visualization tests
test-viz:
pytest -v tests/test_viz/ --cov=tenets.viz
# Run specific test file
test-file:
@read -p "Test file path: " filepath; \
pytest -v $$filepath
# Run all linters
lint:
@echo "Running black..."
black --check --diff .
@echo "\nRunning isort..."
isort --check-only --diff .
@echo "\nRunning ruff..."
ruff check .
@echo "\nRunning mypy..."
mypy tenets --strict || true
@echo "\nRunning bandit..."
bandit -r tenets -ll
@echo "\nRunning safety..."
safety check || true
@echo "\n✓ All linting checks complete!"
# Auto-format code
format:
@echo "Running autoflake..."
autoflake --in-place --remove-all-unused-imports --recursive tenets tests
@echo "Running isort..."
isort .
@echo "Running black..."
black .
@echo "Running ruff with fixes..."
ruff check --fix .
@echo "\n✓ Code formatting complete!"
# Clean build artifacts
clean:
rm -rf build/
rm -rf dist/
rm -rf site/
rm -rf *.egg-info
rm -rf .coverage
rm -rf htmlcov/
rm -rf .pytest_cache/
rm -rf .mypy_cache/
rm -rf .ruff_cache/
rm -rf .tenets/ # Clean tenets cache
find . -type d -name __pycache__ -exec rm -rf {} +
find . -type f -name "*.pyc" -delete
find . -type f -name "*.pyo" -delete
@echo "✓ Cleaned all build artifacts!"
# Build distribution packages
build: clean
python -m build
twine check dist/*
@echo "\n✓ Build complete! Packages in dist/"
# Documentation commands
docs: docs-serve
# Build documentation to site/ directory
docs-build:
@echo "Building documentation..."
mkdocs build --strict
@echo "\n✓ Documentation built in site/"
@echo "Open site/index.html in your browser to view"
# Serve documentation locally with live reload
docs-serve:
@echo "Starting documentation server..."
@echo "Documentation will be available at http://localhost:8000"
@echo "Press Ctrl+C to stop"
mkdocs serve --dev-addr localhost:8000 --livereload
# Serve documentation in dev mode (no API generation, faster for styling/content updates)
docs-dev:
@echo "Starting documentation server in DEV MODE (no API generation)..."
@echo "Documentation will be available at http://localhost:8000"
@echo "Press Ctrl+C to stop"
@echo "NOTE: API docs will not be generated/updated in this mode"
mkdocs serve --dev-addr localhost:8000 --livereload --dirtyreload
# Deploy documentation to GitHub Pages
docs-deploy:
@echo "Deploying documentation to GitHub Pages..."
@echo "This will push to the gh-pages branch"
@read -p "Continue? [y/N] " confirm; \
if [ "$$confirm" = "y" ]; then \
mkdocs gh-deploy --force --message "Deploy docs from Makefile"; \
echo "\n✓ Documentation deployed to https://tenets.dev/docs"; \
else \
echo "Deployment cancelled"; \
fi
# Install documentation dependencies only
docs-deps:
pip install mkdocs mkdocs-material mkdocs-material-extensions
pip install pymdown-extensions mkdocs-minify-plugin
@echo "✓ Documentation dependencies installed!"
# Check documentation for issues
docs-check:
mkdocs build --strict 2>&1 | grep -E "WARNING|ERROR" || echo "✓ No documentation issues found!"
# Visualization: show project dependencies
viz-deps:
@echo "Generating dependency graph..."
tenets viz deps . --output deps.html --format html
@echo "✓ Dependency graph saved to deps.html"
# Visualization: show code complexity
viz-complex:
@echo "Generating complexity heatmap..."
tenets viz complexity . --output complexity.html --threshold 10
@echo "✓ Complexity heatmap saved to complexity.html"
# Run pre-commit on all files
pre-commit:
pre-commit run --all-files
# Create a new release (interactive)
release:
@echo "Creating a new release..."
@echo "Current version: $$(grep version pyproject.toml | head -1 | cut -d'"' -f2)"
@echo "\nThis will:"
@echo "1. Run all tests"
@echo "2. Update version numbers"
@echo "3. Update CHANGELOG.md"
@echo "4. Create a git commit and tag"
@echo "5. Push to GitHub (triggering release workflow)"
@echo ""
@read -p "Continue? [y/N] " confirm; \
if [ "$$confirm" = "y" ]; then \
make test && \
cz bump && \
git push && \
git push --tags; \
fi
# Install git hooks
install-hooks:
pre-commit install --install-hooks
@echo "✓ Git hooks installed!"
# Update dependencies
update-deps:
pip install --upgrade pip pip-tools
pip-compile --upgrade pyproject.toml
@echo "✓ Dependencies updated!"
# Run security checks
security:
bandit -r tenets -f json -o security-report.json
safety check --json --output safety-report.json || true
@echo "✓ Security reports generated!"
# Profile code performance
profile:
@read -p "Script to profile: " script; \
python -m cProfile -o profile.stats $$script
python -m pstats profile.stats
# Generate coverage badge
coverage-badge:
coverage-badge -o assets/coverage.svg -f
@echo "✓ Coverage badge generated!"
# Quick commit with commitizen
commit:
cz commit
# Check commit history
check-commits:
cz check --rev-range origin/master..HEAD
# Show project statistics
stats:
@echo "Project Statistics:"
@echo "==================="
@echo "Lines of code:"
@find tenets -name "*.py" -type f -exec wc -l {} + | tail -1
@echo "\nNumber of Python files:"
@find tenets -name "*.py" -type f | wc -l
@echo "\nNumber of tests:"
@find tests -name "test_*.py" -type f -exec grep -E "def test_" {} + | wc -l || echo "0"
@echo "\nTODO items:"
@grep -r "TODO" tenets tests --include="*.py" | wc -l || echo "0"
@echo "\nRanking strategies:"
@ls -1 tenets/core/ranking/strategies.py | wc -l || echo "4"
@echo "\nSummarization strategies:"
@ls -1 tenets/core/summarizer/strategies.py | wc -l || echo "5"
# Create example configuration
example-config:
@cp .tenets.example.yml .tenets.yml
@echo "✓ Created .tenets.yml from example"
@echo "Edit .tenets.yml to customize your configuration"