mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
84 lines
2.4 KiB
Python
84 lines
2.4 KiB
Python
import ast
|
|
import datetime
|
|
import subprocess
|
|
|
|
version = open("../debian/changelog").readlines()[0].split()[1].strip("()")
|
|
today = datetime.datetime.now().strftime("%d/%m/%Y")
|
|
|
|
|
|
def get_current_commit():
|
|
p = subprocess.Popen(
|
|
"git rev-parse --verify HEAD",
|
|
shell=True,
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.STDOUT,
|
|
)
|
|
stdout, stderr = p.communicate()
|
|
|
|
current_commit = stdout.strip().decode("utf-8")
|
|
return current_commit
|
|
|
|
|
|
current_commit = get_current_commit()
|
|
|
|
|
|
print(
|
|
f"""---
|
|
title: Config Panels
|
|
template: docs
|
|
taxonomy:
|
|
category: docs
|
|
routes:
|
|
default: '/packaging_config_panels'
|
|
---
|
|
|
|
Doc auto-generated by [this script](https://github.com/YunoHost/yunohost/blob/{current_commit}/doc/generate_configpanel_doc.py) on {today} (YunoHost version {version})
|
|
|
|
## Glossary
|
|
|
|
You may encounter some named types which are used for simplicity.
|
|
|
|
- `Translation`: a translated property
|
|
- used for properties: `ask`, `help` and `Pattern.error`
|
|
- a `dict` with locales as keys and translations as values:
|
|
```toml
|
|
ask.en = "The text in english"
|
|
ask.fr = "Le texte en français"
|
|
```
|
|
It is not currently possible for translators to translate those string in weblate.
|
|
- a single `str` for a single english default string
|
|
```toml
|
|
help = "The text in english"
|
|
```
|
|
- `JSExpression`: a `str` JS expression to be evaluated to `true` or `false`:
|
|
- used for properties: `visible` and `enabled`
|
|
- operators availables: `==`, `!=`, `>`, `>=`, `<`, `<=`, `!`, `&&`, `||`, `+`, `-`, `*`, `/`, `%` and `match()`
|
|
- [examples available in the advanced section of Options](/packaging_apps_options#advanced-use-cases)
|
|
"""
|
|
)
|
|
|
|
|
|
fname = "../src/utils/configpanel.py"
|
|
content = open(fname).read()
|
|
|
|
# NB: This magic is because we want to be able to run this script outside of a YunoHost context,
|
|
# in which we cant really 'import' the file because it will trigger a bunch of moulinette/yunohost imports...
|
|
tree = ast.parse(content)
|
|
|
|
OptionClasses = reversed(
|
|
[
|
|
c
|
|
for c in tree.body
|
|
if isinstance(c, ast.ClassDef)
|
|
and c.name in {"SectionModel", "PanelModel", "ConfigPanelModel"}
|
|
]
|
|
)
|
|
|
|
for c in OptionClasses:
|
|
doc = ast.get_docstring(c)
|
|
print("")
|
|
print("----------------")
|
|
print(f"## {c.name.replace('Model', '')}")
|
|
print("")
|
|
print(doc)
|
|
print("")
|