Skip to content

Commit

Permalink
Merge pull request spacetelescope#3286 from pllim/doc-inject-cli
Browse files Browse the repository at this point in the history
DOC: Auto-inject CLI help into user doc
  • Loading branch information
pllim authored Nov 13, 2024
2 parents 3b00695 + ee37b80 commit 4a43a8c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 18 additions & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@
# Thus, any C-extensions that are needed to build the documentation will *not*
# be accessible, and the documentation will not build correctly.

import datetime
import subprocess
import sys
import datetime

from docutils import nodes
from sphinx.util.docutils import SphinxDirective

from jdaviz import __version__

Expand Down Expand Up @@ -293,3 +296,17 @@

# Options for linkcheck
linkcheck_ignore = ['https://github.com/spacetelescope/jdaviz/settings/branches']


# -- Custom directive -------------------------------------------

class JdavizCLIHelpDirective(SphinxDirective):

def run(self):
help_text = subprocess.check_output(["jdaviz", "--help"], encoding="utf-8")
paragraph_node = nodes.literal_block(text=help_text)
return [paragraph_node]


def setup(app):
app.add_directive('jdavizclihelp', JdavizCLIHelpDirective)
2 changes: 2 additions & 0 deletions docs/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ To see the syntax and usage, from a terminal, type::

jdaviz --help

.. jdavizclihelp::

Typical usage to load a file into a desired configuration::

jdaviz --layout=[imviz|specviz|cubeviz|mosviz|specviz2d] /path/to/data/file
Expand Down

0 comments on commit 4a43a8c

Please sign in to comment.