72 lines
2.7 KiB
Python
Executable file
72 lines
2.7 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
"""
|
|
Génère une section de documentation "prerequisites" pour un tutoriel Rougail,
|
|
en utilisant une plage de versions (tags git) spécifiée en arguments.
|
|
|
|
Usage:
|
|
python helper_prerequisites.py <start_version> <end_version> <branch>
|
|
|
|
Arguments:
|
|
start_version (str) : La version de début (tag git) pour la plage de tags.
|
|
end_version (str) : La version de fin (tag git) pour la plage de tags.
|
|
branch (str) : La branche du dépôt git à mentionner dans la documentation.
|
|
|
|
Exemple:
|
|
|
|
./helper_prerequisites.py v1.1_080 v1.1_085 1.1
|
|
|
|
"""
|
|
|
|
import sys
|
|
|
|
def generate_prerequisites(start_version: str, end_version: str, branch: str) -> str:
|
|
"""
|
|
Génère une section de documentation "prerequisites" pour une plage de versions donnée.
|
|
|
|
Args:
|
|
start_version (str): La version de début (tag git) pour la plage.
|
|
end_version (str): La version de fin (tag git) pour la plage.
|
|
branch (str): La branche du dépôt git à mentionner.
|
|
|
|
Returns:
|
|
str: La section de documentation formatée.
|
|
"""
|
|
template = """.. prerequisites:: Prerequisites
|
|
|
|
- We assume that Rougail's library is :ref:`installed <installation>` on your computer.
|
|
|
|
- It is possible to retrieve the current state of the various Rougail files manipulated in this tutorial step
|
|
by checking out the corresponding tag of the `rougail-tutorials` git repository.
|
|
Each tag corresponds to a stage of progress in the tutorial.
|
|
Of course, you can also decide to copy/paste or download the tutorial files contents while following the tutorial steps.
|
|
|
|
If you want to follow this tutorial with the help of the corresponding :tutorial:`rougail-tutorials git repository <src/branch/{branch}>`,
|
|
this workshop page corresponds to the tags :tutorial:`{start_version} <src/tag/{start_version}/README.md>` to :tutorial:`{end_version} <src/tag/{end_version}/README.md>`
|
|
in the repository.
|
|
|
|
::
|
|
|
|
git clone https://forge.cloud.silique.fr/stove/rougail-tutorials.git
|
|
git switch --detach {start_version}
|
|
"""
|
|
return template.format(
|
|
start_version=start_version,
|
|
end_version=end_version,
|
|
branch=branch
|
|
)
|
|
|
|
def main() -> None:
|
|
"""Point d'entrée principal du script."""
|
|
if len(sys.argv) != 4:
|
|
print("Erreur : Trois arguments doivent être spécifiés : <start_version> <end_version> <branch>.")
|
|
print(f"Usage: {sys.argv[0]} <start_version> <end_version> <branch>")
|
|
sys.exit(1)
|
|
|
|
start_version = sys.argv[1]
|
|
end_version = sys.argv[2]
|
|
branch = sys.argv[3]
|
|
print(generate_prerequisites(start_version, end_version, branch))
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|