Skip to content

Commit

Permalink
insert program output directly into docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyburnett committed Dec 11, 2023
1 parent ddd71f1 commit b41ac1f
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 34 deletions.
1 change: 1 addition & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ python:
path: .
extra_requirements:
- docs
- sdp
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def check_sphinx_version(expected_version):
"sphinx_automodapi.smart_resolver",
"sphinx_asdf",
"sphinxcontrib.jquery",
"sphinxcontrib.programoutput",
]

if on_rtd:
Expand Down
32 changes: 2 additions & 30 deletions docs/roman/pipeline_static_preview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,37 +30,9 @@ Usage
``roman_static_preview`` includes two convenience commands, ``preview`` and ``thumbnail``, that set
default options to the static preview requirements.

.. code-block:: shell
❯ roman_static_preview preview --help
Usage: roman_static_preview preview [OPTIONS] INPUT [OUTPUT] [SHAPE]...
create a preview image with a north arrow overlay indicating orientation
Arguments:
INPUT path to ASDF file with 2D image data [required]
[OUTPUT] path to output image file
[SHAPE]... desired pixel resolution of output image [default: 1080, 1080]
Options:
--compass / --no-compass whether to draw a north arrow on the image
[default: compass]
--help Show this message and exit.
.. code-block:: shell
❯ roman_static_preview thumbnail --help
Usage: roman_static_preview thumbnail [OPTIONS] INPUT [OUTPUT] [SHAPE]...
Arguments:
INPUT path to ASDF file with 2D image data [required]
[OUTPUT] path to output image file
[SHAPE]... desired pixel resolution of output image [default: 300, 300]
.. program-output:: roman_static_preview preview --help

Options:
--compass / --no-compass whether to draw a north arrow on the image
[default: no-compass]
--help Show this message and exit.
.. program-output:: roman_static_preview thumbnail --help

Examples
--------
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ docs = [
'sphinx-rtd-theme',
'stsci-rtd-theme',
'sphinx-autobuild',
'sphinxcontrib-programoutput',
'tomli; python_version <="3.11"',
]
test = [
Expand Down
17 changes: 13 additions & 4 deletions romancal/scripts/static_preview.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
import asdf
import numpy

DEFAULT_PREVIEW_SHAPE = (1080, 1080)
DEFAULT_THUMBNAIL_SHAPE = (300, 300)


def command():
try:
Expand Down Expand Up @@ -33,14 +36,15 @@ def preview(
shape: Annotated[
Optional[tuple[int, int]],
typer.Argument(help="desired pixel resolution of output image"),
] = (1080, 1080),
] = DEFAULT_PREVIEW_SHAPE,
compass: Annotated[
Optional[bool],
typer.Option(help="whether to draw a north arrow on the image"),
] = True,
):
"""
create a preview image with a north arrow overlay indicating orientation
f"""
create a {DEFAULT_PREVIEW_SHAPE} preview image from an ASDF file
containing a Roman ``ImageModel``, with a north arrow overlay indicating orientation
"""

if output is None:
Expand Down Expand Up @@ -76,12 +80,17 @@ def thumbnail(
shape: Annotated[
Optional[tuple[int, int]],
typer.Argument(help="desired pixel resolution of output image"),
] = (300, 300),
] = DEFAULT_THUMBNAIL_SHAPE,
compass: Annotated[
Optional[bool],
typer.Option(help="whether to draw a north arrow on the image"),
] = False,
):
f"""
create a {DEFAULT_THUMBNAIL_SHAPE} thumbnail image from an ASDF file
containing a Roman ``ImageModel``
"""

if output is None:
output = Path.cwd()
if output.is_dir():
Expand Down

0 comments on commit b41ac1f

Please sign in to comment.