Esempio n. 1
0
import jinja2
import pypandoc
import pytoml as toml

from common import validate_toml, get_tt_version

if (sys.version_info.major, sys.version_info.minor) < (3, 6):
    raise Exception("need Python 3.6 or later")

THIS_FILE = Path(__file__).resolve()
ROOT_DIR = THIS_FILE.parent.parent
TEMPLATE_DIR = ROOT_DIR / "utils" / "templates"
DOCS_DIR = ROOT_DIR / "docs"
OP_DOCS_DIR = DOCS_DIR / "ops"
FONTS_DIR = ROOT_DIR / "utils" / "fonts"
_VERSION_ = get_tt_version()
_VERSION_STR_ = "Teletype " + \
              _VERSION_["tag"] + " " + _VERSION_["hash"] + " Cheatsheet"


# We want to run inject_latex in parallel as it's quite slow, and we must run
# it once for each op.
# But it must be defined before the multiprocessing.Pool is defined (because...
# python.)
def inject_latex(value):
    latex = pypandoc.convert_text(value["short"], format="markdown", to="tex")
    value["short_latex"] = latex
    return value


# create a multiprocessing pool
Esempio n. 2
0
import jinja2
import pypandoc
import pytoml as toml

from common import list_ops, list_mods, validate_toml, get_tt_version

if (sys.version_info.major, sys.version_info.minor) < (3, 6):
    raise Exception("need Python 3.6 or later")

THIS_FILE = Path(__file__).resolve()
ROOT_DIR = THIS_FILE.parent.parent
TEMPLATE_DIR = ROOT_DIR / "utils" / "templates"
DOCS_DIR = ROOT_DIR / "docs"
OP_DOCS_DIR = DOCS_DIR / "ops"
FONTS_DIR = ROOT_DIR / "utils" / "fonts"
TT_VERSION = get_tt_version()
VERSION_STR = " ".join(["Teletype", TT_VERSION["tag"], "Documentation"])

env = jinja2.Environment(autoescape=False,
                         loader=jinja2.FileSystemLoader(str(TEMPLATE_DIR)),
                         trim_blocks=True,
                         lstrip_blocks=True,
                         cache_size=0,
                         auto_reload=True)

# determines the order in which sections are displayed
OPS_SECTIONS = [
    "variables", "hardware", "patterns", "controlflow", "maths", "metronome",
    "delay", "stack", "queue", "turtle", "grid", "ansible", "whitewhale",
    "meadowphysics", "earthsea", "orca", "justfriends", "telex_i", "telex_o",
    "er301", "fader", "wslash", "matrixarchate"
Esempio n. 3
0
import jinja2
import pypandoc
import pytoml as toml

from common import validate_toml, get_tt_version

if (sys.version_info.major, sys.version_info.minor) < (3, 6):
    raise Exception("need Python 3.6 or later")

THIS_FILE = Path(__file__).resolve()
ROOT_DIR = THIS_FILE.parent.parent
TEMPLATE_DIR = ROOT_DIR / "utils" / "templates"
DOCS_DIR = ROOT_DIR / "docs"
OP_DOCS_DIR = DOCS_DIR / "ops"
FONTS_DIR = ROOT_DIR / "utils" / "fonts"
TT_VERSION = get_tt_version()
VERSION_STR = " ".join(["Teletype", TT_VERSION["tag"], "Documentation"])


# We want to run inject_latex in parallel as it's quite slow, and we must run
# it once for each op.
# But it must be defined before the multiprocessing.Pool is defined (because...
# python.)
def inject_latex(value):
    latex = pypandoc.convert_text(value["short"], format="markdown", to="tex")
    value["short_latex"] = latex
    return value


# create a multiprocessing pool
pool = multiprocessing.Pool()