From 751058189fa0bacda9ff369f5aee9165a4346400 Mon Sep 17 00:00:00 2001 From: xonix Date: Mon, 4 Mar 2024 00:46:38 +0200 Subject: [PATCH 01/32] Create site with documentation #164 --- mdbooker.awk | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 mdbooker.awk diff --git a/mdbooker.awk b/mdbooker.awk new file mode 100644 index 0000000..f7f82eb --- /dev/null +++ b/mdbooker.awk @@ -0,0 +1,30 @@ +BEGIN { + OUTDIR = "book" + SUMMARY = OUTDIR "/SUMMARY.md" + printf "" > SUMMARY + H = 0 + Title = "" + Content = "" +} + +/^# / { handleTitle(1); next } +/^## / { handleTitle(2); next } +/^### / { handleTitle(3); next } +/^#### / { print "error: ####"; exit 1 } +{ Content = Content $0 "\n"; next } + +function handleTitle(h, md) { + if (Title) { + md = Title ".md" + print "generating: " md "..." + print Content > md + printf "%" ((H - 1) * 4) "s%s[%s](%s)\n", "", 1 == H ? "" : "-", Title, md >> SUMMARY + } + H = h + Title = trim(substr($0, h)) + Content = "" +} + +END { handleTitle(-1) } + +function trim(s) { sub(/^[ \t\r\n]+/, "", s); sub(/[ \t\r\n]+$/, "", s); return s } From 338ead5a3a1f863a1a411a9f90e9a7723feaaf27 Mon Sep 17 00:00:00 2001 From: xonix Date: Mon, 4 Mar 2024 00:52:16 +0200 Subject: [PATCH 02/32] Create site with documentation #164 --- README.md | 2 +- mdbooker.awk | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0e300e3..8bb584f 100644 --- a/README.md +++ b/README.md @@ -694,7 +694,7 @@ echo 'Please reopen the shell to activate completion.' Find some contributor instructions in [DEVELOPER.md](docs/DEVELOPER.md). -#### AWK +### AWK The core of this tool is implemented in [AWK](https://en.wikipedia.org/wiki/AWK). Almost all major implementations of AWK will work. Tested and officially supported are [Gawk](https://www.gnu.org/software/gawk/), [BWK](https://github.com/onetrueawk/awk), [mawk](https://invisible-island.net/mawk/). This means that the default AWK implementation in your OS will work. diff --git a/mdbooker.awk b/mdbooker.awk index f7f82eb..fa87341 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -2,6 +2,7 @@ BEGIN { OUTDIR = "book" SUMMARY = OUTDIR "/SUMMARY.md" printf "" > SUMMARY + N = 0 H = 0 Title = "" Content = "" @@ -15,13 +16,14 @@ BEGIN { function handleTitle(h, md) { if (Title) { - md = Title ".md" + N++ + md = (N < 10 ? "0": "") N "_" Title ".md" print "generating: " md "..." - print Content > md + print Content > OUTDIR "/" md printf "%" ((H - 1) * 4) "s%s[%s](%s)\n", "", 1 == H ? "" : "-", Title, md >> SUMMARY } H = h - Title = trim(substr($0, h)) + Title = trim(substr($0, h+1)) Content = "" } From c91601cdc760588137ae79e01fd7dec33487fcd1 Mon Sep 17 00:00:00 2001 From: xonix Date: Mon, 4 Mar 2024 01:02:54 +0200 Subject: [PATCH 03/32] Create site with documentation #164 --- mdbooker.awk | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mdbooker.awk b/mdbooker.awk index fa87341..625a14c 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -14,16 +14,21 @@ BEGIN { /^#### / { print "error: ####"; exit 1 } { Content = Content $0 "\n"; next } -function handleTitle(h, md) { +function handleTitle(h, md,indent,fname) { if (Title) { N++ - md = (N < 10 ? "0": "") N "_" Title ".md" + fname = Title + gsub(/ /, "_", fname) + md = (N < 10 ? "0" : "") N "_" fname ".md" print "generating: " md "..." print Content > OUTDIR "/" md - printf "%" ((H - 1) * 4) "s%s[%s](%s)\n", "", 1 == H ? "" : "-", Title, md >> SUMMARY + indent = H - 2 + if (indent < 0) + indent = 0 + printf "%" (indent * 4) "s%s[%s](%s)\n", "", 1 == H ? "" : "-", Title, md >> SUMMARY } H = h - Title = trim(substr($0, h+1)) + Title = trim(substr($0, h + 1)) Content = "" } From bd8c70c2942333531e31d97744372444c6cb1484 Mon Sep 17 00:00:00 2001 From: xonix Date: Mon, 4 Mar 2024 01:22:49 +0200 Subject: [PATCH 04/32] Create site with documentation #164 --- mdbooker.awk | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/mdbooker.awk b/mdbooker.awk index 625a14c..9f8083a 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -1,8 +1,7 @@ BEGIN { - OUTDIR = "book" - SUMMARY = OUTDIR "/SUMMARY.md" + BOOK = "book" + SUMMARY = BOOK "/SUMMARY.md" printf "" > SUMMARY - N = 0 H = 0 Title = "" Content = "" @@ -16,16 +15,16 @@ BEGIN { function handleTitle(h, md,indent,fname) { if (Title) { - N++ fname = Title gsub(/ /, "_", fname) - md = (N < 10 ? "0" : "") N "_" fname ".md" + md = fname ".md" print "generating: " md "..." - print Content > OUTDIR "/" md + print "# " Title > BOOK "/" md + print Content >> BOOK "/" md indent = H - 2 if (indent < 0) indent = 0 - printf "%" (indent * 4) "s%s[%s](%s)\n", "", 1 == H ? "" : "-", Title, md >> SUMMARY + printf "%" (indent * 4) "s%s[%s](%s)\n", "", 1 == H ? "" : "- ", Title, md >> SUMMARY } H = h Title = trim(substr($0, h + 1)) From 930c2b989c46eee5a37e79ed7ede57c45660d8d1 Mon Sep 17 00:00:00 2001 From: xonix Date: Mon, 4 Mar 2024 22:06:19 +0200 Subject: [PATCH 05/32] Create site with documentation #164 --- mdbooker.awk | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/mdbooker.awk b/mdbooker.awk index 9f8083a..310b002 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -5,6 +5,7 @@ BEGIN { H = 0 Title = "" Content = "" + delete PathElements } /^# / { handleTitle(1); next } @@ -13,24 +14,28 @@ BEGIN { /^#### / { print "error: ####"; exit 1 } { Content = Content $0 "\n"; next } -function handleTitle(h, md,indent,fname) { +function handleTitle(h, md,indent,dir,i,path) { if (Title) { - fname = Title - gsub(/ /, "_", fname) - md = fname ".md" - print "generating: " md "..." - print "# " Title > BOOK "/" md - print Content >> BOOK "/" md + md = fname(Title) ".md" + dir = "" + for (i=2; i BOOK "/" path + print Content >> BOOK "/" path indent = H - 2 if (indent < 0) indent = 0 - printf "%" (indent * 4) "s%s[%s](%s)\n", "", 1 == H ? "" : "- ", Title, md >> SUMMARY + printf "%" (indent * 4) "s%s[%s](%s)\n", "", 1 == H ? "" : "- ", Title, path >> SUMMARY } - H = h - Title = trim(substr($0, h + 1)) + PathElements[H = h] = Title = trim(substr($0, h + 1)) Content = "" } END { handleTitle(-1) } +function fname(s) { gsub(/ /, "_", s); return s } function trim(s) { sub(/^[ \t\r\n]+/, "", s); sub(/[ \t\r\n]+$/, "", s); return s } From a28a07e01e6a51e28c59268b66da6c9d969797b4 Mon Sep 17 00:00:00 2001 From: xonix Date: Mon, 4 Mar 2024 22:23:25 +0200 Subject: [PATCH 06/32] Create site with documentation #164 --- README.md | 94 ++++++++++++++++++++++++++-------------------------- mdbooker.awk | 3 +- 2 files changed, 49 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 8bb584f..23c2e02 100644 --- a/README.md +++ b/README.md @@ -221,7 +221,7 @@ Example: ### @goal -Syntax #1: +#### Simple goal ``` @goal goal_name [ @private ] ``` @@ -254,7 +254,7 @@ Invoking `./makesure` without arguments will attempt to call the goal named `def echo "I'm default goal" ``` -Syntax #2: +#### Glob goal ``` @goal [ goal_name ] @glob [ @private ] ``` @@ -320,16 +320,16 @@ to be able to run each test individually (`./makesure test2.js` for example) and In case if you need to glob the files with spaces in their names, please check the [naming rules section](#naming-rules) below. -### Parameterized goals +#### Parameterized goal Make code easier to reuse. Declaration syntax (using `@params`): -```shell +```sh @goal goal_name @params A B C ``` Usage syntax (using `@args`): -```shell +```sh @goal other_goal @params PARAM @depends_on goal_name @args 'value1' 'value 2' PARAM ``` @@ -338,7 +338,7 @@ The idea of using two complementary keywords `@params` + `@args` was inspired by Example: -```shell +```sh @goal file_downloaded @params FILE_NAME echo "Downloading $FILE_NAME..." @@ -397,7 +397,7 @@ Note, the goal's body parameter values will appear as environment variables (as Note, you can reference the `@define`-ed variables in the arguments of the parameterized goals: -```shell +```sh @define HELLO 'hello' @goal parameterized_goal @params ARG @@ -425,6 +425,45 @@ Please find a more real-world example [here](https://github.com/xonixx/fhtagn/bl For more technical consideration regarding this feature see [parameterized_goals.md](docs/parameterized_goals.md). +#### Naming rules + +It's *recommended* that you name your goals using alphanumeric chars + underscore. + +However, it's possible to name a goal any way you want provided that you apply proper escaping: + +```sh +@goal 'name with spaces' # all chars between '' have literal meaning, same as in shell, ' itself is not allowed in it + +@goal $'name that contains \' single quote' # if you need to have ' in a string, use dollar-strings and escape it + +@goal usual_name +``` + +Now `./makesure -l` gives: +``` +Available goals: + 'name with spaces' + $'name that contains \' single quote' + usual_name +``` + +Note, how goal names are already escaped in output. This is to make it easier for you to call it directly: +```sh +./makesure $'name that contains \' single quote' +``` + +Same naming rules apply to other directives (like `@doc`). + +Usually you won't need this escaping tricks often, but they can be especially in use for `@glob` goals if the relevant files have spaces in them: + +```sh +@goal @glob 'file\ with\ spaces*.txt' +@goal other + @depends_on 'file with spaces1.txt' +``` + +More info on this topic is covered in the [issue](https://github.com/xonixx/makesure/issues/63). + ### @doc Only valid: inside `@goal`. @@ -614,49 +653,10 @@ Only valid: inside `@goal`. Only single `@use_lib` per goal is allowed. -### Naming rules - -It's *recommended* that you name your goals using alphanumeric chars + underscore. - -However, it's possible to name a goal any way you want provided that you apply proper escaping: - -```sh -@goal 'name with spaces' # all chars between '' have literal meaning, same as in shell, ' itself is not allowed in it - -@goal $'name that contains \' single quote' # if you need to have ' in a string, use dollar-strings and escape it - -@goal usual_name -``` - -Now `./makesure -l` gives: -``` -Available goals: - 'name with spaces' - $'name that contains \' single quote' - usual_name -``` - -Note, how goal names are already escaped in output. This is to make it easier for you to call it directly: -```sh -./makesure $'name that contains \' single quote' -``` - -Same naming rules apply to other directives (like `@doc`). - -Usually you won't need this escaping tricks often, but they can be especially in use for `@glob` goals if the relevant files have spaces in them: - -```sh -@goal @glob 'file\ with\ spaces*.txt' -@goal other - @depends_on 'file with spaces1.txt' -``` - -More info on this topic is covered in the [issue](https://github.com/xonixx/makesure/issues/63). - ## Bash completion Install Bash completion for `./makesure` locally -```shell +```sh [[ ! -f ~/.bash_completion ]] && touch ~/.bash_completion grep makesure ~/.bash_completion >/dev/null || echo '. ~/.makesure_completion.bash' >> ~/.bash_completion curl "https://raw.githubusercontent.com/xonixx/makesure/main/completion.bash?token=$(date +%s)" -o ~/.makesure_completion.bash diff --git a/mdbooker.awk b/mdbooker.awk index 310b002..b4eff63 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -11,7 +11,8 @@ BEGIN { /^# / { handleTitle(1); next } /^## / { handleTitle(2); next } /^### / { handleTitle(3); next } -/^#### / { print "error: ####"; exit 1 } +/^#### / { handleTitle(4); next } +/^#####/ { print "error: #####"; exit 1 } { Content = Content $0 "\n"; next } function handleTitle(h, md,indent,dir,i,path) { From af557f281611f811949ed204fa87110f2d537ec4 Mon Sep 17 00:00:00 2001 From: xonix Date: Mon, 4 Mar 2024 22:27:47 +0200 Subject: [PATCH 07/32] Create site with documentation #164 --- book.toml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 book.toml diff --git a/book.toml b/book.toml new file mode 100644 index 0000000..6c05967 --- /dev/null +++ b/book.toml @@ -0,0 +1,14 @@ +[book] +#language = "en" +#src = "src" +src = "book" +title = "Makesure Manual" + +[build] +build-dir = "build" + +[output.html] +git-repository-url = "https://github.com/xonixx/makesure" +#site-url = "/" + +#[output.linkcheck] \ No newline at end of file From e4b8f787679c570e4317136fc66501f4f44d8811 Mon Sep 17 00:00:00 2001 From: xonix Date: Tue, 5 Mar 2024 02:38:02 +0200 Subject: [PATCH 08/32] Create site with documentation #164 --- mdbooker.awk | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/mdbooker.awk b/mdbooker.awk index b4eff63..36faf53 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -1,10 +1,7 @@ BEGIN { - BOOK = "book" - SUMMARY = BOOK "/SUMMARY.md" - printf "" > SUMMARY + printf "" > (SUMMARY = (BOOK = "book/") "SUMMARY.md") H = 0 - Title = "" - Content = "" + Title = Content = "" delete PathElements } @@ -17,18 +14,14 @@ BEGIN { function handleTitle(h, md,indent,dir,i,path) { if (Title) { - md = fname(Title) ".md" - dir = "" - for (i=2; i BOOK "/" path - print Content >> BOOK "/" path - indent = H - 2 - if (indent < 0) + print "generating: " (path = dir (dir ? "/" : "") (md = fname(Title) ".md")) "..." + if (dir) + system("mkdir -p '" BOOK dir "'") + print "# " Title > BOOK path + print Content >> BOOK path + if ((indent = H - 2) < 0) indent = 0 printf "%" (indent * 4) "s%s[%s](%s)\n", "", 1 == H ? "" : "- ", Title, path >> SUMMARY } From 52277d3d72b67b54638bac9add80822e7aac29b3 Mon Sep 17 00:00:00 2001 From: xonix Date: Tue, 5 Mar 2024 02:44:43 +0200 Subject: [PATCH 09/32] Create site with documentation #164 --- mdbooker.awk | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/mdbooker.awk b/mdbooker.awk index 36faf53..5f24e02 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -10,7 +10,7 @@ BEGIN { /^### / { handleTitle(3); next } /^#### / { handleTitle(4); next } /^#####/ { print "error: #####"; exit 1 } -{ Content = Content $0 "\n"; next } +{ Content = Content "\n" $0; next } function handleTitle(h, md,indent,dir,i,path) { if (Title) { @@ -19,14 +19,12 @@ function handleTitle(h, md,indent,dir,i,path) { print "generating: " (path = dir (dir ? "/" : "") (md = fname(Title) ".md")) "..." if (dir) system("mkdir -p '" BOOK dir "'") - print "# " Title > BOOK path - print Content >> BOOK path + print Content > BOOK path if ((indent = H - 2) < 0) indent = 0 printf "%" (indent * 4) "s%s[%s](%s)\n", "", 1 == H ? "" : "- ", Title, path >> SUMMARY } - PathElements[H = h] = Title = trim(substr($0, h + 1)) - Content = "" + Content = "# " (Title = PathElements[H = h] = trim(substr($0, h + 1))) } END { handleTitle(-1) } From b7e7900eac93fc2ef160df95f6b9b55dba8c299f Mon Sep 17 00:00:00 2001 From: xonix Date: Tue, 5 Mar 2024 02:48:30 +0200 Subject: [PATCH 10/32] Create site with documentation #164 --- mdbooker.awk | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mdbooker.awk b/mdbooker.awk index 5f24e02..475c12d 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -5,11 +5,7 @@ BEGIN { delete PathElements } -/^# / { handleTitle(1); next } -/^## / { handleTitle(2); next } -/^### / { handleTitle(3); next } -/^#### / { handleTitle(4); next } -/^#####/ { print "error: #####"; exit 1 } +match($0, /^#+/) { handleTitle(RLENGTH); next } { Content = Content "\n" $0; next } function handleTitle(h, md,indent,dir,i,path) { From c0a822e9964c891b62d70a17f589fe7cc1e88041 Mon Sep 17 00:00:00 2001 From: xonix Date: Tue, 5 Mar 2024 02:55:30 +0200 Subject: [PATCH 11/32] Create site with documentation #164 --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 23c2e02..a1e81ea 100644 --- a/README.md +++ b/README.md @@ -711,19 +711,19 @@ Developed in [xonixx/intellij-awk](https://github.com/xonixx/intellij-awk). ## Similar tools -- **just** https://github.com/casey/just `Rust` +- **just** [https://github.com/casey/just](https://github.com/casey/just) `Rust` - just is a handy way to save and run project-specific commands -- **Taskfile** https://github.com/adriancooney/Taskfile `Bash` +- **Taskfile** [https://github.com/adriancooney/Taskfile](https://github.com/adriancooney/Taskfile) `Bash` - A Taskfile is a bash \[...] script that follows a specific format \[...], sits in the root of your project \[...] and contains the tasks to build your project. -- **Task** https://github.com/go-task/task `Go` +- **Task** [https://github.com/go-task/task](https://github.com/go-task/task) `Go` - Task is a task runner / build tool that aims to be simpler and easier to use than, for example, GNU Make. -- **mmake** https://github.com/tj/mmake `Go` +- **mmake** [https://github.com/tj/mmake](https://github.com/tj/mmake) `Go` - Modern Make is a small program which wraps `make` to provide additional functionality -- **Robo** https://github.com/tj/robo `Go` +- **Robo** [https://github.com/tj/robo](https://github.com/tj/robo) `Go` - Simple Go / YAML-based task runner for the team -- **haku** https://github.com/VladimirMarkelov/haku `Rust` +- **haku** [https://github.com/VladimirMarkelov/haku](https://github.com/VladimirMarkelov/haku) `Rust` - A task/command runner inspired by 'make' -- **Invoke-Build** https://github.com/nightroman/Invoke-Build `PowerShell` +- **Invoke-Build** [https://github.com/nightroman/Invoke-Build](https://github.com/nightroman/Invoke-Build) `PowerShell` - Build Automation in PowerShell -- **make** https://www.gnu.org/software/make/ `C` +- **make** [https://www.gnu.org/software/make/](https://www.gnu.org/software/make/) `C` - \[...] a tool which controls the generation of executables and other non-source files of a program from the program's source files. From 5d879fc009271e97686f6f63f101a10e6bd4243b Mon Sep 17 00:00:00 2001 From: xonix Date: Wed, 6 Mar 2024 02:06:04 +0200 Subject: [PATCH 12/32] Create site with documentation #164 --- mdbooker.awk | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/mdbooker.awk b/mdbooker.awk index 475c12d..d7adb5f 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -11,10 +11,8 @@ match($0, /^#+/) { handleTitle(RLENGTH); next } function handleTitle(h, md,indent,dir,i,path) { if (Title) { for (i = 2; i < H; i++) - dir = dir (dir ? "/" : "") fname(PathElements[i]) - print "generating: " (path = dir (dir ? "/" : "") (md = fname(Title) ".md")) "..." - if (dir) - system("mkdir -p '" BOOK dir "'") + dir = dir (dir ? "-" : "") fname(PathElements[i]) + print "generating: " (path = dir (dir ? "-" : "") (md = fname(Title) ".md")) "..." print Content > BOOK path if ((indent = H - 2) < 0) indent = 0 From 8380ddc357de0a861659d954e4ce357eec45432b Mon Sep 17 00:00:00 2001 From: xonix Date: Wed, 6 Mar 2024 02:25:05 +0200 Subject: [PATCH 13/32] Create site with documentation #164 : fix #links --- mdbooker.awk | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/mdbooker.awk b/mdbooker.awk index d7adb5f..31886ed 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -3,25 +3,39 @@ BEGIN { H = 0 Title = Content = "" delete PathElements + delete Link2Path } -match($0, /^#+/) { handleTitle(RLENGTH); next } -{ Content = Content "\n" $0; next } +match($0, /^#+/) { handleTitle(RLENGTH, 1) } -function handleTitle(h, md,indent,dir,i,path) { +function handleTitle(h,pass, md,indent,dir,i,path) { if (Title) { for (i = 2; i < H; i++) dir = dir (dir ? "-" : "") fname(PathElements[i]) - print "generating: " (path = dir (dir ? "-" : "") (md = fname(Title) ".md")) "..." - print Content > BOOK path - if ((indent = H - 2) < 0) - indent = 0 - printf "%" (indent * 4) "s%s[%s](%s)\n", "", 1 == H ? "" : "- ", Title, path >> SUMMARY + path = dir (dir ? "-" : "") (md = fname(Title) ".md") + if (pass == 1) { + Link2Path[linkify(Title)] = path + } else { + print "generating: " path "..." + print Content > BOOK path + if ((indent = H - 2) < 0) + indent = 0 + printf "%" (indent * 4) "s%s[%s](%s)\n", "", 1 == H ? "" : "- ", Title, path >> SUMMARY + } } Content = "# " (Title = PathElements[H = h] = trim(substr($0, h + 1))) } -END { handleTitle(-1) } +END { handleTitle(-1, 1); pass2() } +function pass2() { + while (getline < FILENAME > 0) { + if (match($0, /^#+/)) { handleTitle(RLENGTH, 2) } + else { Content = Content "\n" $0 } + } + handleTitle(-1, 2) +} + +function linkify(t) { t = tolower(t); gsub(/ /, "-", t); gsub(/[^-a-z0-9_]/, "", t); return t } function fname(s) { gsub(/ /, "_", s); return s } function trim(s) { sub(/^[ \t\r\n]+/, "", s); sub(/[ \t\r\n]+$/, "", s); return s } From b924bcf389b526c5de573b2f9ccd2fc34ca22805 Mon Sep 17 00:00:00 2001 From: xonix Date: Wed, 6 Mar 2024 02:42:54 +0200 Subject: [PATCH 14/32] Create site with documentation #164 : fix #links --- mdbooker.awk | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mdbooker.awk b/mdbooker.awk index 31886ed..ebc4196 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -28,10 +28,15 @@ function handleTitle(h,pass, md,indent,dir,i,path) { END { handleTitle(-1, 1); pass2() } -function pass2() { +function pass2( l) { + Title = Content = "" while (getline < FILENAME > 0) { if (match($0, /^#+/)) { handleTitle(RLENGTH, 2) } - else { Content = Content "\n" $0 } + else { + if (match(l = $0, /]\(#[^)]+\)/)) + l = substr(l, 1, RSTART - 1) "](" Link2Path[substr(l, RSTART + 3, RLENGTH - 4)] ")" substr(l, RSTART + RLENGTH) + Content = Content "\n" l + } } handleTitle(-1, 2) } From 40fc41384dd14a4ada80d95256dd7f1a99dc8fe8 Mon Sep 17 00:00:00 2001 From: xonix Date: Wed, 6 Mar 2024 02:46:41 +0200 Subject: [PATCH 15/32] Create site with documentation #164 : fix #links --- mdbooker.awk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mdbooker.awk b/mdbooker.awk index ebc4196..96d9da2 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -31,7 +31,8 @@ END { handleTitle(-1, 1); pass2() } function pass2( l) { Title = Content = "" while (getline < FILENAME > 0) { - if (match($0, /^#+/)) { handleTitle(RLENGTH, 2) } + if (match($0, /^#+/)) + handleTitle(RLENGTH, 2) else { if (match(l = $0, /]\(#[^)]+\)/)) l = substr(l, 1, RSTART - 1) "](" Link2Path[substr(l, RSTART + 3, RLENGTH - 4)] ")" substr(l, RSTART + RLENGTH) From e819df89cabd2d714ca197a42258626002f0aa2e Mon Sep 17 00:00:00 2001 From: xonix Date: Wed, 6 Mar 2024 03:00:24 +0200 Subject: [PATCH 16/32] Create site with documentation #164 : fix #links --- mdbooker.awk | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mdbooker.awk b/mdbooker.awk index 96d9da2..507c430 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -28,14 +28,16 @@ function handleTitle(h,pass, md,indent,dir,i,path) { END { handleTitle(-1, 1); pass2() } -function pass2( l) { +function pass2( l,f,t) { Title = Content = "" while (getline < FILENAME > 0) { if (match($0, /^#+/)) handleTitle(RLENGTH, 2) else { - if (match(l = $0, /]\(#[^)]+\)/)) - l = substr(l, 1, RSTART - 1) "](" Link2Path[substr(l, RSTART + 3, RLENGTH - 4)] ")" substr(l, RSTART + RLENGTH) + if (match(l = $0, /]\(#[^)]+\)/)) { + print " fix link: #" (f=substr(l, RSTART + 3, RLENGTH - 4)) " -> " (t = Link2Path[f]) + l = substr(l, 1, RSTART - 1) "](" t ")" substr(l, RSTART + RLENGTH) + } Content = Content "\n" l } } From 534361419de911cdbba7e77558bc5c37a1d74575 Mon Sep 17 00:00:00 2001 From: xonix Date: Thu, 7 Mar 2024 01:34:34 +0200 Subject: [PATCH 17/32] Create site with documentation #164 : fix relative links --- mdbooker.awk | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mdbooker.awk b/mdbooker.awk index 507c430..3e83cc9 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -1,4 +1,5 @@ BEGIN { + Base = ENVIRON["BASE"] printf "" > (SUMMARY = (BOOK = "book/") "SUMMARY.md") H = 0 Title = Content = "" @@ -35,8 +36,12 @@ function pass2( l,f,t) { handleTitle(RLENGTH, 2) else { if (match(l = $0, /]\(#[^)]+\)/)) { - print " fix link: #" (f=substr(l, RSTART + 3, RLENGTH - 4)) " -> " (t = Link2Path[f]) + print " fix link: #" (f = substr(l, RSTART + 3, RLENGTH - 4)) " -> " (t = Link2Path[f]) l = substr(l, 1, RSTART - 1) "](" t ")" substr(l, RSTART + RLENGTH) + } else if (match(l,/]\([^)]+\)/) && (f = substr(l, RSTART + 2, RLENGTH - 3)) !~ /https?:/) { + print " fix link: " f " -> " (t = Base f) + l = substr(l, 1, RSTART - 1) "](" t ")" substr(l, RSTART + RLENGTH) + print ">>" l } Content = Content "\n" l } From 8f1410bc39f32e5265484ad95b75b7af9915f69d Mon Sep 17 00:00:00 2001 From: xonix Date: Thu, 7 Mar 2024 01:53:44 +0200 Subject: [PATCH 18/32] Create site with documentation #164 : fix img links --- mdbooker.awk | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/mdbooker.awk b/mdbooker.awk index 3e83cc9..86d948a 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -1,5 +1,7 @@ BEGIN { - Base = ENVIRON["BASE"] + Repo = ENVIRON["REPO"] + LinkBase = "https://github.com/" Repo "/blob/main/" + RawBase = "https://github.com/" Repo "/raw/main/" printf "" > (SUMMARY = (BOOK = "book/") "SUMMARY.md") H = 0 Title = Content = "" @@ -36,12 +38,14 @@ function pass2( l,f,t) { handleTitle(RLENGTH, 2) else { if (match(l = $0, /]\(#[^)]+\)/)) { - print " fix link: #" (f = substr(l, RSTART + 3, RLENGTH - 4)) " -> " (t = Link2Path[f]) + print " fix #link: #" (f = substr(l, RSTART + 3, RLENGTH - 4)) " -> " (t = Link2Path[f]) l = substr(l, 1, RSTART - 1) "](" t ")" substr(l, RSTART + RLENGTH) - } else if (match(l,/]\([^)]+\)/) && (f = substr(l, RSTART + 2, RLENGTH - 3)) !~ /https?:/) { - print " fix link: " f " -> " (t = Base f) + } else if (match(l, /]\([^)]+\)/) && (f = substr(l, RSTART + 2, RLENGTH - 3)) !~ /https?:/) { + if (l ~ /!\[/) + print " fix image link: " f " -> " (t = RawBase f) + else + print " fix relative link: " f " -> " (t = LinkBase f) l = substr(l, 1, RSTART - 1) "](" t ")" substr(l, RSTART + RLENGTH) - print ">>" l } Content = Content "\n" l } From eb60fe326038f795ff666cd3a3324e31143529b5 Mon Sep 17 00:00:00 2001 From: xonix Date: Thu, 7 Mar 2024 01:59:32 +0200 Subject: [PATCH 19/32] Create site with documentation #164 --- mdbooker.awk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mdbooker.awk b/mdbooker.awk index 86d948a..98ad0e7 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -11,11 +11,11 @@ BEGIN { match($0, /^#+/) { handleTitle(RLENGTH, 1) } -function handleTitle(h,pass, md,indent,dir,i,path) { +function handleTitle(h,pass, indent,dir,i,path) { if (Title) { for (i = 2; i < H; i++) dir = dir (dir ? "-" : "") fname(PathElements[i]) - path = dir (dir ? "-" : "") (md = fname(Title) ".md") + path = dir (dir ? "-" : "") fname(Title) ".md" if (pass == 1) { Link2Path[linkify(Title)] = path } else { From 76dab65a16a62cc2f2ef1b0fa245085e63953743 Mon Sep 17 00:00:00 2001 From: xonix Date: Thu, 7 Mar 2024 02:01:22 +0200 Subject: [PATCH 20/32] Create site with documentation #164 --- mdbooker.awk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mdbooker.awk b/mdbooker.awk index 98ad0e7..c142474 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -16,9 +16,9 @@ function handleTitle(h,pass, indent,dir,i,path) { for (i = 2; i < H; i++) dir = dir (dir ? "-" : "") fname(PathElements[i]) path = dir (dir ? "-" : "") fname(Title) ".md" - if (pass == 1) { + if (pass == 1) Link2Path[linkify(Title)] = path - } else { + else { print "generating: " path "..." print Content > BOOK path if ((indent = H - 2) < 0) From c8f126207c17e08dfa6caa1c7d3487211573877f Mon Sep 17 00:00:00 2001 From: xonix Date: Thu, 7 Mar 2024 02:10:54 +0200 Subject: [PATCH 21/32] Create site with documentation #164 --- mdbooker.awk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mdbooker.awk b/mdbooker.awk index c142474..5e18906 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -29,7 +29,7 @@ function handleTitle(h,pass, indent,dir,i,path) { Content = "# " (Title = PathElements[H = h] = trim(substr($0, h + 1))) } -END { handleTitle(-1, 1); pass2() } +END { handleTitle(0, 1); pass2() } function pass2( l,f,t) { Title = Content = "" @@ -50,7 +50,7 @@ function pass2( l,f,t) { Content = Content "\n" l } } - handleTitle(-1, 2) + handleTitle(0, 2) } function linkify(t) { t = tolower(t); gsub(/ /, "-", t); gsub(/[^-a-z0-9_]/, "", t); return t } From e38bcedcffe8279435f577d34d0ffcc37e824b65 Mon Sep 17 00:00:00 2001 From: xonix Date: Thu, 7 Mar 2024 02:28:29 +0200 Subject: [PATCH 22/32] Create site with documentation #164 : fill empty articles with link list --- mdbooker.awk | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/mdbooker.awk b/mdbooker.awk index 5e18906..bdaaa57 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -7,6 +7,7 @@ BEGIN { Title = Content = "" delete PathElements delete Link2Path + delete ContentLinks } match($0, /^#+/) { handleTitle(RLENGTH, 1) } @@ -16,20 +17,27 @@ function handleTitle(h,pass, indent,dir,i,path) { for (i = 2; i < H; i++) dir = dir (dir ? "-" : "") fname(PathElements[i]) path = dir (dir ? "-" : "") fname(Title) ".md" - if (pass == 1) + if (pass == 1) { Link2Path[linkify(Title)] = path - else { + if (H > 2) + ContentLinks[PathElements[H - 1]] = ContentLinks[PathElements[H - 1]] Title "\n" + }else { print "generating: " path "..." - print Content > BOOK path + if (!(Content = trim(Content))) { + Content = ContentLinks[Title] + } + print "# " Title > BOOK path + print Content >> BOOK path if ((indent = H - 2) < 0) indent = 0 printf "%" (indent * 4) "s%s[%s](%s)\n", "", 1 == H ? "" : "- ", Title, path >> SUMMARY } } - Content = "# " (Title = PathElements[H = h] = trim(substr($0, h + 1))) + Content = "" + Title = PathElements[H = h] = trim(substr($0, h + 1)) } -END { handleTitle(0, 1); pass2() } +END { handleTitle(0, 1); for (k in ContentLinks) print k "->" ContentLinks[k] ; pass2() } function pass2( l,f,t) { Title = Content = "" From 0dd366e906dda91eb4ee4a8148a0214a9230c2cc Mon Sep 17 00:00:00 2001 From: xonix Date: Thu, 7 Mar 2024 02:32:49 +0200 Subject: [PATCH 23/32] Create site with documentation #164 : fill empty articles with link list --- mdbooker.awk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mdbooker.awk b/mdbooker.awk index bdaaa57..3b04c4b 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -20,8 +20,8 @@ function handleTitle(h,pass, indent,dir,i,path) { if (pass == 1) { Link2Path[linkify(Title)] = path if (H > 2) - ContentLinks[PathElements[H - 1]] = ContentLinks[PathElements[H - 1]] Title "\n" - }else { + ContentLinks[PathElements[H - 1]] = ContentLinks[PathElements[H - 1]] "- [" Title "](" path ")\n" + } else { print "generating: " path "..." if (!(Content = trim(Content))) { Content = ContentLinks[Title] From 07057e8d517f4473daf9eac3862c85e466f643e3 Mon Sep 17 00:00:00 2001 From: xonix Date: Sun, 10 Mar 2024 22:58:35 +0200 Subject: [PATCH 24/32] Create site with documentation #164 : deploy --- Makesurefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makesurefile b/Makesurefile index 6c1490e..1d1cc66 100644 --- a/Makesurefile +++ b/Makesurefile @@ -494,3 +494,9 @@ do print gensub(/#([0-9]+)/,"[\\0](https://github.com/xonixx/makesure/issues/\\1)", "g") }' done + +@goal deploy_site + HOST='xonix@server.maximullaris.com' + DEST="$HOST":/var/www/makesure + + rsync -aP build/ "$DEST/" From b0238cc8fc946692f0e030289c9ce5beb25f44dc Mon Sep 17 00:00:00 2001 From: xonix Date: Mon, 11 Mar 2024 01:48:50 +0200 Subject: [PATCH 25/32] Create site with documentation #164 : pre-content --- mdbooker.awk | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mdbooker.awk b/mdbooker.awk index 3b04c4b..136cd94 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -12,7 +12,8 @@ BEGIN { match($0, /^#+/) { handleTitle(RLENGTH, 1) } -function handleTitle(h,pass, indent,dir,i,path) { +function handleTitle(h,pass, indent,dir,i,path,title) { + title = trim(substr($0, h + 1)) if (Title) { for (i = 2; i < H; i++) dir = dir (dir ? "-" : "") fname(PathElements[i]) @@ -32,9 +33,10 @@ function handleTitle(h,pass, indent,dir,i,path) { indent = 0 printf "%" (indent * 4) "s%s[%s](%s)\n", "", 1 == H ? "" : "- ", Title, path >> SUMMARY } - } + } else + print Content > BOOK fname(title) ".md" # pre-content Content = "" - Title = PathElements[H = h] = trim(substr($0, h + 1)) + Title = PathElements[H = h] = title } END { handleTitle(0, 1); for (k in ContentLinks) print k "->" ContentLinks[k] ; pass2() } From 2eaa2325987d8cb578e9c17c0af9466a7c01f859 Mon Sep 17 00:00:00 2001 From: xonix Date: Sat, 16 Mar 2024 18:32:49 +0200 Subject: [PATCH 26/32] Create site with documentation #164 : installing mdbook --- .gitignore | 3 +++ Makesurefile | 60 +++++++++++++++++++++++++++++++++++++--------------- book.toml | 3 +-- 3 files changed, 47 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 0b71aad..33ff9cf 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,6 @@ soft/ tmp/ + +book/ +build/ diff --git a/Makesurefile b/Makesurefile index 1cd9fc1..697b63e 100644 --- a/Makesurefile +++ b/Makesurefile @@ -5,12 +5,30 @@ @define GOAWK_VERSION '1.25.0' @define JUST_VERSION '1.3.0' @define FHTAGN_VERSION 'v0.1.1' +@define MDBOOK_VERSION 'v0.4.37' # https://github.com/rust-lang/mdBook/releases +@define MDBOOK_LINKCHECK_VERSION 'TODO' @define GOAWK "goawk$GOAWK_VERSION" @define JUST "just$JUST_VERSION" @define FHTAGN_URL "https://github.com/xonixx/fhtagn/raw/$FHTAGN_VERSION/fhtagn.awk" @define REPO 'xonixx/makesure' @define AWK "${AWK:-awk}" +@lib dl + download() { + local url="$1" + local file="$2" + + if command -v wget >/dev/null + then + wget "$url" -O"$file" + elif command -v curl >/dev/null + then + curl -L "$url" -o "$file" + else + false + fi + } + @goal soft_folder_created @private @reached_if [[ -d "soft" ]] mkdir soft @@ -20,27 +38,20 @@ @goal fhtagn_installed @private @depends_on soft_folder_created @reached_if [[ -x "$FHTAGN" ]] - if command -v wget >/dev/null +@use_lib dl + if download "$FHTAGN_URL" "$FHTAGN" then - wget "$FHTAGN_URL" -O"$FHTAGN" - elif command -v curl >/dev/null - then - curl -L "$FHTAGN_URL" -o "$FHTAGN" + chmod +x "$FHTAGN" else echo "can't dl fhtagn" exit 2 fi - chmod +x "$FHTAGN" - -@goal cleaned @private -@goal cleaned_soft @private +@goal cleaned_soft +@doc 'rm soft folder' @reached_if [[ ! -d "soft" ]] rm -r "soft" -@goal cleaned_all @private -@depends_on cleaned cleaned_soft - @lib awk_ver awk_ver() { local key="$1" @@ -237,13 +248,14 @@ @goal installed_bwk @private @reached_if [[ -f soft/bwk ]] @depends_on soft_folder_created +@use_lib dl echo echo "Fetching BWK..." echo cd "soft" - wget https://github.com/onetrueawk/awk/archive/refs/heads/master.tar.gz -Obwk.tar.gz + download https://github.com/onetrueawk/awk/archive/refs/heads/master.tar.gz bwk.tar.gz tar xzvf bwk.tar.gz rm bwk.tar.gz @@ -296,6 +308,7 @@ @goal installed_gawk @params VERSION EXE_NAME @private @reached_if [[ -f soft/"$EXE_NAME" ]] @depends_on soft_folder_created +@use_lib dl echo echo "Fetching Gawk-$VERSION..." echo @@ -315,7 +328,7 @@ # dlFolder="gawk-$VERSION" # tarOpts="xvf" # fi - wget "$dlUrl" + download "$dlUrl" "$G" tar "${tarOpts:-xzvf}" "$G" rm "$G" @@ -358,13 +371,15 @@ @goal installed_busybox @private @reached_if [[ -x ./soft/busybox ]] - wget 'https://busybox.net/downloads/binaries/1.31.0-i686-uclibc/busybox' -O ./soft/busybox +@use_lib dl + download 'https://busybox.net/downloads/binaries/1.31.0-i686-uclibc/busybox' ./soft/busybox chmod +x ./soft/busybox echo "Installed: $(./soft/busybox | head -n 1)" @goal installed_goawk @private @reached_if [[ -f soft/$GOAWK ]] @depends_on soft_folder_created +@use_lib dl echo echo "Fetching GoAWK $GOAWK_VERSION ..." echo @@ -381,7 +396,7 @@ fi F=goawk_v${GOAWK_VERSION}_${os}_amd64.tar.gz - wget "https://github.com/benhoyt/goawk/releases/download/v$GOAWK_VERSION/$F" + download "https://github.com/benhoyt/goawk/releases/download/v$GOAWK_VERSION/$F" "$F" tar xzvf "$F" goawk rm "$F" @@ -418,6 +433,7 @@ @goal installed_just @private @reached_if [[ -f "soft/$JUST" ]] @depends_on soft_folder_created +@use_lib dl echo echo "Fetching Just $JUST_VERSION ..." echo @@ -425,7 +441,7 @@ cd "soft" F=just-$JUST_VERSION-x86_64-unknown-linux-musl.tar.gz - wget "https://github.com/casey/just/releases/download/$JUST_VERSION/$F" + download "https://github.com/casey/just/releases/download/$JUST_VERSION/$F" "$F" tar xzvf "$F" just mv just "$JUST" rm "$F" @@ -495,8 +511,18 @@ do }' done +# === Documentation site === @goal deploy_site HOST='xonix@server.maximullaris.com' DEST="$HOST":/var/www/makesure rsync -aP build/ "$DEST/" + +@goal site_soft_installed @private +@depends_on mdbook_installed +@depends_on mdbook-linkcheck_installed + +@goal mdbook_installed @private + URL="https://github.com/rust-lang/mdBook/releases/download/$MDBOOK_VERSION/mdbook-$MDBOOK_VERSION-x86_64-unknown-linux-musl.tar.gz" + +@goal mdbook-linkcheck_installed @private \ No newline at end of file diff --git a/book.toml b/book.toml index 6c05967..3eafcda 100644 --- a/book.toml +++ b/book.toml @@ -1,6 +1,5 @@ [book] -#language = "en" -#src = "src" +language = "en" src = "book" title = "Makesure Manual" From 8450d7f3293c169b0154b12efa320d283de0ce0b Mon Sep 17 00:00:00 2001 From: xonix Date: Sat, 16 Mar 2024 18:50:28 +0200 Subject: [PATCH 27/32] Create site with documentation #164 : installing mdbook --- Makesurefile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Makesurefile b/Makesurefile index 697b63e..1c06c8b 100644 --- a/Makesurefile +++ b/Makesurefile @@ -522,7 +522,18 @@ done @depends_on mdbook_installed @depends_on mdbook-linkcheck_installed +@define MDBOOK "./soft/mdbook_$MDBOOK_VERSION" + @goal mdbook_installed @private - URL="https://github.com/rust-lang/mdBook/releases/download/$MDBOOK_VERSION/mdbook-$MDBOOK_VERSION-x86_64-unknown-linux-musl.tar.gz" +@reached_if [[ -e "$MDBOOK" ]] +@use_lib dl + F="mdbook-$MDBOOK_VERSION-x86_64-unknown-linux-musl.tar.gz" + URL="https://github.com/rust-lang/mdBook/releases/download/$MDBOOK_VERSION/$F" + ( cd /tmp + download "$URL" "$F" + tar -xzvf "$F" mdbook ) + mv /tmp/mdbook "$MDBOOK" + "$MDBOOK" --version + rm "/tmp/$F" @goal mdbook-linkcheck_installed @private \ No newline at end of file From d574522375b29b682ab530fdb17d2182191e8fea Mon Sep 17 00:00:00 2001 From: xonix Date: Sat, 16 Mar 2024 19:03:28 +0200 Subject: [PATCH 28/32] Create site with documentation #164 : installing mdbook --- Makesurefile | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/Makesurefile b/Makesurefile index 1c06c8b..46bc511 100644 --- a/Makesurefile +++ b/Makesurefile @@ -2,11 +2,12 @@ @options timing @define NEXT_VERSION '0.9.23' -@define GOAWK_VERSION '1.25.0' -@define JUST_VERSION '1.3.0' -@define FHTAGN_VERSION 'v0.1.1' -@define MDBOOK_VERSION 'v0.4.37' # https://github.com/rust-lang/mdBook/releases -@define MDBOOK_LINKCHECK_VERSION 'TODO' +@define GOAWK_VERSION '1.25.0' # https://github.com/benhoyt/goawk/releases +@define JUST_VERSION '1.3.0' # https://github.com/casey/just/releases +@define FHTAGN_VERSION 'v0.1.1' # https://github.com/xonixx/fhtagn/releases +@define MDBOOK_VERSION 'v0.4.37' # https://github.com/rust-lang/mdBook/releases +@define MDBOOK_LINKCHECK_VERSION 'v0.7.7' # https://github.com/Michael-F-Bryan/mdbook-linkcheck/releases + @define GOAWK "goawk$GOAWK_VERSION" @define JUST "just$JUST_VERSION" @define FHTAGN_URL "https://github.com/xonixx/fhtagn/raw/$FHTAGN_VERSION/fhtagn.awk" @@ -523,9 +524,10 @@ done @depends_on mdbook-linkcheck_installed @define MDBOOK "./soft/mdbook_$MDBOOK_VERSION" +@define MDBOOK_LINKCHECK "./soft/mdbook-linkcheck_$MDBOOK_LINKCHECK_VERSION" @goal mdbook_installed @private -@reached_if [[ -e "$MDBOOK" ]] +@reached_if [[ -x "$MDBOOK" ]] @use_lib dl F="mdbook-$MDBOOK_VERSION-x86_64-unknown-linux-musl.tar.gz" URL="https://github.com/rust-lang/mdBook/releases/download/$MDBOOK_VERSION/$F" @@ -536,4 +538,15 @@ done "$MDBOOK" --version rm "/tmp/$F" -@goal mdbook-linkcheck_installed @private \ No newline at end of file +@goal mdbook-linkcheck_installed @private +@reached_if [[ -x "$MDBOOK_LINKCHECK" ]] +@use_lib dl + F="mdbook-linkcheck.x86_64-unknown-linux-gnu.zip" + URL="https://github.com/Michael-F-Bryan/mdbook-linkcheck/releases/download/$MDBOOK_LINKCHECK_VERSION/$F" + ( cd /tmp + download "$URL" "$F" + unzip -p "$F" mdbook-linkcheck >mdbook-linkcheck ) + mv /tmp/mdbook-linkcheck "$MDBOOK_LINKCHECK" + chmod +x "$MDBOOK_LINKCHECK" + "$MDBOOK_LINKCHECK" --version + rm "/tmp/$F" \ No newline at end of file From e27b1f57005609c3fb187ef9410031b859aa9b91 Mon Sep 17 00:00:00 2001 From: xonix Date: Sat, 16 Mar 2024 19:07:09 +0200 Subject: [PATCH 29/32] Create site with documentation #164 : installing mdbook --- Makesurefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makesurefile b/Makesurefile index 46bc511..489e286 100644 --- a/Makesurefile +++ b/Makesurefile @@ -519,6 +519,12 @@ done rsync -aP build/ "$DEST/" +@goal site_compile +@depends_on site_soft_installed + rm -rf book; mkdir book; awk -f mdbooker.awk README.md + "$MDBOOK" build + "$MDBOOK_LINKCHECK" -s # check broken links + @goal site_soft_installed @private @depends_on mdbook_installed @depends_on mdbook-linkcheck_installed From b05b040591194bfb3596b9ed493c79d2c94a491d Mon Sep 17 00:00:00 2001 From: xonix Date: Sat, 16 Mar 2024 19:10:47 +0200 Subject: [PATCH 30/32] Create site with documentation #164 : fill empty articles with link list --- mdbooker.awk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mdbooker.awk b/mdbooker.awk index 136cd94..2b0c4a9 100644 --- a/mdbooker.awk +++ b/mdbooker.awk @@ -39,7 +39,7 @@ function handleTitle(h,pass, indent,dir,i,path,title) { Title = PathElements[H = h] = title } -END { handleTitle(0, 1); for (k in ContentLinks) print k "->" ContentLinks[k] ; pass2() } +END { handleTitle(0, 1); pass2() } function pass2( l,f,t) { Title = Content = "" From 0ef1ffd0d02cc2d9c241975d89acb0eafee16a1e Mon Sep 17 00:00:00 2001 From: xonix Date: Sat, 16 Mar 2024 19:25:01 +0200 Subject: [PATCH 31/32] Create site with documentation #164 : move mdbooker.awk to its own repo --- mdbooker.awk | 68 ---------------------------------------------------- 1 file changed, 68 deletions(-) delete mode 100644 mdbooker.awk diff --git a/mdbooker.awk b/mdbooker.awk deleted file mode 100644 index 2b0c4a9..0000000 --- a/mdbooker.awk +++ /dev/null @@ -1,68 +0,0 @@ -BEGIN { - Repo = ENVIRON["REPO"] - LinkBase = "https://github.com/" Repo "/blob/main/" - RawBase = "https://github.com/" Repo "/raw/main/" - printf "" > (SUMMARY = (BOOK = "book/") "SUMMARY.md") - H = 0 - Title = Content = "" - delete PathElements - delete Link2Path - delete ContentLinks -} - -match($0, /^#+/) { handleTitle(RLENGTH, 1) } - -function handleTitle(h,pass, indent,dir,i,path,title) { - title = trim(substr($0, h + 1)) - if (Title) { - for (i = 2; i < H; i++) - dir = dir (dir ? "-" : "") fname(PathElements[i]) - path = dir (dir ? "-" : "") fname(Title) ".md" - if (pass == 1) { - Link2Path[linkify(Title)] = path - if (H > 2) - ContentLinks[PathElements[H - 1]] = ContentLinks[PathElements[H - 1]] "- [" Title "](" path ")\n" - } else { - print "generating: " path "..." - if (!(Content = trim(Content))) { - Content = ContentLinks[Title] - } - print "# " Title > BOOK path - print Content >> BOOK path - if ((indent = H - 2) < 0) - indent = 0 - printf "%" (indent * 4) "s%s[%s](%s)\n", "", 1 == H ? "" : "- ", Title, path >> SUMMARY - } - } else - print Content > BOOK fname(title) ".md" # pre-content - Content = "" - Title = PathElements[H = h] = title -} - -END { handleTitle(0, 1); pass2() } - -function pass2( l,f,t) { - Title = Content = "" - while (getline < FILENAME > 0) { - if (match($0, /^#+/)) - handleTitle(RLENGTH, 2) - else { - if (match(l = $0, /]\(#[^)]+\)/)) { - print " fix #link: #" (f = substr(l, RSTART + 3, RLENGTH - 4)) " -> " (t = Link2Path[f]) - l = substr(l, 1, RSTART - 1) "](" t ")" substr(l, RSTART + RLENGTH) - } else if (match(l, /]\([^)]+\)/) && (f = substr(l, RSTART + 2, RLENGTH - 3)) !~ /https?:/) { - if (l ~ /!\[/) - print " fix image link: " f " -> " (t = RawBase f) - else - print " fix relative link: " f " -> " (t = LinkBase f) - l = substr(l, 1, RSTART - 1) "](" t ")" substr(l, RSTART + RLENGTH) - } - Content = Content "\n" l - } - } - handleTitle(0, 2) -} - -function linkify(t) { t = tolower(t); gsub(/ /, "-", t); gsub(/[^-a-z0-9_]/, "", t); return t } -function fname(s) { gsub(/ /, "_", s); return s } -function trim(s) { sub(/^[ \t\r\n]+/, "", s); sub(/[ \t\r\n]+$/, "", s); return s } From 5c5301687e7f7816e609fa874ed22b5536c53f1b Mon Sep 17 00:00:00 2001 From: xonix Date: Sat, 16 Mar 2024 20:08:33 +0200 Subject: [PATCH 32/32] Create site with documentation #164 : move mdbooker.awk to its own repo --- Makesurefile | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/Makesurefile b/Makesurefile index 489e286..960c2ed 100644 --- a/Makesurefile +++ b/Makesurefile @@ -7,10 +7,10 @@ @define FHTAGN_VERSION 'v0.1.1' # https://github.com/xonixx/fhtagn/releases @define MDBOOK_VERSION 'v0.4.37' # https://github.com/rust-lang/mdBook/releases @define MDBOOK_LINKCHECK_VERSION 'v0.7.7' # https://github.com/Michael-F-Bryan/mdbook-linkcheck/releases +@define MDBOOKER_VERSION '11572b1' # https://github.com/xonixx/mdbooker/releases @define GOAWK "goawk$GOAWK_VERSION" @define JUST "just$JUST_VERSION" -@define FHTAGN_URL "https://github.com/xonixx/fhtagn/raw/$FHTAGN_VERSION/fhtagn.awk" @define REPO 'xonixx/makesure' @define AWK "${AWK:-awk}" @@ -34,19 +34,15 @@ @reached_if [[ -d "soft" ]] mkdir soft +@define FHTAGN_URL "https://github.com/xonixx/fhtagn/raw/$FHTAGN_VERSION/fhtagn.awk" @define FHTAGN "./soft/fhtagn$FHTAGN_VERSION.awk" @goal fhtagn_installed @private @depends_on soft_folder_created @reached_if [[ -x "$FHTAGN" ]] @use_lib dl - if download "$FHTAGN_URL" "$FHTAGN" - then - chmod +x "$FHTAGN" - else - echo "can't dl fhtagn" - exit 2 - fi + download "$FHTAGN_URL" "$FHTAGN" + chmod +x "$FHTAGN" @goal cleaned_soft @doc 'rm soft folder' @@ -521,17 +517,28 @@ done @goal site_compile @depends_on site_soft_installed - rm -rf book; mkdir book; awk -f mdbooker.awk README.md + rm -rf book; mkdir book; awk -f "$MDBOOKER" README.md "$MDBOOK" build "$MDBOOK_LINKCHECK" -s # check broken links @goal site_soft_installed @private @depends_on mdbook_installed @depends_on mdbook-linkcheck_installed +@depends_on mdbooker_installed +@define MDBOOKER "./soft/mdbooker_$MDBOOKER_VERSION.awk" @define MDBOOK "./soft/mdbook_$MDBOOK_VERSION" @define MDBOOK_LINKCHECK "./soft/mdbook-linkcheck_$MDBOOK_LINKCHECK_VERSION" +@define MDBOOKER_URL "https://github.com/xonixx/mdbooker/raw/$MDBOOKER_VERSION/mdbooker.awk" + +@goal mdbooker_installed @private +@depends_on soft_folder_created +@reached_if [[ -x "$MDBOOKER" ]] +@use_lib dl + download "$MDBOOKER_URL" "$MDBOOKER" + chmod +x "$MDBOOKER" + @goal mdbook_installed @private @reached_if [[ -x "$MDBOOK" ]] @use_lib dl