diff --git a/.github/workflows/formatting.yml b/.github/workflows/formatting.yml
index 542ce49c0..eb4282c71 100644
--- a/.github/workflows/formatting.yml
+++ b/.github/workflows/formatting.yml
@@ -19,12 +19,13 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.12"
- - name: Install CFEngine CLI
+ - name: Install tools
run: |
- pipx install cfengine
+ pipx install cfengine black
- name: Run formatting command to (hopefully not) make changes
run: |
cfengine dev docs-format
+ black .
- name: Check output.log file for warnings
run: |
! grep WARNING output.log
diff --git a/generator/_scripts/cfdoc_images_path_resolver.py b/generator/_scripts/cfdoc_images_path_resolver.py
index 7af389931..6f95dbf6d 100644
--- a/generator/_scripts/cfdoc_images_path_resolver.py
+++ b/generator/_scripts/cfdoc_images_path_resolver.py
@@ -1,44 +1,49 @@
import re
import os
+
def run(config):
- """ Fixes images paths
- The markdown files other than _index.markdown need img tag src values adjusted if they are relative.
- They need to reference the parent directory with ../ prefixed to the relative location of the image file.
+ """Fixes images paths
+ The markdown files other than _index.markdown need img tag src values adjusted if they are relative.
+ They need to reference the parent directory with ../ prefixed to the relative location of the image file.
"""
markdown_files = config["markdown_files"]
-
+
for file in markdown_files:
process(file)
+
def load_references(file_path):
try:
- with open(file_path, 'r', encoding='utf-8') as f:
+ with open(file_path, "r", encoding="utf-8") as f:
return f.read()
except FileNotFoundError:
return ""
+
def process(file_path):
"""Process a markdown file to fix image paths"""
try:
- with open(file_path, 'r', encoding='utf-8') as f:
+ with open(file_path, "r", encoding="utf-8") as f:
content = f.read()
-
+
is_index_file = os.path.basename(file_path) == "_index.markdown"
-
+
if is_index_file:
# For _index.markdown files, leave image paths as is. As they are on the same level
return
-
+
# Pattern to match img src with relative paths that need fixing
# skips ../, /, or http
img_pattern = r']*?)src="(?!\.\.\/|\/|https?:\/\/)([^"]+?)"([^>]*?)>'
-
+
# Replace with ../ added to the path
- modified_content = re.sub(img_pattern, r'
', content, flags=re.IGNORECASE);
+ modified_content = re.sub(
+ img_pattern, r'
', content, flags=re.IGNORECASE
+ )
if modified_content != content:
- with open(file_path, 'w', encoding='utf-8') as f:
+ with open(file_path, "w", encoding="utf-8") as f:
f.write(modified_content)
-
+
except Exception as e:
print(f"Error processing {file_path}: {e}")
diff --git a/generator/_scripts/cfdoc_metadata.py b/generator/_scripts/cfdoc_metadata.py
index 57ec6bcd8..e67154081 100644
--- a/generator/_scripts/cfdoc_metadata.py
+++ b/generator/_scripts/cfdoc_metadata.py
@@ -23,6 +23,7 @@
import os
import json
+
def run(config):
config["syntax_path"] = config["project_directory"] + "/_generated/syntax_map.json"
config["syntax_map"] = json.load(open(config["syntax_path"], "r"))
@@ -31,6 +32,7 @@ def run(config):
for file in markdown_files:
processMetaData(file, config)
+
# parse meta data lines, remove existing header for later reconstruction
def parseHeader(lines):
header = {}
diff --git a/generator/_scripts/cfdoc_patch_header_nav.py b/generator/_scripts/cfdoc_patch_header_nav.py
index 7786a6cb6..5b2fd121d 100644
--- a/generator/_scripts/cfdoc_patch_header_nav.py
+++ b/generator/_scripts/cfdoc_patch_header_nav.py
@@ -54,7 +54,10 @@ def patch(current_branch):
for branch in data["docs"]:
print(
'