From 55527c00eb35bf3b07b361363fd8ca2961afc8ba Mon Sep 17 00:00:00 2001 From: Thomas Kriechbaumer Date: Sat, 11 Apr 2020 12:25:56 +0200 Subject: docs: rename docs scripts and improve template --- docs/README.md | 2 +- docs/build-archive | 4 ---- docs/build-current | 14 -------------- docs/build.sh | 23 +++++++++++++++++++++++ docs/ci | 14 -------------- docs/ci.sh | 18 ++++++++++++++++++ docs/render_examples.py | 10 ++++++---- docs/setup | 8 -------- docs/setup.sh | 14 ++++++++++++++ docs/upload-archive | 18 ------------------ docs/upload-archive.sh | 22 ++++++++++++++++++++++ docs/upload-stable | 9 --------- docs/upload-stable.sh | 13 +++++++++++++ 13 files changed, 97 insertions(+), 72 deletions(-) delete mode 100755 docs/build-archive delete mode 100755 docs/build-current create mode 100755 docs/build.sh delete mode 100755 docs/ci create mode 100755 docs/ci.sh delete mode 100755 docs/setup create mode 100755 docs/setup.sh delete mode 100755 docs/upload-archive create mode 100755 docs/upload-archive.sh delete mode 100755 docs/upload-stable create mode 100755 docs/upload-stable.sh (limited to 'docs') diff --git a/docs/README.md b/docs/README.md index 5c99fb39..24c24d24 100644 --- a/docs/README.md +++ b/docs/README.md @@ -8,7 +8,7 @@ This directory houses the mitmproxy documentation available at "src/generated/${output%.*}.html" -done - -python3 render_examples > src/content/addons-examples.md - -cd src -hugo diff --git a/docs/build.sh b/docs/build.sh new file mode 100755 index 00000000..aaa52a2f --- /dev/null +++ b/docs/build.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -o errexit +set -o pipefail +set -o nounset +# set -o xtrace + +SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )" +pushd ${SCRIPTPATH} + +for script in scripts/* ; do + output="${script##*/}" + output="src/generated/${output%.*}.html" + echo "Generating output for ${script} into ${output} ..." + "${script}" > "${output}" +done + +output="src/content/addons-examples.md" +echo "Generating examples content page into ${output} ..." +./render_examples.py > "${output}" + +cd src +hugo diff --git a/docs/ci b/docs/ci deleted file mode 100755 index 95a5218e..00000000 --- a/docs/ci +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash -set -e - -# This script gets run from CI to render and upload docs - -./build-current - -# Only upload if we have defined credentials - we only have these defined for -# trusted commits (i.e. not PRs). -if [[ ! -z "${AWS_ACCESS_KEY_ID}" && $GITHUB_REF == "refs/heads/master" ]]; then - aws s3 sync --acl public-read ./public s3://docs.mitmproxy.org/master - aws cloudfront create-invalidation --distribution-id E1TH3USJHFQZ5Q \ - --paths "/master/*" -fi diff --git a/docs/ci.sh b/docs/ci.sh new file mode 100755 index 00000000..159d0b50 --- /dev/null +++ b/docs/ci.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -o errexit +set -o pipefail +set -o nounset +# set -o xtrace + +# This script gets run from CI to render and upload docs for the master branch. + +./build.sh + +# Only upload if we have defined credentials - we only have these defined for +# trusted commits (i.e. not PRs). +if [[ ! -z "${AWS_ACCESS_KEY_ID}" && $GITHUB_REF == "refs/heads/master" ]]; then + aws s3 sync --acl public-read ./public s3://docs.mitmproxy.org/master + aws cloudfront create-invalidation --distribution-id E1TH3USJHFQZ5Q \ + --paths "/master/*" +fi diff --git a/docs/render_examples.py b/docs/render_examples.py index b6fa42eb..9c6dea74 100755 --- a/docs/render_examples.py +++ b/docs/render_examples.py @@ -14,10 +14,12 @@ menu: # Examples of Addons and Scripts +The most recent set of examples is also available [on our GitHub project](https://github.com/mitmproxy/mitmproxy/tree/master/examples). + """) base = os.path.dirname(os.path.realpath(__file__)) -examples_path = os.path.join(base, '../src/examples/') +examples_path = os.path.join(base, 'src/examples/') pathlist = Path(examples_path).glob('**/*.py') examples = [os.path.relpath(str(p), examples_path) for p in sorted(pathlist)] @@ -33,7 +35,7 @@ for ex in examples: print(" * [Examples: {}]({{{{< relref \"addons-examples#{}\">}}}})".format(current_dir, sanitized)) sanitized = ex.replace('/', '').replace('.', '') - print(" * [{}]({{{{< relref \"addons-examples#{}\">}}}})".format(ex, sanitized)) + print(" * [{}]({{{{< relref \"addons-examples#example-{}\">}}}})".format(os.path.basename(ex), sanitized)) current_dir = None current_level = 2 @@ -43,6 +45,6 @@ for ex in examples: print("#" * current_level, current_dir) print(textwrap.dedent(""" - {} {} + {} Example: {} {{{{< example src="{}" lang="py" >}}}} - """.format("#" * (current_level + 1), ex, "/examples/" + ex))) + """.format("#" * (current_level + 1), ex, "examples/" + ex))) diff --git a/docs/setup b/docs/setup deleted file mode 100755 index cb63841a..00000000 --- a/docs/setup +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -set -e - -aws configure set preview.cloudfront true -aws --profile mitmproxy \ - s3 cp --acl public-read ./bucketassets/error.html s3://docs.mitmproxy.org/error.html -aws --profile mitmproxy \ - s3 cp --acl public-read ./bucketassets/robots.txt s3://docs.mitmproxy.org/robots.txt diff --git a/docs/setup.sh b/docs/setup.sh new file mode 100755 index 00000000..da30a3c9 --- /dev/null +++ b/docs/setup.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +set -o errexit +set -o pipefail +set -o nounset +# set -o xtrace + +# This is only needed once to provision a new fresh empty S3 bucket. + +aws configure set preview.cloudfront true +aws --profile mitmproxy \ + s3 cp --acl public-read ./bucketassets/error.html s3://docs.mitmproxy.org/error.html +aws --profile mitmproxy \ + s3 cp --acl public-read ./bucketassets/robots.txt s3://docs.mitmproxy.org/robots.txt diff --git a/docs/upload-archive b/docs/upload-archive deleted file mode 100755 index 3aaeb9be..00000000 --- a/docs/upload-archive +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/bash -set -e - -if [[ $# -eq 0 ]] ; then - echo "Please supply a version, e.g. 'v3'" - exit 1 -fi - -# This script uploads docs to a specified archive version. - -SPATH="/archive/$1" - -aws configure set preview.cloudfront true -aws --profile mitmproxy \ - s3 sync --acl public-read ./public s3://docs.mitmproxy.org$SPATH -aws --profile mitmproxy \ - cloudfront create-invalidation --distribution-id E1TH3USJHFQZ5Q \ - --paths "$SPATH/*" diff --git a/docs/upload-archive.sh b/docs/upload-archive.sh new file mode 100755 index 00000000..e35345e9 --- /dev/null +++ b/docs/upload-archive.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +set -o errexit +set -o pipefail +set -o nounset +# set -o xtrace + +if [[ $# -eq 0 ]] ; then + echo "Please supply a version, e.g. 'v3'" + exit 1 +fi + +# This script uploads docs to a specified archive version. + +SPATH="/archive/$1" + +aws configure set preview.cloudfront true +aws --profile mitmproxy \ + s3 sync --acl public-read ./public s3://docs.mitmproxy.org$SPATH +aws --profile mitmproxy \ + cloudfront create-invalidation --distribution-id E1TH3USJHFQZ5Q \ + --paths "$SPATH/*" diff --git a/docs/upload-stable b/docs/upload-stable deleted file mode 100755 index 5aea7479..00000000 --- a/docs/upload-stable +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -set -e - -aws configure set preview.cloudfront true -aws --profile mitmproxy \ - s3 sync --acl public-read ./public s3://docs.mitmproxy.org/stable -aws --profile mitmproxy \ - cloudfront create-invalidation --distribution-id E1TH3USJHFQZ5Q \ - --paths "/stable/*" diff --git a/docs/upload-stable.sh b/docs/upload-stable.sh new file mode 100755 index 00000000..a2f20f01 --- /dev/null +++ b/docs/upload-stable.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +set -o errexit +set -o pipefail +set -o nounset +# set -o xtrace + +aws configure set preview.cloudfront true +aws --profile mitmproxy \ + s3 sync --acl public-read ./public s3://docs.mitmproxy.org/stable +aws --profile mitmproxy \ + cloudfront create-invalidation --distribution-id E1TH3USJHFQZ5Q \ + --paths "/stable/*" -- cgit v1.2.3