Version 3

Support for multiple libraries synchronization (#44, #43, #41)
Support for Docker Secrets (#25)
Support for Seafile client's version through Docker tags (#9)
Mock Seafile server for testings (#6)
Revised project layout and workflow (#38, #39)
Working Docker Hub description publishing (#10)
This commit is contained in:
flow.gunso
2024-03-16 21:58:04 +00:00
parent 4c347b9156
commit f25b0182d2
42 changed files with 1196 additions and 788 deletions

54
scripts/make-documents.py Executable file
View File

@@ -0,0 +1,54 @@
# !/usr/bin/env python
from pathlib import Path
import argparse
from jinja2 import Environment, FileSystemLoader
REPOSITORY_PATH = Path(__file__).parent.parent
# Argument parsing.
parser = argparse.ArgumentParser(prog="Seafile Docker client documentation renderer")
parser.add_argument("template", type=str)
args = parser.parse_args()
# Setup Jinja2 templater
documentations_path = REPOSITORY_PATH.joinpath("documentations")
loader = FileSystemLoader(documentations_path)
environment = Environment(loader=loader)
template = environment.get_template(args.template)
buffer=[]
for path in Path("versions").iterdir():
with open(path, "rt") as fo:
buffer.append(fo.read().strip())
buffer.sort(reverse=True)
# Prepare the render context.
latest = True
versions = []
for line in buffer:
version = line.strip()
parts = version.split(".")
increments = []
blocks = []
for part in parts:
increments.append(part)
section = ".".join(increments)
blocks.append(f"`{section}`")
if latest:
blocks.append("`latest`")
latest = False
versions.append(blocks)
# Render
content = template.render(versions=versions)
#content = template.render() # When version/ is unavailable.
filename = Path(args.template).with_suffix("")
document = documentations_path.joinpath(filename)
# Write to file
with open(document, mode="w") as fo:
fo.write(content)