From 5f72c0ff9c94d92c99f6a19b4ec2e4f5615a298b Mon Sep 17 00:00:00 2001 From: decfox Date: Thu, 4 Jul 2024 19:40:09 +0530 Subject: [PATCH] fix: add docs to be parsed --- .github/workflows/build_docs.yml | 6 +- Makefile | 2 +- script/build_docs.sh | 187 +++++++++++++++++++++++++++++++ scripts/build_docs.sh | 21 ---- 4 files changed, 191 insertions(+), 25 deletions(-) create mode 100644 script/build_docs.sh delete mode 100644 scripts/build_docs.sh diff --git a/.github/workflows/build_docs.yml b/.github/workflows/build_docs.yml index 92caa80fa..0077b6025 100644 --- a/.github/workflows/build_docs.yml +++ b/.github/workflows/build_docs.yml @@ -23,16 +23,16 @@ jobs: path: "ooni-docs" - name: Update docs - run: cp -R dist/docs/* ooni-docs/src/content/docs/mydocs/ + run: cp -R dist/docs/* ooni-docs/src/content/docs/probe-engine/ - name: Check for conflicting slugs run: | - cat ooni-docs/src/content/docs/mydocs/*.md \ + cat ooni-docs/src/content/docs/probe-engine/*.md \ | grep "^slug:" | awk -F':' '{gsub(/^ +/, "", $2); print $2}' | sort | uniq -c \ | awk '{if ($1 > 1) { print "duplicate slug for: " $2; exit 1}}' - name: Print the lines of the generated docs - run: wc -l ooni-docs/src/content/docs/mydocs/* + run: wc -l ooni-docs/src/content/docs/probe-engine/* - name: Commit changes # Only push the docs update when we are in master diff --git a/Makefile b/Makefile index a995a2b06..88496448a 100644 --- a/Makefile +++ b/Makefile @@ -122,7 +122,7 @@ search/for/zip: #help: The `make docs clean` command builds the docs for docs.ooni.org. .PHONY: docs clean docs: - ./scripts/build_docs.sh + ./script/build_docs.sh clean: rm -rf dist/ diff --git a/script/build_docs.sh b/script/build_docs.sh new file mode 100644 index 000000000..6644ec450 --- /dev/null +++ b/script/build_docs.sh @@ -0,0 +1,187 @@ +#!/bin/bash +DOCS_ROOT=dist/docs/ +REPO_NAME="ooni/probe-cli" +COMMIT_HASH=$(git rev-parse --short HEAD) + +mkdir -p $DOCS_ROOT + +strip_title() { + # Since the title is already present in the frontmatter, we need to remove + # it to avoid duplicate titles + local infile="$1" + cat $infile | awk 'BEGIN{p=1} /^#/{if(p){p=0; next}} {print}' +} + +cat <$DOCS_ROOT/00-index.md +--- +# Do not edit! This file is automatically generated +# to edit go to: https://github.com/$REPO_NAME/edit/master/README.md +# version: $REPO_NAME:$COMMIT_HASH +title: OONI Probe Engine +description: OONI Probe Engine documentation +slug: probe-engine +--- +EOF +strip_title README.md >> $DOCS_ROOT/00-index.md + +# design docs +BASE_PATH=docs/design + +DOC_PATH=$DOCS_ROOT/00-design.md +cat <$DOC_PATH +--- +# Do not edit! This file is automatically generated +# to edit go to: https://github.com/$REPO_NAME/edit/master/README.md +# version: $REPO_NAME:$COMMIT_HASH +title: OONI Probe Engine Design +description: Design documents for OONI Probe +slug: probe-engine/design/ +--- +EOF +strip_title $BASE_PATH/README.md >> $DOC_PATH + +DOC_PATH=$DOCS_ROOT/01-design-oonimkall.md +cat <$DOC_PATH +--- +# Do not edit! This file is automatically generated +# to edit go to: https://github.com/$REPO_NAME/edit/master/README.md +# version: $REPO_NAME:$COMMIT_HASH +title: OONI oonimkall +description: OONI oonimkall package design documentaton +slug: probe-engine/design/oonimkall +--- +EOF +strip_title $BASE_PATH/dd-001-oonimkall.md >> $DOC_PATH + +DOC_PATH=$DOCS_ROOT/02-design-netx.md +cat <$DOC_PATH +--- +# Do not edit! This file is automatically generated +# to edit go to: https://github.com/$REPO_NAME/edit/master/README.md +# version: $REPO_NAME:$COMMIT_HASH +title: OONI netx +description: OONI netx package design documentation +slug: probe-engine/design/netx +--- +EOF +strip_title $BASE_PATH/dd-02-netx.md >> $DOC_PATH + +DOC_PATH=$DOCS_ROOT/03-design-step-by-step.md +cat <$DOC_PATH +--- +# Do not edit! This file is automatically generated +# to edit go to: https://github.com/$REPO_NAME/edit/master/README.md +# version: $REPO_NAME:$COMMIT_HASH +title: OONI step-by-step +description: OONI step-by-step design documentation +slug: probe-engine/design/step-by-step +--- +EOF +strip_title $BASE_PATH/dd-003-step-by-step.md >> $DOC_PATH + +DOC_PATH=$DOCS_ROOT/04-design-minioonirunv2.md +cat <$DOC_PATH +--- +# Do not edit! This file is automatically generated +# to edit go to: https://github.com/$REPO_NAME/edit/master/README.md +# version: $REPO_NAME:$COMMIT_HASH +title: OONI minioonirunv2 +description: OONI minioonirunv2 design documentation +slug: probe-engine/design/minioonirunv2 +--- +EOF +strip_title $BASE_PATH/dd-004-minioonirunv2.md >> $DOC_PATH + +DOC_PATH=$DOCS_ROOT/05-design-dslx.md +cat <$DOC_PATH +--- +# Do not edit! This file is automatically generated +# to edit go to: https://github.com/$REPO_NAME/edit/master/README.md +# version: $REPO_NAME:$COMMIT_HASH +title: OONI dslx +description: OONI dslx package design documentation +slug: probe-engine/design/dslx +--- +EOF +strip_title $BASE_PATH/dd-005-dslx.md >> $DOC_PATH + +DOC_PATH=$DOCS_ROOT/06-design-probeservices.md +cat <$DOC_PATH +--- +# Do not edit! This file is automatically generated +# to edit go to: https://github.com/$REPO_NAME/edit/master/README.md +# version: $REPO_NAME:$COMMIT_HASH +title: OONI probeservices +description: OONI probeservices design documentation +slug: probe-engine/design/probeservices +--- +EOF +strip_title $BASE_PATH/dd-006-probeservices.md >> $DOC_PATH + +DOC_PATH=$DOCS_ROOT/07-design-throttling.md +cat <$DOC_PATH +--- +# Do not edit! This file is automatically generated +# to edit go to: https://github.com/$REPO_NAME/edit/master/README.md +# version: $REPO_NAME:$COMMIT_HASH +title: OONI throttling experiment +description: OONI throttling experiment design documentation +slug: probe-engine/design/throttling +--- +EOF +strip_title $BASE_PATH/dd-007-throttling.md >> $DOC_PATH + +DOC_PATH=$DOCS_ROOT/08-design-richer-input.md +cat <$DOC_PATH +--- +# Do not edit! This file is automatically generated +# to edit go to: https://github.com/$REPO_NAME/edit/master/README.md +# version: $REPO_NAME:$COMMIT_HASH +title: OONI richer input +description: OONI richer input design documentation +slug: probe-engine/design/richer-input +--- +EOF +strip_title $BASE_PATH/dd-008-richer-input.md >> $DOC_PATH + +# oonimkall docs +DOC_PATH=$DOCS_ROOT/09-oonimkall.md +cat <$DOC_PATH +--- +# Do not edit! This file is automatically generated +# to edit go to: https://github.com/$REPO_NAME/edit/master/README.md +# version: $REPO_NAME:$COMMIT_HASH +title: OONI oonimkall +description: OONI oonimkall documentation +slug: probe-engine/oonimkall +--- +EOF +strip_title pkg/oonimkall/README.md >> $DOC_PATH + +# release docs +DOC_PATH=$DOCS_ROOT/10-releasing.md +cat <$DOC_PATH +--- +# Do not edit! This file is automatically generated +# to edit go to: https://github.com/$REPO_NAME/edit/master/README.md +# version: $REPO_NAME:$COMMIT_HASH +title: OONI Probe Release +description: OONI Probe release documentation +slug: probe-engine/releasing/ +--- +EOF +strip_title docs/releasing.md >> $DOC_PATH + +# release docs +DOC_PATH=$DOCS_ROOT/10-releasing.md +cat <$DOC_PATH +--- +# Do not edit! This file is automatically generated +# to edit go to: https://github.com/$REPO_NAME/edit/master/README.md +# version: $REPO_NAME:$COMMIT_HASH +title: OONI Probe Release +description: OONI Probe release documentation +slug: probe-engine/releasing/ +--- +EOF +strip_title docs/releasing.md >> $DOC_PATH diff --git a/scripts/build_docs.sh b/scripts/build_docs.sh deleted file mode 100644 index 5d1c22036..000000000 --- a/scripts/build_docs.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -DOCS_ROOT=dist/docs/ -REPO_NAME="ooni/probe-cli" -COMMIT_HASH=$(git rev-parse --short HEAD) - -mkdir -p $DOCS_ROOT - -strip_title() { - # Since the title is already present in the frontmatter, we need to remove - # it to avoid duplicate titles - local infile="$1" - cat $infile | awk 'BEGIN{p=1} /^#/{if(p){p=0; next}} {print}' -} - -cat <$DOCS_ROOT/00-index.md ---- -# Do not edit! This file is automatically generated -# to edit go to: https://github.com/$REPO_NAME/edit/master/README.md -# version: $REPO_NAME:$COMMIT_HASH ---- -EOF