-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
117 lines (87 loc) · 4.72 KB
/
Makefile
File metadata and controls
117 lines (87 loc) · 4.72 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
# The OCaml release version to generate the docset for.
# (The default value set here is the latest that docset generation has been verified to work for).
OCAML_VERSION ?= 5.4
OCAML_RELEASE_URL = https://ocaml.org/releases/$(OCAML_VERSION)
DOWNLOADS_PATH = downloads
GENERATED_PATH = generated
SCRIPTS_PATH = scripts
MANUAL_BASENAME = ocaml-$(OCAML_VERSION)-refman-html.tar.gz
MANUAL_URL = $(OCAML_RELEASE_URL)/$(MANUAL_BASENAME)
MANUAL_PACKED_PATH = $(DOWNLOADS_PATH)/$(MANUAL_BASENAME)
MANUAL_UNPACKED_PATH = $(DOWNLOADS_PATH)/$(OCAML_VERSION)
MANUAL_CONTAINER_BASENAME = htmlman
DOCSET_BASENAME_NO_EXT = ocaml-unofficial
DOCSET_PATH = $(GENERATED_PATH)/$(DOCSET_BASENAME_NO_EXT).docset
DOCSET_CONTENTS_PATH = $(DOCSET_PATH)/Contents
DOCSET_RESOURCES_PATH = $(DOCSET_CONTENTS_PATH)/Resources
DOCSET_INDEXDB_PATH = $(DOCSET_RESOURCES_PATH)/docSet.dsidx
DOCSET_DOCUMENTS_PATH = $(DOCSET_RESOURCES_PATH)/Documents
DOCSET_READABLE_NAME = OCaml (Unofficial)
DOCSET_SEARCH_KEYWORD = ocaml
DOCSET_MAIN_PAGE = $(MANUAL_CONTAINER_BASENAME)/index.html
DOCSET_INFO_PATH = $(DOCSET_CONTENTS_PATH)/Info.plist
DOCSET_ARCHIVE_PATH = $(GENERATED_PATH)/$(DOCSET_BASENAME_NO_EXT).tgz
# See ./scripts/deno-deploy/main.ts
ONLINE_PAGE_BASE_URL = https://ocaml-docset-redirector.deno.holm.scot/$(OCAML_VERSION)/
STASHED_INDEXDB_PATH = prev.db
GLOBAL_PYTHON_INVOCATION = python3
PYTHON_VENV_PATH = .venv
PYTHON_VENV_ACTIVATE = . $(PYTHON_VENV_PATH)/bin/activate
PYTHON_INVOCATION = python
# @todo Rename scripts directory to src/generator and src/backend
# @→ And put a README in the latter saying the reason this directory contains multiple implementations of the same thing, is that this is a nice small task I can use to try out different "serverless" providers.
# @→ Use a NOTE alert https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts
# @→ Try SvelteKit on CloudflareWorkers or Vercel?
# ------------------------------------------------------------
# The archive is for (optional) distribution: https://kapeli.com/docsets#dashdocsetfeed
# @todo Use a GitHub Action to generate the docset serverside and provide an XML feed
# @→ Use this for inspiration? https://github.com/aiotter/deno_api_docset/tree/master/.github/workflows
# @→ Also https://github.com/michaelblyons/SublimeText-DashDoc/actions/runs/13080174561/workflow
$(DOCSET_ARCHIVE_PATH): docset
tar --directory $(dir $(DOCSET_PATH)) --exclude=.DS_Store -czf $@ $(notdir $(DOCSET_PATH))
docset: $(MANUAL_UNPACKED_PATH) $(PYTHON_VENV_PATH)
# Copy the HTML manual into the docset
mkdir -p $(DOCSET_DOCUMENTS_PATH)
cp -a $(MANUAL_UNPACKED_PATH)/$(MANUAL_CONTAINER_BASENAME) $(DOCSET_DOCUMENTS_PATH)
@echo
# Index the HTML manual, and insert anchor tags to enable page-level ToCs
$(PYTHON_VENV_ACTIVATE) && $(PYTHON_INVOCATION) $(SCRIPTS_PATH)/index_manual.py $(DOCSET_DOCUMENTS_PATH) $(DOCSET_INDEXDB_PATH)
@echo
# Create the Property List file that describes the docset
$(PYTHON_VENV_ACTIVATE) && $(PYTHON_INVOCATION) $(SCRIPTS_PATH)/describe_docset.py $(DOCSET_BASENAME_NO_EXT) "$(DOCSET_READABLE_NAME)" $(DOCSET_SEARCH_KEYWORD) $(DOCSET_MAIN_PAGE) $(ONLINE_PAGE_BASE_URL) $(DOCSET_INFO_PATH)
docset-debug: PYTHON_INVOCATION += -m pdb
docset-debug: docset
$(MANUAL_UNPACKED_PATH): $(MANUAL_PACKED_PATH)
mkdir -p $@
tar xf $< -C $@
$(MANUAL_PACKED_PATH):
mkdir -p $(DOWNLOADS_PATH)
curl --fail -L -o $@ $(MANUAL_URL)
$(PYTHON_VENV_PATH):
$(GLOBAL_PYTHON_INVOCATION) -m venv $@
$(PYTHON_VENV_ACTIVATE) && pip install 'beautifulsoup4 ~= 4.14'
# ------------------------------------------------------------
stash-db:
cp $(DOCSET_INDEXDB_PATH) $(STASHED_INDEXDB_PATH)
compare-dbs: $(STASHED_INDEXDB_PATH) $(DOCSET_INDEXDB_PATH)
$(SCRIPTS_PATH)/compare_dbs $^
# ------------------------------------------------------------
clean: clean-generated
@echo
@echo "Only generated files were removed. Run 'make clean-all' if you also want to remove downloaded files and the Python virtual environment."
clean-generated:
rm -rf $(GENERATED_PATH)
clean-all: clean-generated
rm -rf $(DOWNLOADS_PATH)
rm -rf $(PYTHON_VENV_PATH)
# ------------------------------------------------------------
# NOTE: This is a convenience to open an editor whose Python LSP should pick up the separate
# venv in the nested directory (instead of the venv at the top-level of the repo).
edit-gcp: EDITOR_ASYNC ?= $(EDITOR)
edit-gcp: scripts/gcp
$(EDITOR_ASYNC) $< $</main.py
# ------------------------------------------------------------
.PHONY: docset docset-debug \
stash-db compare-dbs \
clean clean-generated clean-all \
edit-gcp