diff --git a/CHANGELOG.md b/CHANGELOG.md index 59b4241de..36ceee5bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Unhandled exception in telemetry when username could not be inferred on Windows - Metadata is now correctly updated for hybrid spaces - Unintended deactivation of telemetry due to import problem +- Line wrapping in examples ## [0.7.3] - 2024-02-09 ### Added diff --git a/docs/scripts/utils.py b/docs/scripts/utils.py index 83e8dd18c..bcdd3f935 100644 --- a/docs/scripts/utils.py +++ b/docs/scripts/utils.py @@ -2,6 +2,7 @@ import pathlib import shutil +import textwrap from subprocess import DEVNULL, STDOUT, check_call from tqdm import tqdm @@ -158,16 +159,26 @@ def create_example_documentation(example_dest_dir: str, ignore_examples: bool): ) # CLEANUP - # Remove all lines that try to include a png file markdown_path = file.with_suffix(".md") + # We wrap lines which are too long as long as they do not contain a link. + # To discover whether a line contains a link, we check if the string "](" + # is contained. with open(markdown_path, "r", encoding="UTF-8") as markdown_file: - lines = markdown_file.readlines() - + content = markdown_file.read() + wrapped_lines = [] + for line in content.splitlines(): + if "![svg]" in line or "![png]" in line or "
88 and "](" not in line: + wrapped = textwrap.wrap(line, width=88) + wrapped_lines.extend(wrapped) + else: + wrapped_lines.append(line) + + # Add a manual new line to each of the lines + lines = [line + "\n" for line in wrapped_lines] # Delete lines we do not want to have in our documentation - lines = [line for line in lines if "![svg]" not in line] - lines = [line for line in lines if "![png]" not in line] - lines = [line for line in lines if "