Skip to content

Commit

Permalink
Added documentation skeleton. (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
byrdie authored Aug 10, 2024
1 parent b2a04d5 commit 62b8bd3
Show file tree
Hide file tree
Showing 12 changed files with 348 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: 2

build:
os: ubuntu-22.04
tools:
python: "3.12"
apt_packages:
- graphviz

sphinx:
configuration: docs/conf.py

python:
install:
- method: pip
path: .
extra_requirements:
- doc
2 changes: 2 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_autosummary/
_build/
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)
Empty file added docs/_static/.gitkeep
Empty file.
40 changes: 40 additions & 0 deletions docs/_templates/class_custom.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{ name | escape | underline}}

.. currentmodule:: {{ module }}

.. autoclass:: {{ fullname }}
:members:
:show-inheritance:
:inherited-members:
:undoc-members:
:member-order: groupwise

{% block attributes %}
{% if attributes %}
.. rubric:: {{ _('Attributes') }}

.. autosummary::
{% for item in attributes %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block methods %}
{% if methods %}
.. rubric:: {{ _('Methods') }}

.. autosummary::
{% for item in methods %}
~{{ name }}.{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block dia %}
.. rubric:: {{ _('Inheritance Diagram') }}

.. inheritance-diagram:: {{ fullname }}
:parts: 1
{% endblock %}

5 changes: 5 additions & 0 deletions docs/_templates/function_custom.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{ name | escape | underline}}

.. currentmodule:: {{ module }}

.. autofunction:: {{ fullname }}
69 changes: 69 additions & 0 deletions docs/_templates/module_custom.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{{ name | escape | underline}}

.. automodule:: {{ fullname }}

{% block attributes %}
{% if attributes %}
.. rubric:: Module Attributes

.. autosummary::
:toctree:
{% for item in attributes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block functions %}
{% if functions %}
.. rubric:: {{ _('Functions') }}

.. autosummary::
:toctree:
:template: function_custom.rst
{% for item in functions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block classes %}
{% if classes %}
.. rubric:: {{ _('Classes') }}

.. autosummary::
:toctree:
:template: class_custom.rst
{% for item in classes %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block exceptions %}
{% if exceptions %}
.. rubric:: {{ _('Exceptions') }}

.. autosummary::
:toctree:
{% for item in exceptions %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}

{% block modules %}
{% if modules %}
.. rubric:: Modules

.. autosummary::
:toctree:
:template: module_custom.rst
:recursive:
{% for item in modules %}
{{ item }}
{%- endfor %}
{% endif %}
{% endblock %}


98 changes: 98 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- 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

package_path = os.path.abspath('../')
sys.path.insert(0, package_path)
os.environ['PYTHONPATH'] = ';'.join((package_path, os.environ.get('PYTHONPATH', '')))

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

project = 'SDO'
copyright = '2024, Roy T. Smart'
author = 'Roy T. Smart'

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

# 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.ext.napoleon',
'sphinx.ext.autodoc',
'sphinx.ext.autosummary',
'sphinx.ext.intersphinx',
'sphinx.ext.inheritance_diagram',
'sphinx.ext.viewcode',
'sphinxcontrib.bibtex',
'jupyter_sphinx',
]
autosummary_generate = True # Turn on sphinx.ext.autosummary
autosummary_imported_members = True
autosummary_ignore_module_all = False
autodoc_typehints = "description"

graphviz_output_format = 'png'
inheritance_graph_attrs = dict(rankdir='TB')

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

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

# -- 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 = 'pydata_sphinx_theme'

# 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 = ['_static']

html_theme_options = {
"icon_links": [
{
"name": "GitHub",
"url": "https://github.com/sun-data/solar-dynamics-observatory",
"icon": "fa-brands fa-github",
"type": "fontawesome",
},
{
"name": "PyPI",
"url": "https://pypi.org/project/solar-dynamics-observatory",
"icon": "fa-brands fa-python",
},
],
}

# https://github.com/readthedocs/readthedocs.org/issues/2569
master_doc = 'index'

bibtex_bibfiles = ['refs.bib']
bibtex_default_style = 'plain'
bibtex_reference_style = 'author_year'

intersphinx_mapping = {
'python': ('https://docs.python.org/3', None),
'numpy': ('https://numpy.org/doc/stable/', None),
'matplotlib': ('https://matplotlib.org/stable', None),
'astropy': ('https://docs.astropy.org/en/stable/', None),
'named_arrays': ('https://named-arrays.readthedocs.io/en/stable/', None)
}
44 changes: 44 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Introduction
============

The `Solar Dynamics Observatory <https://sdo.gsfc.nasa.gov>`_ (SDO)
:cite:p:`Pesnell2012` is a NASA satellite which has been continuously
observing the Sun since 2010.

This Python package aims to represent SDO imagery using :mod:`named_arrays`,
a named tensor implementation with :class:`astropy.units.Quantity` support.

Installation
============

This package is published to PyPI and can be installed using pip.

.. code-block::
pip install solar-dynamics-observatory
API Reference
=============

.. autosummary::
:toctree: _autosummary
:template: module_custom.rst
:recursive:

sdo


Bibliography
============

.. bibliography::

|

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
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

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% %O%
goto end

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

:end
popd
14 changes: 14 additions & 0 deletions docs/refs.bib
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@ARTICLE{Pesnell2012,
author = {{Pesnell}, W. Dean and {Thompson}, B.~J. and {Chamberlin}, P.~C.},
title = "{The Solar Dynamics Observatory (SDO)}",
journal = {\solphys},
keywords = {SDO, Solar cycle, Helioseismology, Coronal, Space weather},
year = 2012,
month = jan,
volume = {275},
number = {1-2},
pages = {3-15},
doi = {10.1007/s11207-011-9841-3},
adsurl = {https://ui.adsabs.harvard.edu/abs/2012SoPh..275....3P},
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}
3 changes: 3 additions & 0 deletions sdo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""
Download and analyze SDO observations.
"""

0 comments on commit 62b8bd3

Please sign in to comment.