From f0c512575eb3b780eee5d807964be4574ae3bb53 Mon Sep 17 00:00:00 2001 From: Emma Date: Sat, 7 Sep 2024 12:33:57 -0400 Subject: [PATCH] Add Love2D API generation flag option to make docs target --- .gitignore | 1 + Makefile | 2 +- docs/packaging.md | 11 +++++++++++ tools/get-docs.fnl | 15 +++++++++------ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index bb0ce15..003a793 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ /result /lua*.html /build +/src/fennel-ls/docs/generated/love2d.fnl diff --git a/Makefile b/Makefile index 3bd85a5..87a539e 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ repl: $(FENNEL) $(FENNELFLAGS) docs: - $(FENNEL) $(FENNELFLAGS) tools/get-docs.fnl + $(FENNEL) $(FENNELFLAGS) tools/get-docs.fnl $(GET_DOCS_FLAGS) rm-docs: rm -rf src/fennel-ls/docs/ diff --git a/docs/packaging.md b/docs/packaging.md index b4dab70..e193068 100644 --- a/docs/packaging.md +++ b/docs/packaging.md @@ -21,6 +21,17 @@ $ make rm-docs $ make docs ``` +## Including LÖVE documentation +Due to license incompatibility between fennel-ls and the official LÖVE +documentation, this repository cannot include the LÖVE documentation by +default. It must be generated manually. + +This can be done by passing a flag to the `docs` target. + +```sh +$ make docs GET_DOCS_FLAGS=--generate-love2d +``` + ## Vendored Dependencies The vendored dependencies are very easy to solve. You delete the dependency files by running `make rm-deps`. diff --git a/tools/get-docs.fnl b/tools/get-docs.fnl index a09bbc2..498d0b5 100644 --- a/tools/get-docs.fnl +++ b/tools/get-docs.fnl @@ -27,9 +27,9 @@ (fn main [] (sh :mkdir :-p :build/) (sh :mkdir :-p :src/fennel-ls/docs/generated/) - (let [{:convert lua-manual} (require :tools.get-docs.lua-manual) - {:convert tic80-manual} (require :tools.get-docs.tic80) - {:convert download-and-convert-love2d-manual!} (require :tools.get-docs.love2d)] + (let [generate-love2d-docs? (case arg [:--generate-love2d] true _ false) + {:convert lua-manual} (require :tools.get-docs.lua-manual) + {:convert tic80-manual} (require :tools.get-docs.tic80)] (derive-docs-from-url "https://www.lua.org/manual/5.1/manual.html" :lua51.fnl lua-manual) (derive-docs-from-url "https://www.lua.org/manual/5.2/manual.html" @@ -39,8 +39,11 @@ (derive-docs-from-url "https://www.lua.org/manual/5.4/manual.html" :lua54.fnl lua-manual) (derive-docs-from-url "https://tic80.com/learn" :tic80.fnl tic80-manual) - (write-doc-file! :love2d.fnl - "https://github.com/love2d-community/love-api/" - (download-and-convert-love2d-manual!)))) + (when generate-love2d-docs? + (let [{:convert download-and-convert-love2d-manual!} (require :tools.get-docs.love2d)] + (print "generating Love2D docs...") + (write-doc-file! :love2d.fnl + "https://github.com/love2d-community/love-api/" + (download-and-convert-love2d-manual!)))))) (main)