$def with (project, repo, readme, package_releases, pyproject, api_python, test_results, test_coverage, mentions, issues) $var breadcrumbs = ("projects", "Projects") $ title = project $var title_classes = ["p-name"] $var article_classes = ["h-ragt-ag-project"] $ likes = 0 $for mention in mentions: $if mention["data"]["comment_type"][0] == "like": $ likes += 1 $elif mention["data"]["comment_type"][0] == "like": $ likes += 1

Issues $if issues: $issues

$if likes:

$emoji.emojize(":red_heart:") $likes

$#
$# $ data = mention["data"] $# $if name := data.get("name", None): $#

$name

$# $if data: $# $ a = data["author"] $# $ comment_type = data["comment_type"][0] $# $if comment_type == "like": $# $emoji.emojize(":red_heart:") $# $if content := data.get("content"): $#
$:content
$# $ published = data["published"][0] $# Opened $# $if data: $# by $a.get("name", a["url"]), $# $if comment := data.get("comment"): $# $ comment_count = len(comment) $# $if comment_count: $# 💬 $comment_count comment$("s" if comment_count > 1 else "") $# $#
$if repo.exists(): $ commits = list(repo.log().values()) $if commits: $ commit = commits[0] $ author_url = commit["author_email"] $if "@" in author_url: $ author_url = f"mailto:{author_url}" $else: $ author_url = f"https://{author_url}"
$# $commit["author_name"] $:str(mkdn(commit["message"]))[3:-4] $if "errors" in test_results: $if test_results["errors"]: $ test_color = "red" $ test_indicator = "■" $ plural = "" $if test_results["errors"] > 1: $ plural = "s" $ test_msg = f"{test_results['errors']} test{plural} of {test_results['tests']} failing" $else: $ test_color = "green" $ test_indicator = "●" $ plural = "" $if test_results["tests"] > 1: $ plural = "s" $ test_msg = f"{test_results['tests']} test{plural} passing" $:test_indicator $test_msg in $test_results["time"]s \ $commit["hash"][:7].upper() $len(repo.log()) commits
$ files = sorted(repo.files) $if files:
$ ignorable_files = ( $ ".github", $ ".gitignore", $ "README", $ "README.md", $ "pyproject.toml", $ "pyrightconfig.json", $ "package.json", $ "tsconfig.json", $ "webpack.config.js", $ "eslintrc.js", $ "eslintrc.json", $ "eslintrc.yml", $ ) $ prev_file = None $ prev_file = None $ known_files = [f for f in files if str(f).partition("/")[0] in ignorable_files]

\ $for file in known_files: $ file, is_dir, _ = str(file).partition("/") $if file == prev_file: $continue $file\ $if is_dir: /\ $ prev_file = file $if not loop.last: ,

$# $ git_url = f"{tx.origin}/code/projects/{project}.git" $#
$git_url 📋
$if readme:
$:mkdn(readme)
$if api_members := api_python.get("members"): $if readme:
$ _imports, _globals, _exceptions, _functions, _classes = api_members

$api_python["name"]

$if mod_doc := api_python["mod"].get("doc"): $:mkdn(mod_doc.partition("\n\n")[0]) $for module in set(dict(_imports).keys()).difference(stdlib_module_names).difference(set(api_python["descendants"].keys())): $module\ $if not loop.last: ,

$ metrics = api_python["mod"]["metrics"]

$metrics["lines"][1] LLOC, $if metrics["maintainability"] >= 19: highly maintainable $elif metrics["maintainability"] >= 9: moderately maintainable $else: difficult to maintain

$for func_name, func_details in _functions: $if func_name not in api_python["mod"]["all"]: $continue

$func_name\ $func_details["sig"]

$if func_doc := func_details.get("doc"): $:mkdn(func_doc.partition("\n\n")[0])
$var title = title $def aside(): $if pyproject: $ py_project = pyproject["tool"]["poetry"] $ py_project_name = py_project.pop("name") $# title += f" {py_project.pop('version')}"

$py_project.pop("description")
$if keywords := py_project.pop("keywords", None): $for keyword in keywords: $keyword\ $if not loop.last: ,

Package
$py_project_name $for source in py_project.pop("source", []): $if source["name"] == "main": @$source["url"].removeprefix("https://")

$if py_deps := py_project.pop("dependencies", None):

Requires
python $py_deps.pop("python")
$for dep, version in sorted(py_deps.items()): $ dep_nobreak = dep.replace("-", "‍-‍") $:dep_nobreak\ $if not loop.last: ,

$ plugins = py_project.pop("plugins", None) $ scripts = py_project.pop("scripts", None) $if plugins or scripts:

Provides
$if plugins: $if webapps := plugins.pop("webapps", None): webapps (\ $for webapp, webapp_callable in webapps.items(): $ webapp_path = webapp_callable.replace(".", "/").replace(":", "#") $webapp\ $if not loop.last: , \ ) $if websites := plugins.pop("websites", None): websites (\ $for website, website_callable in websites.items(): $ website_path = website_callable.replace(".", "/").replace(":", "#") $website\ $if not loop.last: , \ ) $if scripts: scripts (\ $for script, script_callable in scripts.items(): $ script_path = script_callable.replace(".", "/").replace(":", "#") $script\ $if not loop.last: , \ ) $if plugins or scripts:

$ license = py_project.pop("license") $ licenses = {"0BSD": 'BSD Zero Clause License', $ "BSD-2-Clause": 'BSD 2-Clause "Simplified" License', $ "BSD-3-Clause": 'BSD 3-Clause "Modified" License', $ "AGPL-3.0-or-later": 'GNU AGPL v3.0 or later'}

License
\ $:licenses[license]

$if package_releases: $ release, entry = package_releases[0]

Releases ($len(package_releases))
v$release

$if not (pyproject or package_releases):
$var aside = aside()