Skip to content

Commit

Permalink
Add command to regenerate breeze command output images
Browse files Browse the repository at this point in the history
  • Loading branch information
potiuk committed Jun 5, 2022
1 parent ac8a790 commit 7c283a5
Show file tree
Hide file tree
Showing 6 changed files with 327 additions and 180 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,7 @@ licenses/LICENSES-ui.txt

# Packaged breeze on Windows
/breeze.exe

# Generated out dir

/out
11 changes: 11 additions & 0 deletions BREEZE.rst
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,17 @@ of help of the commands only when they change.
:width: 100%
:alt: Breeze command-hash-export

Regenerating images for documentation
=====================================

This documentation contains exported images with "help" of their commands and parameters. You can
regenerate all those images (which might be needed in case new version of rich is used) via
``regenerate-breeze-images`` command.

.. image:: ./images/breeze/output-regenerate-command-images.svg
:width: 100%
:alt: Breeze regenerate-command-images


Starting complete Airflow installation
======================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
)
from airflow_breeze.utils.recording import output_file_for_recording
from airflow_breeze.utils.reinstall import ask_to_reinstall_breeze, reinstall_breeze, warn_non_editable
from airflow_breeze.utils.run_utils import run_command
from airflow_breeze.utils.run_utils import assert_pre_commit_installed, run_command
from airflow_breeze.utils.visuals import ASCIIART, ASCIIART_STYLE

CONFIGURATION_AND_MAINTENANCE_COMMANDS = {
Expand All @@ -75,6 +75,7 @@
"resource-check",
"free-space",
"fix-ownership",
"regenerate-command-images",
"command-hash-export",
"version",
],
Expand Down Expand Up @@ -533,3 +534,27 @@ def remove_autogenerated_code(script_path: str):

def backup(script_path_file: Path):
shutil.copy(str(script_path_file), str(script_path_file) + ".bak")


@main.command(name="regenerate-command-images", help="Regenerate breeze command images.")
@option_verbose
@option_dry_run
def regenerate_command_images(verbose: bool, dry_run: bool):
assert_pre_commit_installed(verbose=verbose)
perform_environment_checks(verbose=verbose)
try:
(AIRFLOW_SOURCES_ROOT / "images" / "breeze" / "output-commands-hash.txt").unlink()
except FileNotFoundError:
# when we go to Python 3.8+ we can add missing_ok = True instead of try/except
pass
command_to_execute = [sys.executable, "-m", "pre_commit", 'run', 'update-breeze-file', '--all-files']
env = os.environ.copy()
run_command(
command_to_execute,
verbose=verbose,
dry_run=dry_run,
check=False,
no_output_dump_on_exception=True,
text=True,
env=env,
)
2 changes: 1 addition & 1 deletion images/breeze/output-commands-hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5f6d42eb170dba8f19b375f8e7c588b3
4741c257cb7cb98fd268d443cfa12135
Loading

0 comments on commit 7c283a5

Please sign in to comment.