forked from langchain-ai/langchain
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
infra: Optimize Makefile for Better Usability and Maintenance (langch…
…ain-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)
- Loading branch information
Showing
1 changed file
with
22 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,71 @@ | ||
.PHONY: all clean docs_build docs_clean docs_linkcheck api_docs_build api_docs_clean api_docs_linkcheck | ||
.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 | ||
|
||
# Default target executed when no arguments are given to make. | ||
## help: Show this help info. | ||
help: Makefile | ||
@printf "\n\033[1mUsage: make <TARGETS> ...\033[0m\n\n\033[1mTargets:\033[0m\n\n" | ||
@sed -n 's/^##//p' $< | awk -F':' '{printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' | sort | sed -e 's/^/ /' | ||
|
||
## all: Default target, shows help. | ||
all: help | ||
|
||
## clean: Clean documentation and API documentation artifacts. | ||
clean: docs_clean api_docs_clean | ||
|
||
###################### | ||
# DOCUMENTATION | ||
###################### | ||
|
||
clean: docs_clean api_docs_clean | ||
|
||
|
||
## docs_build: Build the documentation. | ||
docs_build: | ||
docs/.local_build.sh | ||
|
||
## docs_clean: Clean the documentation build artifacts. | ||
docs_clean: | ||
@if [ -d _dist ]; then \ | ||
rm -r _dist; \ | ||
echo "Directory _dist has been cleaned."; \ | ||
rm -r _dist; \ | ||
echo "Directory _dist has been cleaned."; \ | ||
else \ | ||
echo "Nothing to clean."; \ | ||
echo "Nothing to clean."; \ | ||
fi | ||
|
||
## docs_linkcheck: Run linkchecker on the documentation. | ||
docs_linkcheck: | ||
poetry run linkchecker _dist/docs/ --ignore-url node_modules | ||
|
||
## api_docs_build: Build the API Reference documentation. | ||
api_docs_build: | ||
poetry run python docs/api_reference/create_api_rst.py | ||
cd docs/api_reference && poetry run make html | ||
|
||
## api_docs_clean: Clean the API Reference documentation build artifacts. | ||
api_docs_clean: | ||
find ./docs/api_reference -name '*_api_reference.rst' -delete | ||
cd docs/api_reference && poetry run make clean | ||
|
||
## api_docs_linkcheck: Run linkchecker on the API Reference documentation. | ||
api_docs_linkcheck: | ||
poetry run linkchecker docs/api_reference/_build/html/index.html | ||
|
||
## spell_check: Run codespell on the project. | ||
spell_check: | ||
poetry run codespell --toml pyproject.toml | ||
|
||
## spell_fix: Run codespell on the project and fix the errors. | ||
spell_fix: | ||
poetry run codespell --toml pyproject.toml -w | ||
|
||
###################### | ||
# LINTING AND FORMATTING | ||
###################### | ||
|
||
## lint: Run linting on the project. | ||
lint lint_package lint_tests: | ||
poetry run ruff docs templates cookbook | ||
poetry run ruff format docs templates cookbook --diff | ||
poetry run ruff --select I docs templates cookbook | ||
git grep 'from langchain import' docs/docs templates cookbook | grep -vE 'from langchain import (hub)' && exit 1 || exit 0 | ||
|
||
## format: Format the project files. | ||
format format_diff: | ||
poetry run ruff format docs templates cookbook | ||
poetry run ruff --select I --fix docs templates cookbook | ||
|
||
|
||
###################### | ||
# HELP | ||
###################### | ||
|
||
help: | ||
@echo '====================' | ||
@echo '-- DOCUMENTATION --' | ||
@echo 'clean - run docs_clean and api_docs_clean' | ||
@echo 'docs_build - build the documentation' | ||
@echo 'docs_clean - clean the documentation build artifacts' | ||
@echo 'docs_linkcheck - run linkchecker on the documentation' | ||
@echo 'api_docs_build - build the API Reference documentation' | ||
@echo 'api_docs_clean - clean the API Reference documentation build artifacts' | ||
@echo 'api_docs_linkcheck - run linkchecker on the API Reference documentation' | ||
@echo 'spell_check - run codespell on the project' | ||
@echo 'spell_fix - run codespell on the project and fix the errors' | ||
@echo '-- TEST and LINT tasks are within libs/*/ per-package --' |