Skip to content

Commit

Permalink
Creates Sphinx doc files for python music_box module in docs/sphinx_f…
Browse files Browse the repository at this point in the history
…iles (#154)

* added documentations to missing functions

* adds sphinx doc files in docs directory
  • Loading branch information
alexjamesgarza authored Apr 30, 2024
1 parent ce5289e commit 77e579a
Show file tree
Hide file tree
Showing 9 changed files with 278 additions and 0 deletions.
20 changes: 20 additions & 0 deletions doc/sphinx_files/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 = 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)
6 changes: 6 additions & 0 deletions doc/sphinx_files/docs/source/modules.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
docs
====

.. toctree::
:maxdepth: 4

35 changes: 35 additions & 0 deletions doc/sphinx_files/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

%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
117 changes: 117 additions & 0 deletions doc/sphinx_files/source/acom_music_box.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
acom\_music\_box package
========================

Submodules
----------

acom\_music\_box.music\_box module
----------------------------------

.. automodule:: acom_music_box.music_box
:members:
:undoc-members:
:show-inheritance:

acom\_music\_box.music\_box\_conditions module
----------------------------------------------

.. automodule:: acom_music_box.music_box_conditions
:members:
:undoc-members:
:show-inheritance:

acom\_music\_box.music\_box\_evolving\_conditions module
--------------------------------------------------------

.. automodule:: acom_music_box.music_box_evolving_conditions
:members:
:undoc-members:
:show-inheritance:

acom\_music\_box.music\_box\_model\_options module
--------------------------------------------------

.. automodule:: acom_music_box.music_box_model_options
:members:
:undoc-members:
:show-inheritance:

acom\_music\_box.music\_box\_product module
-------------------------------------------

.. automodule:: acom_music_box.music_box_product
:members:
:undoc-members:
:show-inheritance:

acom\_music\_box.music\_box\_reactant module
--------------------------------------------

.. automodule:: acom_music_box.music_box_reactant
:members:
:undoc-members:
:show-inheritance:

acom\_music\_box.music\_box\_reaction module
--------------------------------------------

.. automodule:: acom_music_box.music_box_reaction
:members:
:undoc-members:
:show-inheritance:

acom\_music\_box.music\_box\_reaction\_list module
--------------------------------------------------

.. automodule:: acom_music_box.music_box_reaction_list
:members:
:undoc-members:
:show-inheritance:

acom\_music\_box.music\_box\_reaction\_rate module
--------------------------------------------------

.. automodule:: acom_music_box.music_box_reaction_rate
:members:
:undoc-members:
:show-inheritance:

acom\_music\_box.music\_box\_species module
-------------------------------------------

.. automodule:: acom_music_box.music_box_species
:members:
:undoc-members:
:show-inheritance:

acom\_music\_box.music\_box\_species\_concentration module
----------------------------------------------------------

.. automodule:: acom_music_box.music_box_species_concentration
:members:
:undoc-members:
:show-inheritance:

acom\_music\_box.music\_box\_species\_list module
-------------------------------------------------

.. automodule:: acom_music_box.music_box_species_list
:members:
:undoc-members:
:show-inheritance:

acom\_music\_box.utils module
-----------------------------

.. automodule:: acom_music_box.utils
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: acom_music_box
:members:
:undoc-members:
:show-inheritance:
30 changes: 30 additions & 0 deletions doc/sphinx_files/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import sys
import os
sys.path.insert(0, os.path.abspath('..'))
# Configuration file for the Sphinx documentation builder.
#
# For the full list of built-in configuration values, see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Project information -----------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

project = 'acom_music_box'
copyright = '2024, NCAR'
author = 'NCAR'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

extensions = ['sphinx.ext.autodoc']

templates_path = ['_templates']
exclude_patterns = []



# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'alabaster'
html_static_path = ['_static']
22 changes: 22 additions & 0 deletions doc/sphinx_files/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.. acom_music_box documentation master file, created by
sphinx-quickstart on Mon Apr 29 18:31:30 2024.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to acom_music_box's documentation!
==========================================

.. toctree::
:maxdepth: 2
:caption: Contents:

modules



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

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
7 changes: 7 additions & 0 deletions doc/sphinx_files/source/modules.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
acom_music_box
==============

.. toctree::
:maxdepth: 4

acom_music_box
12 changes: 12 additions & 0 deletions src/acom_music_box/music_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,18 @@ def readFromUIJsonString(self, data):
self.evolving_conditions = EvolvingConditions.from_UI_JSON(data, self.species_list, self.reaction_list)

def readConditionsFromJson(self, path_to_json):
"""
Reads and parses a JSON file from the CAMP JSON file to set up the box model simulation.
Args:
path_to_json (str): The JSON path to the JSON file.
Returns:
None
Raises:
ValueError: If the JSON string cannot be parsed.
"""

with open(path_to_json, 'r') as json_file:
data = json.load(json_file)
Expand Down
29 changes: 29 additions & 0 deletions src/acom_music_box/music_box_reaction_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,20 @@ def add_reaction(self, reaction):

@classmethod
def get_reactants_from_JSON(self, reaction, species_list):
"""
Retrieves reactants from a JSON object.
This method iterates over the 'reactants' field of the provided JSON object,
matches each reactant with a species from the provided species list, and
creates a Reactant object for each one.
Args:
reaction (dict): A dictionary representing a reaction, as parsed from JSON.
species_list (SpeciesList): A list of all possible species.
Returns:
list: A list of Reactant objects representing the reactants of the reaction.
"""
reactants = []

for reactant, reactant_info in reaction['reactants'].items():
Expand All @@ -110,6 +124,21 @@ def get_reactants_from_JSON(self, reaction, species_list):

@classmethod
def get_products_from_JSON(self, reaction, species_list):
"""
Extracts products from a JSON object.
This method checks if the 'products' field is present in the provided JSON object.
If it is, the method iterates over the 'products' field, matches each product with
a species from the provided species list, and creates a Product object for each one.
Args:
reaction (dict): A dictionary representing a reaction, as parsed from JSON.
species_list (SpeciesList): A list of all possible species.
Returns:
list: A list of Product objects representing the products of the reaction, or
an empty list if the 'products' field is not present in the JSON object.
"""
products = []
if 'products' in reaction:
for product, product_info in reaction['products'].items():
Expand Down

0 comments on commit 77e579a

Please sign in to comment.