From d2258ae35c57be93aac504d9e42591f3400482f4 Mon Sep 17 00:00:00 2001 From: Tom Hodson Date: Fri, 17 Jun 2022 12:23:40 +0200 Subject: [PATCH] Reformat the docs and add myst-nb as a doc dep --- code/docs/api_docs.rst | 14 ++++++++++ code/docs/conf.py | 4 +++ code/docs/index.rst | 52 +++++--------------------------------- code/docs/quickstart.rst | 30 ++++++++++++++++++++++ code/docs/requirements.txt | 2 ++ readthedocs.yaml | 1 + 6 files changed, 57 insertions(+), 46 deletions(-) create mode 100644 code/docs/api_docs.rst create mode 100644 code/docs/quickstart.rst diff --git a/code/docs/api_docs.rst b/code/docs/api_docs.rst new file mode 100644 index 0000000..3d108e7 --- /dev/null +++ b/code/docs/api_docs.rst @@ -0,0 +1,14 @@ +API Docs +======== + +MCMC : Markov Chain Monte Carlo Routines +--------------------------------------------- + +.. automodule:: MCFF.mcmc + :members: + +Ising_Model : Ising Model Routines +--------------------------------------------- + +.. automodule:: MCFF.ising_model + :members: diff --git a/code/docs/conf.py b/code/docs/conf.py index f5b1ade..cb43f52 100644 --- a/code/docs/conf.py +++ b/code/docs/conf.py @@ -34,8 +34,12 @@ release = "1.0" extensions = [ "sphinx.ext.autodoc", "sphinx.ext.napoleon", + "myst_nb", ] +# Tell myst_nb not to execute the notebooks +nb_execution_mode = "off" + # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] diff --git a/code/docs/index.rst b/code/docs/index.rst index ec56a46..aa7ccc5 100644 --- a/code/docs/index.rst +++ b/code/docs/index.rst @@ -7,54 +7,14 @@ You can find the source code and main landing page for this project on `GitHub < There is a `Jupyter notebook `_ detailing how this page was generated in there. - - -Quickstart ----------- - -.. code-block:: python - - from MCFF.mcmc import mcmc_generator - from MCFF.ising_model import show_state - - ### Simulation Inputs ### - N = 500 # Use an NxN system - - initial_state = np.random.choice( - np.array([-1, 1], dtype=np.int8), size=(N, N) - ) # the intial state to use - - ### Simulation Code ### - critical_states = [ - s for s in mcmc_generator(initial_state, steps=5, stepsize=5*N**2, T= 3.5) - ] - - fig, axes = plt.subplots( - ncols=len(critical_states), figsize=(5 * len(critical_states), 5) - ) - - for s, ax in zip(critical_states, axes): - show_state(s, ax=ax) - -.. image:: _static/states.png - :width: 100% - :alt: 5 grids showing black and white Ising Model states - .. toctree:: - :maxdepth: 2 - :caption: Contents: + :maxdepth: 1 + :glob: + :caption: Table of Contents: -mcmc : Markov Chain Monte Carlo Routines ---------------------------------------------- - -.. automodule:: MCFF.mcmc - :members: - -ising_model : Ising Model Routines ---------------------------------------------- - -.. automodule:: MCFF.ising_model - :members: + quickstart + api_docs + learning/* diff --git a/code/docs/quickstart.rst b/code/docs/quickstart.rst new file mode 100644 index 0000000..68bc871 --- /dev/null +++ b/code/docs/quickstart.rst @@ -0,0 +1,30 @@ +Quickstart +---------- + +.. code-block:: python + + from MCFF.mcmc import mcmc_generator + from MCFF.ising_model import show_state + + ### Simulation Inputs ### + N = 500 # Use an NxN system + + initial_state = np.random.choice( + np.array([-1, 1], dtype=np.int8), size=(N, N) + ) # the intial state to use + + ### Simulation Code ### + critical_states = [ + s for s in mcmc_generator(initial_state, steps=5, stepsize=5*N**2, T= 3.5) + ] + + fig, axes = plt.subplots( + ncols=len(critical_states), figsize=(5 * len(critical_states), 5) + ) + + for s, ax in zip(critical_states, axes): + show_state(s, ax=ax) + +.. image:: _static/states.png + :width: 100% + :alt: 5 grids showing black and white Ising Model states diff --git a/code/docs/requirements.txt b/code/docs/requirements.txt index e69de29..4b40359 100644 --- a/code/docs/requirements.txt +++ b/code/docs/requirements.txt @@ -0,0 +1,2 @@ +sphinx +myst-nb diff --git a/readthedocs.yaml b/readthedocs.yaml index 248fedd..7b8fbeb 100644 --- a/readthedocs.yaml +++ b/readthedocs.yaml @@ -23,5 +23,6 @@ sphinx: python: install: - requirements: requirements.txt + - requirements: code/docs/requirements.txt - method: pip path: code/