Skip to content

Commit

Permalink
added docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-morel committed Sep 22, 2024
1 parent 7f6f1b9 commit 1fcd577
Show file tree
Hide file tree
Showing 23 changed files with 2,743 additions and 10,995 deletions.
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/gitguardian/ggshield
rev: v1.31.0
hooks:
- id: ggshield
language_version: python3
stages: [commit]
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
please, view the documentation at https://taktk.readthedocs.io
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -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 = .
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)
1 change: 1 addition & 0 deletions docs/_static/github.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
66 changes: 66 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
"""Configuration file for the Sphinx documentation builder."""
from dataclasses import asdict
from pathlib import Path

from sphinxawesome_theme import LinkIcon, ThemeOptions
from sphinxawesome_theme.postprocess import Icons

# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

if __name__ == "__main__":
GH_ICON = open("./_static/github.svg").read()
else:
GH_ICON = (Path(__file__).parent / "_static/github.svg").read_text()
# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
project = "taktk"
copyright = "2024, ken-morel"
author = "ken-morel"
release = "0.1.0"

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = []

templates_path = ["_templates"]
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]


# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "sphinxawesome_theme"
html_static_path = ["_static"]
intersphinx_mapping = {"python": ("https://docs.python.org/3", None)}
# Select theme for both light and dark mode
pygments_style = "sphinx"
# Select a different theme for dark mode
pygments_style_dark = "monokai"


html_permalinks_icon = Icons.permalinks_icon

theme_options = ThemeOptions(
# Add your theme options. For example:
show_breadcrumbs=True,
main_nav_links={"About": "/about"},
logo_dark="_static/logo.png",
logo_light="_static/logo.png",
breadcrumbs_separator="|",
extra_header_link_icons={
"github": LinkIcon(
icon=GH_ICON, link="https://github.com/ken-morel/taktk"
),
},
)

html_theme_options = asdict(theme_options)


# conf.py
# extensions.append("sphinx_docsearch")
# docsearch_app_id = "<DOCSEARCH_APP_ID>"
# docsearch_api_key = "<DOCSEARCH_SEARCH_API_KEY>"
# docsearch_index_name = "<DOCSEARCH_INDEX_NAME>"
17 changes: 17 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Welcome to Lumache's documentation!
===================================

**Lumache** (/lu'make/) is a Python library for cooks and food lovers that
creates recipes mixing random ingredients. It pulls data from the `Open Food
Facts database <https://world.openfoodfacts.org/>`_ and offers a *simple* and
*intuitive* API.

.. note::

This project is under active development.



.. toctree::
:maxdepth: 2
:caption: Contents:
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sphinxawesome_theme
sphinx-docsearch
1 change: 1 addition & 0 deletions docs/whatsnew.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# v0.1.0
19 changes: 11 additions & 8 deletions examples/login_page.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@
def Signin(self):
r"""
\frame padding=100
\frame pos:pack
\frame pos:pack pos:fill=X padding=20
\frame pos:pack pos:fill=BOTH
\frame pos:pack pos:fill=BOTH padding=20
\label text=[label.name] pos:pack=LEFT\
font='"Nova Square" 15'
\entry text={{username}}\
\entry text={{username||username = value}}\
pos:pack=RIGHT width=30 font='"Nova Square" 18'
\frame pos:pack pos:fill=X padding=20
\frame pos:pack pos:fill=BOTH padding=20
\label text=[label.password] pos:pack=LEFT\
font='"Nova Square" 15'
\entry show='*' text={{password}}\
\entry show='*' text={$password}\
pos:pack=RIGHT width=30 font='"Nova Square" 18'
\frame pos:pack pos:fill=X
\frame pos:pack pos:fill=BOTH
\button command={lambda: None} text=[gt_signup] pos:pack=LEFT
\button command={signin} text=[submit] pos:pack=RIGHT
"""
Expand Down Expand Up @@ -121,10 +121,13 @@ def setter():


def update():
Signin().render(root).grid(column=0, row=0)
"""Update the component."""
Signin().render(root).grid(column=0, row=0, sticky="nsew")


root = Window()
root.columnconfigure(0, weight=1)
root.rowconfigure(0, weight=1)
menu.toplevel(root)
Signin().render(root).grid(column=0, row=0)
Signin().render(root).grid(column=0, row=0, sticky="nsew")
root.mainloop()
Binary file removed images/example-simple.png
Binary file not shown.
Binary file removed images/git.png
Binary file not shown.
Binary file removed images/julia.png
Binary file not shown.
Binary file removed images/montage.png
Binary file not shown.
Binary file removed images/powershell.png
Binary file not shown.
Binary file added logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added logo.xcf
Binary file not shown.
2 changes: 1 addition & 1 deletion src/taktk/component/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from .. import Nil, resolve, template
from ..template import Template, evaluate_literal
from ..writeable import Expression, Namespace
from ..writeable import Namespace, Writeable


class Instruction:
Expand Down
40 changes: 14 additions & 26 deletions src/taktk/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
import enum
import os.path
import string
import timeit
from decimal import Decimal
from pathlib import Path
from typing import Optional

from pyoload import annotate

from .dictionary import Translation
from .writeable import Expression, Namespace, NamespaceWriteable
from .writeable import Namespace, Writeable


class TagType(enum.Enum):
Expand Down Expand Up @@ -435,12 +434,6 @@ def evaluate_literal(string: str, namespace=None):
b, e = string, None
else:
raise ValueError("empty literal string")
if string[0] == "!":
auto_eval = True
aes_string = string[1:]
else:
auto_eval = False
aes_string = string
if hasattr(tkinter.constants, string):
return getattr(tkinter.constants, string)
elif string == "None":
Expand All @@ -455,24 +448,23 @@ def evaluate_literal(string: str, namespace=None):
return int(string)
elif len(string_set - DECIMAL) == 0:
return Decimal(string)
elif (
len(aes_string) > 2 and aes_string[0] == "{" and aes_string[-1] == "}"
):
elif len(string) > 2 and b == "{" and e == "}":
if namespace is None:
raise ValueError(
"Unallowed Writeable in none namespaced context", string
)
st = aes_string[1:-1]
if len(st) >= 2 and st[0] == "{" and st[-1] == "}":
if auto_eval:
return NamespaceWriteable(namespace, st[1:-1]).get()
code = string[1:-1]
if len(code) >= 2 and code[0] == "$":
return Writeable.from_name(namespace, code[1:])
if len(code) >= 2 and code[0] == "{" and code[-1] == "}":
code = code[1:-1]
if "||" in code:
get, set_ = code.split("||")
else:
return NamespaceWriteable(namespace, st[1:-1])
get, set_ = code, ""
return Writeable.from_get_set(namespace, get, set_)
else:
if auto_eval:
return Expression(namespace, st).get()
else:
return Expression(namespace, st)
return eval(code, {}, namespace)
elif b in STRING_QUOTES:
if e == b:
return string[1:-1]
Expand Down Expand Up @@ -578,17 +570,13 @@ def __repr__(self) -> str:
instructions: list[Item]

def __init__(self, root: Item, namespace=None):
"""
Creates a taktl template
"""
"""Create a taktl template"""
self.root = root
self.namespace = namespace

@classmethod
def parse(cls, string: str) -> "Template":
"""
Loads template from taktl source string
"""
"""Load template from taktl source string."""
return Template(State(string.replace("\\\n", "")).parse())

def eval(self, _namespace=None):
Expand Down
Loading

0 comments on commit 1fcd577

Please sign in to comment.