mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
ci: fix helpers doc regen + add auto app resource doc
This commit is contained in:
parent
2eb7da0603
commit
6520d82e4d
2 changed files with 41 additions and 8 deletions
|
@ -13,15 +13,18 @@ generate-helpers-doc:
|
|||
script:
|
||||
- cd doc
|
||||
- python3 generate_helper_doc.py
|
||||
- python3 generate_resource_doc.py > resources.md
|
||||
- hub clone https://$GITHUB_TOKEN:x-oauth-basic@github.com/YunoHost/doc.git doc_repo
|
||||
- cp helpers.md doc_repo/pages/06.contribute/10.packaging_apps/11.helpers/packaging_apps_helpers.md
|
||||
- cp helpers.md doc_repo/pages/06.contribute/10.packaging_apps/80.resources/11.helpers/packaging_apps_helpers.md
|
||||
- cp resources.md doc_repo/pages/06.contribute/10.packaging_apps/80.resources/15.appresources/packaging_apps_resources.md
|
||||
- cd doc_repo
|
||||
# replace ${CI_COMMIT_REF_NAME} with ${CI_COMMIT_TAG} ?
|
||||
- hub checkout -b "${CI_COMMIT_REF_NAME}"
|
||||
- hub commit -am "[CI] Helper for ${CI_COMMIT_REF_NAME}"
|
||||
- hub pull-request -m "[CI] Helper for ${CI_COMMIT_REF_NAME}" -p # GITHUB_USER and GITHUB_TOKEN registered here https://gitlab.com/yunohost/yunohost/-/settings/ci_cd
|
||||
- hub commit -am "[CI] Update app helpers/resources for ${CI_COMMIT_REF_NAME}"
|
||||
- hub pull-request -m "[CI] Update app helpers/resources for ${CI_COMMIT_REF_NAME}" -p # GITHUB_USER and GITHUB_TOKEN registered here https://gitlab.com/yunohost/yunohost/-/settings/ci_cd
|
||||
artifacts:
|
||||
paths:
|
||||
- doc/helpers.md
|
||||
- doc/resources.md
|
||||
only:
|
||||
- tags
|
||||
|
|
|
@ -1,11 +1,41 @@
|
|||
from yunohost.utils.resources import AppResourceClassesByType
|
||||
import ast
|
||||
|
||||
resources = sorted(AppResourceClassesByType.values(), key=lambda r: r.priority)
|
||||
print("""---
|
||||
title: App resources
|
||||
template: docs
|
||||
taxonomy:
|
||||
category: docs
|
||||
routes:
|
||||
default: '/packaging_apps_resources'
|
||||
---
|
||||
|
||||
for klass in resources:
|
||||
doc = klass.__doc__.replace("\n ", "\n")
|
||||
""")
|
||||
|
||||
|
||||
fname = "../src/utils/resources.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)
|
||||
|
||||
ResourceClasses = [c for c in tree.body if isinstance(c, ast.ClassDef) and c.bases and c.bases[0].id == 'AppResource']
|
||||
|
||||
ResourceDocString = {}
|
||||
|
||||
for c in ResourceClasses:
|
||||
|
||||
assert c.body[1].targets[0].id == "type"
|
||||
resource_id = c.body[1].value.value
|
||||
docstring = ast.get_docstring(c)
|
||||
|
||||
ResourceDocString[resource_id] = docstring
|
||||
|
||||
|
||||
for resource_id, doc in sorted(ResourceDocString.items()):
|
||||
doc = doc.replace("\n ", "\n")
|
||||
|
||||
print("")
|
||||
print(f"## {klass.type.replace('_', ' ').title()}")
|
||||
print(f"## {resource_id.replace('_', ' ').title()}")
|
||||
print("")
|
||||
print(doc)
|
||||
|
|
Loading…
Add table
Reference in a new issue