You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
3.7 KiB

#! /usr/bin/env python3
# -*- coding: utf-8 -*-
"""
This documentation is licensed under Creative Commons-BY-SA-4.0.
Please read the provided documentation/LICENSE file or visit
https://creativecommons.org/licenses/by-sa/4.0/legalcode
The documentation is built statically and does not belong to the normal build process with configure and make
Its updating is part of the development process, not packaging and running.
The correct out/ dir is already part of git.
.adoc is asciidoctor, not simple asciidoc.
"""
#Make the readme
import sys
sys.path.append("../../engine")
from config import METADATA
from subprocess import run
from os import getcwd
import os.path
assert os.path.exists(os.path.join(getcwd(), __file__)), (getcwd(), __file__)
#Readme
with open("readme.template", "r") as r:
template_readme = r.read()
template_readme = template_readme.replace("<name>", METADATA["name"])
template_readme = template_readme.replace("<version>", METADATA["version"])
template_readme = template_readme.replace("<shortname>", METADATA["shortName"])
template_readme = template_readme.replace("<description>", METADATA["description"])
template_readme = template_readme.replace("<dependencies>", METADATA["dependencies"])
template_readme = template_readme.replace("<author>", METADATA["author"])
with open ("../../README.md", "w") as w:
w.write(template_readme)
#http://www.pell.portland.or.us/~orc/Code/discount/
#pacman -S discount
#-toc is too much
run("markdown -f autolink -html5 -o index.html README.md".split(), cwd="../../")
#Append CSS style
with open ("../../index.html", "r") as r:
indexhtml = r.read()
with open ("../../index.html", "w") as rw:
new = f"""
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="template/documentation/css/normalize.css" type="text/css">
<link rel="stylesheet" href="template/documentation/css/style.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>{METADATA["name"]}: Git Readme </title>
</head>
<body>
{indexhtml}
</body>
</html>
"""
rw.write(new)
print ("Built /README.md")
#Documentation index
with open("index.adoc.template", "r") as r:
template_index = r.read()
template_index = template_index.replace("<name>", METADATA["name"])
template_index = template_index.replace("<shortname>", METADATA["shortName"])
template_index = template_index.replace("<version>", METADATA["version"])
template_index = template_index.replace("<author>", METADATA["author"])
with open ("../../documentation/index.adoc", "w") as w:
w.write(template_index)
#print ("Built /documentation/index.adoc. You still need to run /documentation/build-documentation.sh manually")
#print ("Built /documentation/index.adoc")
#Documentation
METADATA["supportedLanguages"].update({"English":""})
for language in METADATA["supportedLanguages"].keys():
language = language.lower()
try:
with open(f"{language}.adoc.template", "r") as r:
template = r.read()
except:
continue #language not yet supported as manual
for key, value in METADATA.items(): #all strings
if type(value) is str:
template = template.replace(f"<{key}>", value)
if language == "english":
template = template.replace("<english-only-description>", "== Introduction\n\n" + METADATA["description"])
with open (f"../../documentation/{language}.part.adoc", "r") as clientPart:
template = template.replace("<manual>", clientPart.read())
with open (f"../../documentation/{language}.adoc", "w") as w:
w.write(template)
#print ("Built /documentation. You still need to run /documentation/build-documentation.sh manually")
print ("Built template part of documentation.")