Skip to content

Commit

Permalink
docs: rename docs scripts and improve template
Browse files Browse the repository at this point in the history
  • Loading branch information
Kriechi committed Apr 11, 2020
1 parent 5ea75a1 commit 55527c0
Show file tree
Hide file tree
Showing 13 changed files with 80 additions and 49 deletions.
11 changes: 7 additions & 4 deletions dev.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/bin/sh
set -e
set -x
#!/usr/bin/env bash

set -o errexit
set -o pipefail
set -o nounset
set -o xtrace

echo "Creating dev environment in ./venv..."

Expand All @@ -12,4 +15,4 @@ pip3 install -r requirements.txt
echo ""
echo " * Created virtualenv environment in ./venv."
echo " * Installed all dependencies into the virtualenv."
echo " * You can now activate the $(python3 --version) virtualenv with this command: \`. venv/bin/activate\`"
echo " * You can now activate the $(python3 --version) virtualenv with this command: \`. venv/bin/activate\`"
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 0 additions & 4 deletions docs/build-archive

This file was deleted.

14 changes: 0 additions & 14 deletions docs/build-current

This file was deleted.

23 changes: 23 additions & 0 deletions docs/build.sh
Original file line number Diff line number Diff line change
@@ -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
12 changes: 8 additions & 4 deletions docs/ci → docs/ci.sh
Original file line number Diff line number Diff line change
@@ -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).
Expand Down
10 changes: 6 additions & 4 deletions docs/render_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
# 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)]
Expand All @@ -33,7 +35,7 @@
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
Expand All @@ -43,6 +45,6 @@
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)))
10 changes: 8 additions & 2 deletions docs/setup → docs/setup.sh
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
8 changes: 6 additions & 2 deletions docs/upload-archive → docs/upload-archive.sh
Original file line number Diff line number Diff line change
@@ -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'"
Expand Down
8 changes: 6 additions & 2 deletions docs/upload-stable → docs/upload-stable.sh
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
8 changes: 4 additions & 4 deletions release/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ These steps assume you are on the correct branch and have a git remote called `o
`export VERSION=4.0.3 && docker pull mitmproxy/mitmproxy:$VERSION && docker tag mitmproxy/mitmproxy:$VERSION mitmproxy/mitmproxy:latest && docker push mitmproxy/mitmproxy:latest`.

### Docs
- `./build-current`. If everything looks alright, continue with
- `./upload-stable`,
- `./build-archive`, and
- `./upload-archive v4`. Doing this now already saves you from switching back to an old state on the next release.
- `./build.sh`. If everything looks alright, continue with
- `./upload-stable.sh`,
- `DOCS_ARCHIVE=true ./build.sh`, and
- `./upload-archive.sh v4`. Doing this now already saves you from switching back to an old state on the next release.

### Website
- Update version here:
Expand Down
17 changes: 10 additions & 7 deletions release/docker/docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#!/bin/sh
set -e
#!/usr/bin/env bash

set -o errexit
set -o pipefail
set -o nounset
# set -o xtrace

MITMPROXY_PATH="/home/mitmproxy/.mitmproxy"

if [[ "$1" = "mitmdump" || "$1" = "mitmproxy" || "$1" = "mitmweb" ]]; then
mkdir -p "$MITMPROXY_PATH"
chown -R mitmproxy:mitmproxy "$MITMPROXY_PATH"

su-exec mitmproxy "$@"
mkdir -p "$MITMPROXY_PATH"
chown -R mitmproxy:mitmproxy "$MITMPROXY_PATH"
su-exec mitmproxy "$@"
else
exec "$@"
exec "$@"
fi
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ deps =
awscli
changedir = docs
commands =
./ci
./ci.sh

0 comments on commit 55527c0

Please sign in to comment.