Skip to content

Commit 2c907a2

Browse files
committed
fix: target dir header & update make docs
1 parent 647102f commit 2c907a2

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

makefile

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
# Define variables
2-
TARGET_DIR=docs
3-
KATEX_HEADER=../docs/katex.html
4-
DOCS_DIR=bintensors
2+
ROOT_DIR := $(shell pwd)
3+
TARGET_DIR := $(ROOT_DIR)/../docs
4+
KATEX_HEADER := $(ROOT_DIR)/docs/katex.html
5+
DOCS_DIR := $(ROOT_DIR)/bintensors
56

67
# Ensure the target directory exists
78
$(TARGET_DIR):
89
mkdir -p $(TARGET_DIR)
910

10-
# Generate documentation for bintensors with a custom header
11-
docs: $(TARGET_DIR)
12-
cd $(DOCS_DIR) && \
13-
RUSTDOCFLAGS="--html-in-header=$(KATEX_HEADER)" cargo doc --no-deps --target-dir=$(TARGET_DIR)
11+
# Make sure the KaTeX header exists before trying to use it
12+
$(KATEX_HEADER):
13+
@echo "Error: KaTeX header file not found at $(KATEX_HEADER)"
14+
@exit 1
1415

15-
docs-open: $(TARGET_DIR)
16+
# Base documentation command
17+
define docs_command
1618
cd $(DOCS_DIR) && \
17-
RUSTDOCFLAGS="--html-in-header=$(KATEX_HEADER)" cargo doc --no-deps --target-dir=$(TARGET_DIR) --open
19+
RUSTDOCFLAGS="--html-in-header=$(KATEX_HEADER)" cargo doc --no-deps --target-dir=$(TARGET_DIR) $(1)
20+
endef
21+
22+
# Generate documentation for bintensors with a custom header
23+
docs: $(TARGET_DIR) $(KATEX_HEADER)
24+
$(call docs_command)
1825

19-
# Clean docs
20-
clean:
21-
rm -rf $(TARGET_DIR)
26+
# Generate and open documentation
27+
docs-open: $(TARGET_DIR) $(KATEX_HEADER)
28+
$(call docs_command,--open)
2229

23-
.PHONY: docs clean
30+
.PHONY: docs docs-open

0 commit comments

Comments
 (0)