Adding documentation

pull/11/head
Paco Hope 2022-08-09 18:48:18 -04:00
parent c781347bc3
commit ad0e532be8
8 changed files with 120 additions and 0 deletions

20
docs/Makefile Normal file
View File

@ -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)

5
docs/README.md Normal file
View File

@ -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

2
docs/requirements.txt Normal file
View File

@ -0,0 +1,2 @@
sphinx
sphinx-argparse

10
docs/source/cli.rst Normal file
View File

@ -0,0 +1,10 @@
Command Line Reference
====================================
.. argparse::
:module: tfscript.cli
:func: parseCLI
:prog: tfscript
This is the documentation for the CLI tool.

23
docs/source/conf.py Normal file
View File

@ -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'))

12
docs/source/index.rst Normal file
View File

@ -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 <https://wiki.teamfortress.com/wiki/Scripting_faq>`_ in your ``cfg`` files, then this will help you automate that.
.. toctree::
:maxdepth: 1
cli
installing

View File

@ -0,0 +1,6 @@
Installing
==============
You can get the software by going `to the repository <https://git.paco.to/tfscript/tfscript/releases>`_ and downloading.
Someday we hope you can just run ``pip install tfscript``.

42
docs/sync.sh Executable file
View File

@ -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)