From c268c54cb07cbe9c99d8c870461e5fbac5cbd28c Mon Sep 17 00:00:00 2001 From: Pierre Camilleri <22995923+pierrecamilleri@users.noreply.github.com> Date: Wed, 26 Jun 2024 14:25:26 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=B5=20renamings=20and=20fix=20newline?= =?UTF-8?q?=20at=20start=20of=20description?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/frformat/nomenclature_acte_format.py | 3 +- utils/generate_docs.py | 41 ++++++++++-------------- 2 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/frformat/nomenclature_acte_format.py b/src/frformat/nomenclature_acte_format.py index 12f1f0c..5235c5a 100644 --- a/src/frformat/nomenclature_acte_format.py +++ b/src/frformat/nomenclature_acte_format.py @@ -29,8 +29,7 @@ def INVALID_PREFIX(prefix: str) -> str: name = "Nomenclature des actes" -description = """ - Document de référence dans les spécifications SCDL : +description = """Document de référence dans les spécifications SCDL : http://www.moselle.gouv.fr/content/download/1107/7994/file/nomenclature.pdf Dans la nomenclature Actes, les valeurs avant le '/' sont : diff --git a/utils/generate_docs.py b/utils/generate_docs.py index 302ce6c..32e687f 100644 --- a/utils/generate_docs.py +++ b/utils/generate_docs.py @@ -39,41 +39,34 @@ ] -def text_formatting(text): - new_text = text.strip() - formatted_description = "" - text_array = new_text.splitlines() - - if len(text_array) == 1: - formatted_description = text_array[0] - return formatted_description - - for line in text_array: - if line is text_array[0] and line != "": - formatted_description = line - else: - formatted_description = formatted_description + "
" + line - - return formatted_description - - -def generate_validators_documentation(all_validators): +def generate_formats_documentation(all_formats): documentation = [] - for validator in all_validators: + for format in all_formats: doc = { - "class_name": validator.__name__, - "name": validator.metadata.name, - "description": text_formatting(validator.metadata.description), + "class_name": format.__name__, + "name": format.metadata.name, + "description": description_formatting(format.metadata.description), } documentation.append(doc) return documentation +def description_formatting(description): + text_array = description.strip().splitlines() + + formatted_description = text_array[0] if len(text_array) > 0 else "" + + for line in text_array[1:]: + formatted_description = formatted_description + "
" + line + + return formatted_description + + if __name__ == "__main__": TEMPLATE_FILE = "formats_template.md.jinja" OUTPUT_FILE = "./docs/formats.md" - documentation = generate_validators_documentation(all_validators) + documentation = generate_formats_documentation(all_validators) template_loader = jinja2.FileSystemLoader(searchpath="./utils/") template_env = jinja2.Environment(loader=template_loader, trim_blocks=True)