From 0e7bfea494444875d11ee93f9eae3cefab07abc1 Mon Sep 17 00:00:00 2001 From: Yi-Te Huang Date: Tue, 24 Sep 2024 15:43:20 +0800 Subject: [PATCH] add Makefile --- .github/workflows/FormatCheck.yml | 2 +- Makefile | 21 +++++++++++++++++++++ docs/README.md | 15 ++++++++++++--- 3 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 Makefile diff --git a/.github/workflows/FormatCheck.yml b/.github/workflows/FormatCheck.yml index 7063e805..5e60d9fc 100644 --- a/.github/workflows/FormatCheck.yml +++ b/.github/workflows/FormatCheck.yml @@ -46,6 +46,6 @@ jobs: write(stdout, output) write(stdout, "-----\n") write(stdout, "Please format them by running the following command:\n") - write(stdout, "julia -e \"using JuliaFormatter; format(\\\".\\\")\"") + write(stdout, "make format") exit(1) end' \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..920c480f --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +JULIA:=julia + +default: help + +docs: + ${JULIA} --project=docs -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' + ${JULIA} --project=docs docs/make.jl + +format: + ${JULIA} -e 'using JuliaFormatter; format(".")' + +test: + ${JULIA} --project -e 'using Pkg; Pkg.resolve(); Pkg.test()' + +help: + @echo "The following make commands are available:" + @echo " - make docs: instantiate and build the documentation" + @echo " - make format: format codes with JuliaFormatter" + @echo " - make test: run the tests" + +.PHONY: default docs format test help \ No newline at end of file diff --git a/docs/README.md b/docs/README.md index 7c5a0d9a..3d5ab58f 100644 --- a/docs/README.md +++ b/docs/README.md @@ -3,16 +3,25 @@ ## Working Directory All the commands should be run under the root folder of the package: `/path/to/HierarchicalEOM.jl/` -## Build Pkg +The document pages will be generated in the directory: `/path/to/HierarchicalEOM.jl/docs/build/` (which is ignored by git). + +## Method 1: Run with `make` command +Run the following command: +```shell +make docs +``` + +## Method 2: Run `julia` command manually + +### Build Pkg Run the following command: ```shell julia --project=docs -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()' ``` > **_NOTE:_** `Pkg.develop(PackageSpec(path=pwd()))` adds the local version of `HierarchicalEOM` as dev-dependency instead of pulling from the registered version. -## Build Documentation +### Build Documentation Run the following command: ```shell julia --project=docs docs/make.jl ``` -The document pages will be generated in the directory: `/path/to/HierarchicalEOM.jl/docs/build/` (which is ignored by git).