Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
129 lines (107 loc) · 3.97 KB
/
Copy pathMakefile
File metadata and controls
129 lines (107 loc) · 3.97 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
SHELL:=/usr/bin/env bash
.DEFAULT_GOAL:=help
PROJECT_NAME = "obsidian.nvim"
TEST = test/obsidian
# Depending on your setup you have to override the locations at runtime. E.g.:
# make user-docs
MINITEST = deps/mini.test
MINIDOC = deps/mini.doc
MARKDOC = deps/markdoc.nvim
NVIM_TREESITTER = deps/nvim-treesitter
QUARTZ = deps/quartz
QUARTZ_REV = d25a6eabf96751ffca56f8a8139272def7a65041
NVIM ?= nvim
VIMRUNTIME ?= $(shell $(NVIM) --clean --headless +'lua io.write(vim.env.VIMRUNTIME)' +q 2>/dev/null)
################################################################################
##@ Start here
.PHONY: chores
chores: style lint types test ## Run development tasks (lint, style, types, test); PRs must pass this.
################################################################################
##@ Development
.PHONY: lint
lint: ## Lint the code with selene and typos
selene --config selene/config.toml lua/ tests/
typos lua
.PHONY: style
style: ## Format the code with stylua
stylua --check .
.PHONY: types
types: ## Type check with EmmyLua
VIMRUNTIME=$(VIMRUNTIME) emmylua_check ./lua/ --config .emmyrc.json --warnings-as-errors
.PHONY: test
test: $(MINITEST)
nvim --headless --clean --noplugin -u ./scripts/minimal_init.lua -c "lua MiniTest.run()"
$(MINITEST):
mkdir -p deps
git clone --filter=blob:none https://github.com/echasnovski/mini.test $(MINITEST)
$(MARKDOC):
mkdir -p deps
git clone --filter=blob:none https://github.com/OXY2DEV/markdoc.nvim $(MARKDOC)
$(NVIM_TREESITTER):
mkdir -p deps
git clone --filter=blob:none https://github.com/nvim-treesitter/nvim-treesitter $(NVIM_TREESITTER) --branch main
.PHONY: user-docs
user-docs: $(MARKDOC) $(NVIM_TREESITTER) ## Generate user documentation with markdoc
nvim \
--headless \
--clean \
-u "scripts/markdoc.lua" \
-c "qa!"
.PHONY: api-docs
api-docs: $(MINIDOC) ## Generate API documentation with mini.doc
MINIDOC=$(MINIDOC) nvim \
--headless \
--noplugin \
-c "luafile scripts/generate_api_docs.lua" \
-c "qa!"
.PHONY: docgen
docgen: ## Generate configuration reference from annotations
nvim \
--headless \
--noplugin \
-c "luafile scripts/generate_docs.lua" \
-c "qa!"
$(MINIDOC):
git clone --depth 1 https://github.com/echasnovski/mini.doc $(MINIDOC)
$(QUARTZ)/.git:
mkdir -p $(QUARTZ)
git -C $(QUARTZ) init
git -C $(QUARTZ) remote add origin https://github.com/jackyzha0/quartz.git
$(QUARTZ)/.revision-$(QUARTZ_REV): | $(QUARTZ)/.git
git -C $(QUARTZ) fetch --depth 1 origin $(QUARTZ_REV)
git -C $(QUARTZ) checkout --force --detach $(QUARTZ_REV)
rm -f $(QUARTZ)/.revision-*
touch $@
$(QUARTZ)/.npm-installed: $(QUARTZ)/.revision-$(QUARTZ_REV)
cd $(QUARTZ) && npm ci
touch $@
.PHONY: docs-site docs-serve
##@ Documentation
docs-site: $(QUARTZ)/.npm-installed ## Build the Quartz site from Markdown in docs/
cp quartz.config.ts $(QUARTZ)/quartz.config.ts
rm -rf $(QUARTZ)/content
mkdir -p $(QUARTZ)/content
cp -R docs/. $(QUARTZ)/content/
cp docs/Home.md $(QUARTZ)/content/index.md
rm -rf $(QUARTZ)/content/.obsidian
cd $(QUARTZ) && npx quartz build
docs-serve: $(QUARTZ)/.npm-installed ## Serve the Quartz site locally
cp quartz.config.ts $(QUARTZ)/quartz.config.ts
rm -rf $(QUARTZ)/content
mkdir -p $(QUARTZ)/content
cp -R docs/. $(QUARTZ)/content/
cp docs/Home.md $(QUARTZ)/content/index.md
rm -rf $(QUARTZ)/content/.obsidian
cd $(QUARTZ) && npx quartz build --serve --port 9876
################################################################################
##@ Helpers
.PHONY: version
version: ## Print the obsidian.nvim version
@nvim --headless -c 'lua io.write("v" .. require("obsidian").VERSION)' -c q 2>&1
.PHONY: help
help: ## Display this help
@echo "Welcome to $$(tput bold)${PROJECT_NAME}$$(tput sgr0) 🥳📈🎉"
@echo ""
@echo "To get started:"
@echo " >>> $$(tput bold)make chores$$(tput sgr0)"
@awk 'BEGIN {FS = ":.*##"; printf "\033[36m\033[0m"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)