diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..d0c3cbf --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..239026f --- /dev/null +++ b/docs/README.md @@ -0,0 +1,5 @@ +# Building Documentation + +1. Run `make html` +2. The docs appear in `docs/build/html`. You can open them in a browser (e.g., on Mac do `open docs/build/html/index.html`) +3. Run `sync.sh` to upload it to the S3 bucket diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..56f5ee7 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,2 @@ +sphinx +sphinx-argparse diff --git a/docs/source/cli.rst b/docs/source/cli.rst new file mode 100644 index 0000000..73e94af --- /dev/null +++ b/docs/source/cli.rst @@ -0,0 +1,10 @@ +Command Line Reference +==================================== + +.. argparse:: + :module: tfscript.cli + :func: parseCLI + :prog: tfscript + + +This is the documentation for the CLI tool. diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 0000000..5684a75 --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,23 @@ +# Configuration file for the Sphinx documentation builder. +# +# For the full list of built-in configuration values, see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +project = 'TFScript' +copyright = '2022, Nicholas Hope and Paco Hope' +author = 'Nicholas Hope and Paco Hope' +release = '1.0' +extensions = [ + 'sphinx.ext.duration', + 'sphinx.ext.doctest', + 'sphinx.ext.autodoc', + 'sphinx.ext.autosummary', + 'sphinxarg.ext' ] +templates_path = ['_templates'] +exclude_patterns = [] +html_theme = 'alabaster' +html_static_path = ['_static'] + +import os +import sys +sys.path.append(os.path.abspath('../../src')) \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 0000000..61e1e39 --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,12 @@ +Welcome to TFScript +==================================== + +TFScript helps you manage all the customisations you make to your Team Fortress 2 configurations. If you have `custom scripts `_ in your ``cfg`` files, then this will help you automate that. + + + +.. toctree:: + :maxdepth: 1 + + cli + installing \ No newline at end of file diff --git a/docs/source/installing.rst b/docs/source/installing.rst new file mode 100644 index 0000000..202182a --- /dev/null +++ b/docs/source/installing.rst @@ -0,0 +1,6 @@ +Installing +============== + +You can get the software by going `to the repository `_ and downloading. + +Someday we hope you can just run ``pip install tfscript``. \ No newline at end of file diff --git a/docs/sync.sh b/docs/sync.sh new file mode 100755 index 0000000..e81ed58 --- /dev/null +++ b/docs/sync.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +BUCKET=tfscript.nickhope.world +AWSROLE="arn:aws:iam::096320175891:role/Admin" +NORMALAGE=120 # in seconds +# could be something like "foo" if everything is meant to be in /foo +PREFIX="" +AWS="aws" # for simple debugging, change this to AWS="echo aws" +AWSLOG="sync.log" + +export AWS_DEFAULT_OUTPUT=text +export AWS_PAGER= +CACHE="--cache-control max-age=\"${NORMALAGE}\",public" + +# Set up AWS creds. Assume role once. Reuse creds after that. + +temp_role=$(aws --output json sts assume-role \ + --role-arn "${AWSROLE}" \ + --role-session-name "tfscript-sync") + +export AWS_ACCESS_KEY_ID=$(echo $temp_role | jq -r .Credentials.AccessKeyId) +export AWS_SECRET_ACCESS_KEY=$(echo $temp_role | jq -r .Credentials.SecretAccessKey) +export AWS_SESSION_TOKEN=$(echo $temp_role | jq -r .Credentials.SessionToken) + +rm -f ${AWSLOG} +${AWS} s3 sync --only-show-errors \ + build/html s3://${BUCKET} --delete \ + ${CACHE} 2>&1 >> ${AWSLOG} + +echo "Writing index files to directory markers" +time (find build/html/* -name index.html | while read -r line; do + # ${AWS} s3 cp $line "s3://$BUCKET/${BASH_REMATCH[1]}" + # get rid of "public/" + OBJKEY=${line#build\/html/*} + # get rid of "/index.html" + OBJKEY=${OBJKEY%/index.html} + echo "Uploading from $line to s3://${BUCKET}/${OBJKEY}/" + ${AWS} s3api put-object --bucket "$BUCKET" \ + --body ${line} --key "${OBJKEY}" --content-type text/html ${CACHE} 2>&1 >> ${AWSLOG} + ${AWS} s3api put-object --bucket "$BUCKET" \ + --body ${line} --key "${OBJKEY}/" --content-type text/html ${CACHE} 2>&1 >> ${AWSLOG} +done)