From f5bcd9d692d6ab0b12ec56927979f3f59f6387b0 Mon Sep 17 00:00:00 2001 From: very-doge-wow Date: Sun, 17 Mar 2024 18:31:29 +0100 Subject: [PATCH] fix: indent of examples --- reader/chart_reader.py | 4 ++-- reader/chart_reader_test.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/reader/chart_reader.py b/reader/chart_reader.py index ebb9a1c..c1edfe8 100644 --- a/reader/chart_reader.py +++ b/reader/chart_reader.py @@ -176,8 +176,8 @@ def generate_values_doc(doc: dict, helm_chart_path: str) -> dict: # check if the next line still is a comment, if so add it to docstring while values_lines[i + 1].lstrip().startswith("#"): # remove first char (#) and add newline - calc = values_lines[i + 1].replace(" ", "", indent_num).replace("#", "", 1) + "\n" - if calc[0] == " ": + calc = values_lines[i + 1].replace("#", "", 1).replace(" ", "", indent_num) + "\n" + if indent_num == 0 and calc[0] == " ": calc = calc.replace(" ", "", 1) doc_string += calc i += 1 diff --git a/reader/chart_reader_test.py b/reader/chart_reader_test.py index 6be676d..c59db1a 100644 --- a/reader/chart_reader_test.py +++ b/reader/chart_reader_test.py @@ -210,7 +210,7 @@ def test_generate_values_docs_nested(): result = chart_reader.generate_values_doc(doc, "test/values-nested-docs") print(result) assert_that(result["values"], contains_inanyorder( - {'name': 'image', 'description': 'which image to deploy\n', 'default': {'image': {'repository': 'nginx', 'pullPolicy': 'IfNotPresent', 'tag': ''}}, 'example': '\nimage:\n repository: very-doge-wow/stella\n pullPolicy: IfNotPresent\n'}, {'name': 'image.tag', 'description': 'Overrides the image tag whose default is the chart appVersion.\n', 'default': {'image': {'tag': ''}}, 'example': '\nimage:\n tag: "latest"\n'}, {'name': 'replicaCount', 'description': 'how many replicas to deploy\n', 'default': {'replicaCount': 1}, 'example': ''} + {'name': 'image', 'description': 'which image to deploy\n', 'default': {'image': {'repository': 'nginx', 'pullPolicy': 'IfNotPresent', 'tag': ''}}, 'example': '\nimage:\n repository: very-doge-wow/stella\n pullPolicy: IfNotPresent\n'}, {'name': 'image.tag', 'description': 'Overrides the image tag whose default is the chart appVersion.\n', 'default': {'image': {'tag': ''}}, 'example': '\nimage:\n tag: "latest"\n'}, {'name': 'replicaCount', 'description': 'how many replicas to deploy\n', 'default': {'replicaCount': 1}, 'example': ''} ))