#!/usr/bin/env python3
# api: cli
# title: document backends
# description: markdown table from class attributes
# version: 0.1
#

import sys
sys.path.append("pythonpath")
from translationbackends import BackendUtils

# Generate overview list
def document_backends():
    print("| service        | brief summary                               | lang_detect | error msgs | api key🔑| test quali | prvcy |")
    print("|----------------|---------------------------------------------|-------------|------------|----------|------------|-------|")
    _re = ["log", "popup"]
    _kr = ["-", "required"]
    classes = {cls.__name__: cls for cls in set(BackendUtils.subclasses())}
    for name in sorted(classes):
        c = classes[name]
        print("| {name:<14} |{doc:<45}| {lang:<11} | {error:<10} | {key:<8} | {quality:<10s} | {privacyy:<5s} |".format(
            name=name, doc=c.__doc__, lang=c.lang_detect, error=_re[c.raises_error],
            key=_kr[c.requires_key], quality="+" * int(10 * c.is_tested), privacyy="+" * int(5 * c.privacy)
        ))

document_backends()
