Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Confirm the docs build works on PRs touching docs or code
name: ReadTheDocs/Sphinx Validation
on:
pull_request:
paths: ["docs/**", "cwmscli/**", "pyproject.toml"]
push:
branches: [main]
paths: ["docs/**", "cwmscli/**", "pyproject.toml"]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install deps
run: |
python -m pip install -U pip
pip install -r docs/requirements.txt
pip install .
- name: Sphinx build (treat warnings as errors)
run: sphinx-build -nW -b html docs docs/_build/html
- name: Link check (optional)
run: sphinx-build -b linkcheck docs docs/_build/linkcheck
16 changes: 16 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
version: 2

build:
os: ubuntu-24.04
tools:
python: "3.12"

sphinx:
configuration: docs/conf.py

python:
install:
- method: pip
path: .
- requirements: docs/requirements.txt
formats: [html, pdf]
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
# cwms-cli

command line utilities used for Corps Water Management Systems (CWMS) processes

[![Docs](https://readthedocs.org/projects/cwms-cli/badge/?version=latest)](https://cwms-cli.readthedocs.io/en/latest/)

## Install

```sh
pip install git+https://github.com/HydrologicEngineeringCenter/cwms-cli.git@main
```

## Command line implementation

```sh
cwms-cli --help
```

15 changes: 13 additions & 2 deletions cwmscli/commands/commands_cwms.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,16 @@ def csv2cwms_cmd(**kwargs):
# ================================================================================
# BLOB
# ================================================================================
@click.group("blob", help="Manage CWMS Blobs (upload, download, delete, update, list)")
@click.group(
"blob",
help="Manage CWMS Blobs (upload, download, delete, update, list)",
epilog="""
* Store a PDF/image as a CWMS blob with optional description
* Download a blob by id to your local filesystem
* Update a blob's name/description
* Bulk list blobs for an office
""",
)
@requires(reqs.cwms)
def blob_group():
pass
Expand Down Expand Up @@ -190,7 +199,9 @@ def update_cmd(**kwargs):
# ================================================================================
@blob_group.command("list", help="List blobs with optional filters and sorting")
# TODO: Add link to regex docs when new CWMS-DATA site is deployed to PROD
@click.option("--blob-id-like", help="LIKE filter for blob ID (e.g., '*PNG').")
@click.option(
"--blob-id-like", help="LIKE filter for blob ID (e.g., ``*PNG``)."
) # Escape the wildcard/asterisk for RTD generation with double backticks
@click.option(
"--columns",
multiple=True,
Expand Down
4 changes: 1 addition & 3 deletions cwmscli/utils/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,14 @@ def requires(*requirements):
"package": "cwms-python",
"version": "0.8.0",
"desc": "CWMS REST API Python client",
"link": "https://github.com/USACE/cwms-python"
"link": "https://github.com/hydrologicengineeringcenter/cwms-python"
},
{
"module": "requests",
"version": "2.30.0",
"desc": "Required for HTTP API access"
}
)
def my_command():
...
"""

def decorator(func):
Expand Down
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
6 changes: 6 additions & 0 deletions docs/cli.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CLI reference
=============

.. click:: cwmscli.__main__:cli
:prog: cwms-cli
:nested: full
8 changes: 8 additions & 0 deletions docs/cli/blob.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Blob commands
=============

Overview, examples, etc…

.. click:: cwmscli.commands.commands_cwms:blob_group
:prog: cwms-cli blob
:nested: full
37 changes: 37 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import importlib.metadata as ilmd
import os
import sys

# Make cwms-cli importable for autodoc/sphinx-click
sys.path.insert(0, os.path.abspath(".."))

project = "cwms-cli"

# Get the installed package version without shadowing Sphinx's "version"
try:
pkg_version = ilmd.version("cwms-cli")
except ilmd.PackageNotFoundError:
pkg_version = "0.0.0"

release = pkg_version
version = pkg_version

extensions = [
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
"sphinx.ext.intersphinx",
"sphinx_click",
]

autosummary_generate = True
autodoc_typehints = "description"

intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
}

html_theme = "sphinx_rtd_theme"

# autodoc_mock_imports = ["cwms", "pandas", "requests"]
5 changes: 5 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.. toctree::
:maxdepth: 2

cli
cli/blob
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.https://www.sphinx-doc.org/
exit /b 1
)

if "%1" == "" goto help

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
3 changes: 3 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sphinx
sphinx-rtd-theme
sphinx-click
Loading