Skip to content

Commit

Permalink
Add doc example
Browse files Browse the repository at this point in the history
  • Loading branch information
yichengt900 committed Dec 5, 2023
1 parent 1ac3045 commit 1f92057
Show file tree
Hide file tree
Showing 11 changed files with 411 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/UsersGuide/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SOURCEDIR = source
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)
32 changes: 32 additions & 0 deletions docs/UsersGuide/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Steps to build and use the Sphinx documentation tool:

1) Get Sphinx, sphinxcontrib-bibtex, and the RTD theme installed on your desktop from
http://www.sphinx-doc.org/en/master/usage/installation.html
https://sphinxcontrib-bibtex.readthedocs.io/en/latest/quickstart.html#installation
https://pypi.org/project/sphinx-rtd-theme/

For example:
pip install sphinx
pip install sphinxcontrib-bibtex
pip install sphinx-rtd-theme

One approach that has worked to resolve "Module Not Found" errors for users with MacPorts package manager:
$ sudo port install py-six # may not be necessary
$ sudo port install py310-sphinxcontrib-bibtex
$ sudo port select --set sphinx py310-sphinx
$ sudo port install py310-sphinx_rtd_theme

py310 can be replaced with the user's version of Python (e.g., py39)

To build html:

$ cd MOM6_OBGC_examples/docs/UsersGuide
$ make clean && sphinx-build -b html source build

The "make html" command can often be used in place of the previous command.

Sphinx uses Latex to export the documentation as a PDF file. To build pdf:

make latexpdf

It will generate a PDF file in ./build/latex/<sphinx-project-name>.pdf
35 changes: 35 additions & 0 deletions docs/UsersGuide/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=source
set BUILDDIR=build

if "%1" == "" goto help

%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.http://sphinx-doc.org/
exit /b 1
)

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

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

:end
popd
3 changes: 3 additions & 0 deletions docs/UsersGuide/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sphinxcontrib-bibtex
sphinx_rtd_theme
docutils==0.16
31 changes: 31 additions & 0 deletions docs/UsersGuide/source/Introduction.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.. _Intro:

****************
Introduction
****************

This User's Guide provides guidance for setting and running the MOM6 Ocean Biogeochemical System.

The Ocean Biogeochemical component is based on :cite:t:`StockEtAl2019` (2019)

Disclaimer
*************

The United States Department of Commerce (DOC) GitHub project code is
provided on an “as is” basis and the user assumes responsibility for its
use. DOC has relinquished control of the information and no longer has a
responsibility to protect the integrity, confidentiality, or
availability of the information. Any claims against the Department of
Commerce stemming from the use of its GitHub project will be governed by
all applicable Federal laws. Any reference to specific commercial
products, processes, or services by service mark, trademark,
manufacturer, or otherwise, does not constitute or imply their
endorsement, recommendation, or favoring by the Department of Commerce.
The Department of Commerce seal and logo, or the seal and logo of a DOC
bureau, shall not be used in any manner to imply endorsement of any
commercial product or activity by DOC or the United States Government.

References
*************

.. bibliography:: references.bib
25 changes: 25 additions & 0 deletions docs/UsersGuide/source/_static/custom.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.red { color: red; }
.bolditalic {
font-family: "Courier New", Courier, monospace;
font-weight: bold;
font-style: italic;
}

.underline {
text-decoration: underline;
}

.bolditalic {
font-weight: bold;
font-style: italic;
}

table.align-default {
margin-left: 0px;
margin-right: auto;
}

table.align-center {
margin-left: 0px;
margin-right: auto;
}
21 changes: 21 additions & 0 deletions docs/UsersGuide/source/_static/theme_overrides.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* override table width restrictions */
@media screen and (min-width: 767px) {

.wy-table-responsive table td {
/* !important prevents the common CSS stylesheets from overriding
this as on RTD they are loaded after this stylesheet */
white-space: normal !important;
}

.wy-nav-content {
max-width: 100% !important;
}

/* .wy-table-responsive { */
/* overflow: visible !important; */
/* } */

}



4 changes: 4 additions & 0 deletions docs/UsersGuide/source/_templates/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
217 changes: 217 additions & 0 deletions docs/UsersGuide/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath('.'))



# -- Project information -----------------------------------------------------

project = 'MOM6_OBGC_examples Users Guide'
copyright = '2023, '
author = ' '

# The short X.Y version
version = 'develop'
# The full version, including alpha/beta/rc tags
release = 'Develop Branch Documentation'

numfig = True

# -- General configuration ---------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx_rtd_theme',
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.mathjax',
'sphinx.ext.ifconfig',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages',
'sphinx.ext.napoleon',
'sphinxcontrib.bibtex',
]

bibtex_bibfiles = ['references.bib']
#bibtex_bibfiles = ['refs.bib']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'
html_theme_path = ["_themes", ]

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}
html_theme_options = {"body_max_width": "none"}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
#html_static_path = []
html_static_path = ['_static']
html_context = {}

def setup(app):
app.add_css_file('custom.css') # may also be an URL
app.add_css_file('theme_overrides.css') # may also be a URL

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}


# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'MOM6_OBGC_examples'


# -- Options for LaTeX output ------------------------------------------------

latex_engine = 'pdflatex'
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
'pointsize': '11pt',

# Additional stuff for the LaTeX preamble.
'preamble': r'''
\usepackage{charter}
\usepackage[defaultsans]{lato}
\usepackage{inconsolata}
''',
# Release name prefix
'releasename': ' ',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'MOM6_OBGC_examples.tex', 'MOM6_OBGC_examples Users Guide',
' ', 'manual'),
]


# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'MOM6_OBGC_examples', 'MOM6_OBGC_examples Users Guide',
[author], 1)
]


# -- Options for Texinfo output ----------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'MOM6_OBGC_examples', 'MOM6_OBGC_examples Users Guide',
author, 'MOM6_OBGC_examples', 'One line description of project.',
'Miscellaneous'),
]


# -- Options for Epub output -------------------------------------------------

# Bibliographic Dublin Core info.
epub_title = project

# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''

# A unique identification for the text.
#
# epub_uid = ''

# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']


# -- Extension configuration -------------------------------------------------

# -- Options for intersphinx extension ---------------------------------------

# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
'MOM6_OBGC_examples': ('https://MOM6_OBGC_examples.readthedocs.io/en/latest/', None),
}

# -- Options for todo extension ----------------------------------------------

# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
Loading

0 comments on commit 1f92057

Please sign in to comment.