From 3ca5387dd7632cfb0dce1e6bff10dbe1be574ec2 Mon Sep 17 00:00:00 2001 From: gerard ketefian Date: Fri, 15 Nov 2024 09:20:06 -0700 Subject: [PATCH] Include "metplus" in autodoc_mock_imports list in the configuration file for sphinx (conf.py) (this will give sphinx access to METplus); remove definition of METPLUS_ROOT as an environment variable from the Makefile for the docs and instead define it in conf.py (as just a null string since it isn't actually used to load METplus). --- doc/Makefile | 8 +++----- doc/conf.py | 10 +++++++++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/doc/Makefile b/doc/Makefile index 33cb87212..a4fac61e1 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,12 +1,10 @@ # Makefile for Sphinx documentation -#SPHINXOPTS = -a -n -W -SPHINXOPTS = -a -n +SPHINXOPTS = -a -n -W SPHINXBUILD = sphinx-build SOURCEDIR = . BUILDDIR = build LINKCHECKDIR = $(BUILDDIR)/linkcheck -METPLUSROOT = /scratch1/NCEPDEV/nems/role.epic/spack-stack/spack-stack-1.6.0/envs/upp-addon-env/install/intel/2021.5.0/metplus-5.1.0-eznr7ze .PHONY: help Makefile linkcheck @@ -16,8 +14,8 @@ help: doc: make clean - export METPLUS_ROOT=$(METPLUSROOT) ; $(MAKE) linkcheck - export METPLUS_ROOT=$(METPLUSROOT) ; $(MAKE) html + $(MAKE) linkcheck + $(MAKE) html linkcheck: $(SPHINXBUILD) -b linkcheck $(SPHINXOPTS) $(SOURCEDIR) $(LINKCHECKDIR) diff --git a/doc/conf.py b/doc/conf.py index 2b5bf7b4d..e8f15567d 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -253,7 +253,7 @@ def setup(app): # -- Options for autodoc extension --------------------------------------- autodoc_mock_imports = ["f90nml","cartopy","mpl_toolkits.basemap","fill_jinja_template", - "matplotlib","numpy","uwtools","mpl_toolkits", + "matplotlib","numpy","uwtools","mpl_toolkits","metplus", ] logger = logging.getLogger(__name__) @@ -310,3 +310,11 @@ def warn_undocumented_members(app, what, name, obj, options, lines): 'fire-ug': ('https://fire-behavior.readthedocs.io/en/latest/%s', '%s'), } +# Define environment variables that need to exist when running the top-level code in python +# files (outside of functions, classes, etc.). +# +# METPLUS_ROOT just needs to exist in the environment; its value is not important since for +# the purpose of building the documentation, METplus is loaded by including "metplus" in +# the autodoc_mock_imports list above, not via use of the METPLUS_ROOT environment variable. +os.environ["METPLUS_ROOT"] = "" +