Skip to content

Commit 26eed70

Browse files
authored
infra: Optimize Makefile for Better Usability and Maintenance (langchain-ai#18859)
**Previous screenshots:** ![image](https://github.com/langchain-ai/langchain/assets/86140903/e2f326e3-4d97-4b22-aacb-e789a9d815e4) **Current screenshot:** ![image](https://github.com/langchain-ai/langchain/assets/86140903/bd8a3ea7-1b8a-4803-9168-df45f6fa4893)
1 parent 51baa1b commit 26eed70

File tree

1 file changed

+22
-27
lines changed

1 file changed

+22
-27
lines changed

Makefile

+22-27
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,71 @@
1-
.PHONY: all clean docs_build docs_clean docs_linkcheck api_docs_build api_docs_clean api_docs_linkcheck
1+
.PHONY: all clean help docs_build docs_clean docs_linkcheck api_docs_build api_docs_clean api_docs_linkcheck spell_check spell_fix lint lint_package lint_tests format format_diff
22

3-
# Default target executed when no arguments are given to make.
3+
## help: Show this help info.
4+
help: Makefile
5+
@printf "\n\033[1mUsage: make <TARGETS> ...\033[0m\n\n\033[1mTargets:\033[0m\n\n"
6+
@sed -n 's/^##//p' $< | awk -F':' '{printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | sort | sed -e 's/^/ /'
7+
8+
## all: Default target, shows help.
49
all: help
510

11+
## clean: Clean documentation and API documentation artifacts.
12+
clean: docs_clean api_docs_clean
613

714
######################
815
# DOCUMENTATION
916
######################
1017

11-
clean: docs_clean api_docs_clean
12-
13-
18+
## docs_build: Build the documentation.
1419
docs_build:
1520
docs/.local_build.sh
1621

22+
## docs_clean: Clean the documentation build artifacts.
1723
docs_clean:
1824
@if [ -d _dist ]; then \
19-
rm -r _dist; \
20-
echo "Directory _dist has been cleaned."; \
25+
rm -r _dist; \
26+
echo "Directory _dist has been cleaned."; \
2127
else \
22-
echo "Nothing to clean."; \
28+
echo "Nothing to clean."; \
2329
fi
2430

31+
## docs_linkcheck: Run linkchecker on the documentation.
2532
docs_linkcheck:
2633
poetry run linkchecker _dist/docs/ --ignore-url node_modules
2734

35+
## api_docs_build: Build the API Reference documentation.
2836
api_docs_build:
2937
poetry run python docs/api_reference/create_api_rst.py
3038
cd docs/api_reference && poetry run make html
3139

40+
## api_docs_clean: Clean the API Reference documentation build artifacts.
3241
api_docs_clean:
3342
find ./docs/api_reference -name '*_api_reference.rst' -delete
3443
cd docs/api_reference && poetry run make clean
3544

45+
## api_docs_linkcheck: Run linkchecker on the API Reference documentation.
3646
api_docs_linkcheck:
3747
poetry run linkchecker docs/api_reference/_build/html/index.html
3848

49+
## spell_check: Run codespell on the project.
3950
spell_check:
4051
poetry run codespell --toml pyproject.toml
4152

53+
## spell_fix: Run codespell on the project and fix the errors.
4254
spell_fix:
4355
poetry run codespell --toml pyproject.toml -w
4456

4557
######################
4658
# LINTING AND FORMATTING
4759
######################
4860

61+
## lint: Run linting on the project.
4962
lint lint_package lint_tests:
5063
poetry run ruff docs templates cookbook
5164
poetry run ruff format docs templates cookbook --diff
5265
poetry run ruff --select I docs templates cookbook
5366
git grep 'from langchain import' docs/docs templates cookbook | grep -vE 'from langchain import (hub)' && exit 1 || exit 0
5467

68+
## format: Format the project files.
5569
format format_diff:
5670
poetry run ruff format docs templates cookbook
5771
poetry run ruff --select I --fix docs templates cookbook
58-
59-
60-
######################
61-
# HELP
62-
######################
63-
64-
help:
65-
@echo '===================='
66-
@echo '-- DOCUMENTATION --'
67-
@echo 'clean - run docs_clean and api_docs_clean'
68-
@echo 'docs_build - build the documentation'
69-
@echo 'docs_clean - clean the documentation build artifacts'
70-
@echo 'docs_linkcheck - run linkchecker on the documentation'
71-
@echo 'api_docs_build - build the API Reference documentation'
72-
@echo 'api_docs_clean - clean the API Reference documentation build artifacts'
73-
@echo 'api_docs_linkcheck - run linkchecker on the API Reference documentation'
74-
@echo 'spell_check - run codespell on the project'
75-
@echo 'spell_fix - run codespell on the project and fix the errors'
76-
@echo '-- TEST and LINT tasks are within libs/*/ per-package --'

0 commit comments

Comments
 (0)