From ed0a780d7e4d96cfb8b1c8a77600223c4bd7ddae Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Mon, 4 Jul 2022 19:02:06 +0200 Subject: [PATCH] Add docs --- .gitignore | 2 + README.md | 1 + docs/templates/layout.html | 83 ++++++++++++++++++++++++++++++++++++++ scripts/generate_docs.py | 28 +++++++++++++ tasks.py | 22 ++++++++++ 5 files changed, 136 insertions(+) create mode 100644 docs/templates/layout.html create mode 100644 scripts/generate_docs.py diff --git a/.gitignore b/.gitignore index f65b589..09e93dd 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ __pycache__/ .mypy_cache/ .pytest_cache/ +docs/dist/ +requirements.txt diff --git a/README.md b/README.md index 2927e16..8dfd50c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # microblog.pub [![builds.sr.ht status](https://builds.sr.ht/~tsileo/microblog.pub.svg)](https://builds.sr.ht/~tsileo/microblog.pub?) +[![AGPL 3.0](https://img.shields.io/badge/license-AGPL_3.0-blue.svg?style=flat)](https://git.sr.ht/~tsileo/microblog.pub/tree/v2/item/LICENSE) This branch is a complete rewrite of the original microblog.pub server. diff --git a/docs/templates/layout.html b/docs/templates/layout.html new file mode 100644 index 0000000..272a059 --- /dev/null +++ b/docs/templates/layout.html @@ -0,0 +1,83 @@ + + + +microblog.pub - A self-hosted, single-user, ActivityPub powered microblog. + + + + + + +
+
+

microblog.pub

+

A self-hosted, single-user, ActivityPub powered microblog.

+
+ + + +
+ {{ content | safe }} +
+ +
+ + diff --git a/scripts/generate_docs.py b/scripts/generate_docs.py new file mode 100644 index 0000000..3126516 --- /dev/null +++ b/scripts/generate_docs.py @@ -0,0 +1,28 @@ +from pathlib import Path + +from jinja2 import Environment +from jinja2 import FileSystemLoader +from jinja2 import select_autoescape +from markdown import markdown + + +def markdownify(content: str) -> str: + return markdown(content, extensions=["mdx_linkify"]) + + +def main() -> None: + # Setup Jinja + loader = FileSystemLoader("docs/templates") + env = Environment(loader=loader, autoescape=select_autoescape()) + template = env.get_template("layout.html") + + Path("docs/dist").mkdir(exist_ok=True) + + readme = Path("README.md") + template.stream( + content=markdownify(readme.read_text().removeprefix("# microblog.pub")) + ).dump("docs/dist/index.html") + + +if __name__ == "__main__": + main() diff --git a/tasks.py b/tasks.py index 5f709d2..3a71423 100644 --- a/tasks.py +++ b/tasks.py @@ -73,6 +73,28 @@ def tests(ctx, k=None): ) +@task +def generate_requirements_txt(ctx, where="requirements.txt"): + # type: (Context, str) -> None + run( + f"poetry export -f requirements.txt --without-hashes > {where}", + pty=True, + echo=True, + ) + + +@task(generate_requirements_txt) +def build_configuration_wizard_image(ctx): + # type: (Context) -> None + run("docker build -t testmpw -f configuration_wizard.dockerfile .") + + +@task +def build_docs(ctx): + # type: (Context) -> None + run("poetry run python scripts/generate_docs.py", pty=True, echo=True) + + @task def download_twemoji(ctx): # type: (Context) -> None