aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/.gitignore7
-rw-r--r--docs/README.md2
-rwxr-xr-xdocs/build-archive4
-rwxr-xr-xdocs/build-current12
-rwxr-xr-xdocs/build.sh23
-rwxr-xr-xdocs/ci.sh (renamed from docs/ci)12
-rwxr-xr-xdocs/render_examples.py50
-rwxr-xr-xdocs/setup.sh (renamed from docs/setup)10
-rw-r--r--docs/src/assets/style.scss1
-rw-r--r--docs/src/layouts/shortcodes/example.html3
-rwxr-xr-xdocs/upload-archive.sh (renamed from docs/upload-archive)8
-rwxr-xr-xdocs/upload-stable.sh (renamed from docs/upload-stable)8
12 files changed, 108 insertions, 32 deletions
diff --git a/docs/.gitignore b/docs/.gitignore
index 1fb99949..610ffdf1 100644
--- a/docs/.gitignore
+++ b/docs/.gitignore
@@ -1,5 +1,6 @@
generated/
-src/public
-node_modules
-public
+src/public/
+node_modules/
+public/
src/resources/_gen/
+src/content/addons-examples.md
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 <https://docs.mit
2. Windows users: Depending on your git settings, you may need to manually create a symlink from
/docs/src/examples to /examples.
3. Make sure the mitmproxy Python package is installed.
- 4. Run `./build-current` to generate the documentation source files in `./src/generated`.
+ 4. Run `./build.sh` to generate additional documentation source files.
Now you can run `hugo server -D` in ./src.
diff --git a/docs/build-archive b/docs/build-archive
deleted file mode 100755
index 004e625a..00000000
--- a/docs/build-archive
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-set -e
-
-DOCS_ARCHIVE=true ./build-current
diff --git a/docs/build-current b/docs/build-current
deleted file mode 100755
index 7164de6d..00000000
--- a/docs/build-current
+++ /dev/null
@@ -1,12 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-
-for script in scripts/* ; do
- echo "Generating output for $script ..."
- output="${script##*/}"
- "$script" > "src/generated/${output%.*}.html"
-done
-
-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.sh
index 95a5218e..159d0b50 100755
--- a/docs/ci
+++ b/docs/ci.sh
@@ -1,9 +1,13 @@
-#!/bin/bash
-set -e
+#!/usr/bin/env bash
-# This script gets run from CI to render and upload docs
+set -o errexit
+set -o pipefail
+set -o nounset
+# set -o xtrace
-./build-current
+# 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).
diff --git a/docs/render_examples.py b/docs/render_examples.py
new file mode 100755
index 00000000..9c6dea74
--- /dev/null
+++ b/docs/render_examples.py
@@ -0,0 +1,50 @@
+#!/usr/bin/env python3
+
+import os
+import textwrap
+from pathlib import Path
+
+print("""
+---
+title: "Examples"
+menu:
+ addons:
+ weight: 6
+---
+
+# 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/')
+pathlist = Path(examples_path).glob('**/*.py')
+
+examples = [os.path.relpath(str(p), examples_path) for p in sorted(pathlist)]
+examples = [p for p in examples if not os.path.basename(p) == '__init__.py']
+examples = [p for p in examples if not os.path.basename(p).startswith('test_')]
+
+current_dir = None
+current_level = 2
+for ex in examples:
+ if os.path.dirname(ex) != current_dir:
+ current_dir = os.path.dirname(ex)
+ sanitized = current_dir.replace('/', '').replace('.', '')
+ print(" * [Examples: {}]({{{{< relref \"addons-examples#{}\">}}}})".format(current_dir, sanitized))
+
+ sanitized = ex.replace('/', '').replace('.', '')
+ print(" * [{}]({{{{< relref \"addons-examples#example-{}\">}}}})".format(os.path.basename(ex), sanitized))
+
+current_dir = None
+current_level = 2
+for ex in examples:
+ if os.path.dirname(ex) != current_dir:
+ current_dir = os.path.dirname(ex)
+ print("#" * current_level, current_dir)
+
+ print(textwrap.dedent("""
+ {} Example: {}
+ {{{{< example src="{}" lang="py" >}}}}
+ """.format("#" * (current_level + 1), ex, "examples/" + ex)))
diff --git a/docs/setup b/docs/setup.sh
index cb63841a..da30a3c9 100755
--- a/docs/setup
+++ b/docs/setup.sh
@@ -1,5 +1,11 @@
-#!/bin/sh
-set -e
+#!/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 \
diff --git a/docs/src/assets/style.scss b/docs/src/assets/style.scss
index 26c22071..33e8863e 100644
--- a/docs/src/assets/style.scss
+++ b/docs/src/assets/style.scss
@@ -47,6 +47,7 @@ body > div {
width: 100%;
text-align: right;
}
+ max-width: 70vw;
margin-bottom: 1em;
}
diff --git a/docs/src/layouts/shortcodes/example.html b/docs/src/layouts/shortcodes/example.html
index d23cabb6..83a6075d 100644
--- a/docs/src/layouts/shortcodes/example.html
+++ b/docs/src/layouts/shortcodes/example.html
@@ -1,5 +1,4 @@
-
<div class="example">
{{ highlight (trim (readFile (.Get "src")) "\n\r") (.Get "lang") "" }}
<div class="path">{{ (.Get "src" )}}</div>
-</div> \ No newline at end of file
+</div>
diff --git a/docs/upload-archive b/docs/upload-archive.sh
index 3aaeb9be..e35345e9 100755
--- a/docs/upload-archive
+++ b/docs/upload-archive.sh
@@ -1,5 +1,9 @@
-#!/bin/bash
-set -e
+#!/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'"
diff --git a/docs/upload-stable b/docs/upload-stable.sh
index 5aea7479..a2f20f01 100755
--- a/docs/upload-stable
+++ b/docs/upload-stable.sh
@@ -1,5 +1,9 @@
-#!/bin/bash
-set -e
+#!/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 \