From 5cde68fcbc47bd181f95a9a807781a97f2162571 Mon Sep 17 00:00:00 2001 From: Ben Edgington Date: Wed, 24 Nov 2021 10:04:58 +0000 Subject: [PATCH] Improve workflow for one-page annotated spec --- bin/build/annotated.awk | 9 ++++++++- bin/build/update.sh | 5 +++++ gatsby-node.js | 7 ------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/bin/build/annotated.awk b/bin/build/annotated.awk index b69f78d..3678c8b 100755 --- a/bin/build/annotated.awk +++ b/bin/build/annotated.awk @@ -1,7 +1,7 @@ #!/usr/bin/gawk -f # Split out the annotated spec chapter as a single page doc and update links - +# # Sends output to stdout BEGIN { @@ -27,6 +27,8 @@ in_part_3 { # Change the chapter title if (in_part_3 == 1) { print "# One Page Annotated Spec" + print "" + print "**Note:** This page has been automatically generated from the chapters in [Part 3](/part3). You may find that some internal links are broken." in_part_3 = 2 next } @@ -39,5 +41,10 @@ in_part_3 { # Rewrite urls that are internal to the chapter gsub(/]\(\/part3\/[^#)]*/, "](", $0) + # Remove page path comments from titles + if ($0 ~ /^#.*/, "", $0) + } + print } diff --git a/bin/build/update.sh b/bin/build/update.sh index 16b3ac9..e2819e2 100755 --- a/bin/build/update.sh +++ b/bin/build/update.sh @@ -5,5 +5,10 @@ cd "$(dirname "$0")/../../src" +# Build the markdown pages rm -rf md/pages/ ../bin/build/split.awk book.md + +# Build the one page annotated spec +rm -f md/annotated.md +../bin/build/annotated.awk book.md > md/annotated.md diff --git a/gatsby-node.js b/gatsby-node.js index f3b1b14..824a527 100644 --- a/gatsby-node.js +++ b/gatsby-node.js @@ -21,13 +21,6 @@ exports.onPreInit = ({reporter}) => { } catch (err) { reporter.panic("Failed to unpack book source.", err) } - - reporter.info("Creating one-page annotated spec...") - try { - execSync('bin/build/annotated.awk src/book.md > src/md/annotated.md') - } catch (err) { - reporter.panic("Failed to create one page annotated spec.", err) - } } exports.createPages = async ({ actions, graphql }) => {