From 8ac6f9a19825cdd3af2c076ac9d843a9f05431d4 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 4 Jan 2024 13:43:50 -0600 Subject: [PATCH] Wrap scenario descriptions in docstrings (#787) Otherwise, the lines can get kind of long. --- crates/puffin-cli/tests/pip_install_scenarios.rs | 12 ++++++++---- scripts/scenarios/template.mustache | 4 +++- scripts/scenarios/update.py | 5 +++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/crates/puffin-cli/tests/pip_install_scenarios.rs b/crates/puffin-cli/tests/pip_install_scenarios.rs index 6dc1e5e96..167e0056e 100644 --- a/crates/puffin-cli/tests/pip_install_scenarios.rs +++ b/crates/puffin-cli/tests/pip_install_scenarios.rs @@ -110,7 +110,8 @@ fn requires_exact_version_does_not_exist() -> Result<()> { /// requires-greater-version-does-not-exist /// -/// The user requires a version of `a` greater than `1.0.0` but only smaller or equal versions exist +/// The user requires a version of `a` greater than `1.0.0` but only smaller or +/// equal versions exist /// /// requires-greater-version-does-not-exist-d34821ba /// ├── environment @@ -161,7 +162,8 @@ fn requires_greater_version_does_not_exist() -> Result<()> { /// requires-less-version-does-not-exist /// -/// The user requires a version of `a` less than `1.0.0` but only larger versions exist +/// The user requires a version of `a` less than `1.0.0` but only larger versions +/// exist /// /// requires-less-version-does-not-exist-4088ec1b /// ├── environment @@ -318,7 +320,8 @@ fn requires_direct_incompatible_versions() -> Result<()> { /// requires-transitive-incompatible-with-root-version /// -/// The user requires packages `a` and `b` but `a` requires a different version of `b` +/// The user requires packages `a` and `b` but `a` requires a different version of +/// `b` /// /// requires-transitive-incompatible-with-root-version-b3c83bbd /// ├── environment @@ -381,7 +384,8 @@ fn requires_transitive_incompatible_with_root_version() -> Result<()> { /// requires-transitive-incompatible-with-transitive /// -/// The user requires package `a` and `b`; `a` and `b` require different versions of `c` +/// The user requires package `a` and `b`; `a` and `b` require different versions of +/// `c` /// /// requires-transitive-incompatible-with-transitive-a35362d1 /// ├── environment diff --git a/scripts/scenarios/template.mustache b/scripts/scenarios/template.mustache index 28cf550ee..c43f0d295 100644 --- a/scripts/scenarios/template.mustache +++ b/scripts/scenarios/template.mustache @@ -20,7 +20,9 @@ mod common; /// {{name}} /// -/// {{description}} +{{#description_lines}} +/// {{.}} +{{/description_lines}} /// /// {{prefix}} {{#tree}} diff --git a/scripts/scenarios/update.py b/scripts/scenarios/update.py index 96ce0efc9..8d053c949 100755 --- a/scripts/scenarios/update.py +++ b/scripts/scenarios/update.py @@ -20,6 +20,7 @@ import json import shutil import subprocess import sys +import textwrap from pathlib import Path @@ -132,6 +133,10 @@ for index, scenario in enumerate(data["scenarios"]): if scenario["name"] == "example": data["scenarios"].pop(index) +# Wrap the description onto multiple lines +for scenario in data["scenarios"]: + scenario["description_lines"] = textwrap.wrap(scenario["description"], width=80) + # Render the template print("Rendering template...", file=sys.stderr) output = chevron_blue.render(template=TEMPLATE.read_text(), data=data, no_escape=True)