diff --git a/.gitignore b/.gitignore index 22c1c2a58466d13424047fcba0f493355df6bcf4..dc835bbc6af993ba35b514e82a3eac570efb8f33 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,5 @@ builds/ config/ run_EnvSuitPipeline.py custom_plotting.py +/docs/_build/ +/docs/_autosummary/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 94995bb41460847bc343e517551a59f2c4a2b18c..f1f1d02aec35d9d9f874942c4cd7285ba40b2df4 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -281,11 +281,15 @@ full_fat_epi: pages: when: always stage: docs + extends: .before_script + image: lb584/ews_coordinator:latest script: - echo "hello" - - mkdir public - - mv -v $CI_PROJECT_DIR/docs/index.html public - - ls public/ + - cd $CI_PROJECT_DIR/docs + - make html + - mkdir $CI_PROJECT_DIR/public + - mv -rv $CI_PROJECT_DIR/docs/_build/html/* $CI_PROJECT_DIR/public/ + - ls $CI_PROJECT_DIR/public/ artifacts: paths: - - public + - $CI_PROJECT_DIR/public diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..c0cc58c0a3b5f900b1fc51f4a53dba0848d2b600 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,22 @@ +# 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 + rm -rf _build + rm -rf _autosummary + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/_templates/custom-class-template.rst b/docs/_templates/custom-class-template.rst new file mode 100644 index 0000000000000000000000000000000000000000..f73eda50ec593f7393241c5d6aa4c143a66c805b --- /dev/null +++ b/docs/_templates/custom-class-template.rst @@ -0,0 +1,34 @@ +{{ fullname | escape | underline}} + +.. currentmodule:: {{ module }} + +.. autoclass:: {{ objname }} + :members: + :show-inheritance: + :inherited-members: + :special-members: __call__, __add__, __mul__ + + {% block methods %} + {% if methods %} + .. rubric:: {{ _('Methods') }} + + .. autosummary:: + :nosignatures: + {% for item in methods %} + {%- if not item.startswith('_') %} + ~{{ name }}.{{ item }} + {%- endif -%} + {%- endfor %} + {% endif %} + {% endblock %} + + {% block attributes %} + {% if attributes %} + .. rubric:: {{ _('Attributes') }} + + .. autosummary:: + {% for item in attributes %} + ~{{ name }}.{{ item }} + {%- endfor %} + {% endif %} + {% endblock %} diff --git a/docs/_templates/custom-module-template.rst b/docs/_templates/custom-module-template.rst new file mode 100644 index 0000000000000000000000000000000000000000..d066d0e4dc2e34f399f55ea38d92ed4540787317 --- /dev/null +++ b/docs/_templates/custom-module-template.rst @@ -0,0 +1,66 @@ +{{ fullname | 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: + :nosignatures: + {% for item in functions %} + {{ item }} + {%- endfor %} + {% endif %} + {% endblock %} + + {% block classes %} + {% if classes %} + .. rubric:: {{ _('Classes') }} + + .. autosummary:: + :toctree: + :template: custom-class-template.rst + :nosignatures: + {% 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 %} +.. autosummary:: + :toctree: + :template: custom-module-template.rst + :recursive: +{% for item in modules %} + {{ item }} +{%- endfor %} +{% endif %} +{% endblock %} diff --git a/docs/api.rst b/docs/api.rst new file mode 100644 index 0000000000000000000000000000000000000000..f15c1b8e9eb23c1463085ab3189654ba471d3eb9 --- /dev/null +++ b/docs/api.rst @@ -0,0 +1,13 @@ +API +=== + +.. autosummary:: + :toctree: _autosummary + :template: custom-module-template.rst + :recursive: + + coordinator + plotting + ews_postprocessing + met_processing + source_gen diff --git a/docs/conf.py b/docs/conf.py new file mode 100644 index 0000000000000000000000000000000000000000..64e1d2508bbfd6f665106ba8eb34226724fdb1c4 --- /dev/null +++ b/docs/conf.py @@ -0,0 +1,70 @@ +# 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 + +import os +import sys +sys.path.insert(0, os.path.abspath('..')) +print(sys.path) + +project = 'ews-coordinator' +author = 'Gilligan lab' + +# -- General configuration --------------------------------------------------- +# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration + +extensions = [ + 'sphinx.ext.duration', + 'sphinx.ext.doctest', + 'sphinx.ext.autodoc', + 'sphinx.ext.autosummary', + 'sphinx.ext.intersphinx', # Link to other project's documentation (see mapping below) + 'sphinx.ext.viewcode', # Add a link to the Python source code for classes, functions etc. + 'sphinx_autodoc_typehints', # Automatically document param types (less noise in class signature) + 'IPython.sphinxext.ipython_console_highlighting' +] + +# Mappings for sphinx.ext.intersphinx. Projects have to have Sphinx-generated doc! (.inv file) +intersphinx_mapping = { + "python": ("https://docs.python.org/3/", None), +} + +autosummary_generate = True # Turn on sphinx.ext.autosummary +autoclass_content = "both" # Add __init__ doc (ie. params) to class summaries +html_show_sourcelink = False # Remove 'view source code' from top of page (for html, not python) +autodoc_inherit_docstrings = True # If no docstring, inherit from base class +set_type_checking_flag = True # Enable 'expensive' imports for sphinx_autodoc_typehints +nbsphinx_allow_errors = True +autodoc_typehints = "description" # Sphinx-native method. Not as good as sphinx_autodoc_typehints +add_module_names = False # Remove namespaces from class/method signatures + +templates_path = ['_templates'] +exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] + +# Readthedocs theme +# on_rtd is whether on readthedocs.org, this line of code grabbed from docs.readthedocs.org... +on_rtd = os.environ.get("READTHEDOCS", None) == "True" +if not on_rtd: # only import and set the theme if we're building docs locally + import sphinx_rtd_theme + html_theme = "sphinx_rtd_theme" + html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] +html_css_files = ["readthedocs-custom.css"] # Override some CSS settings +# html_theme = 'alabaster' + + +# # This is the expected signature of the handler for this event, cf doc +# def autodoc_skip_member_handler(app, what, name, obj, skip, options): +# # Basic approach; you might want a regex instead +# print("got it" + name) +# return name.startswith("test_") +# +# +# # Automatically called by sphinx at startup +# def setup(app): +# # Connect the autodoc-skip-member event from apidoc to the callback +# app.connect('autodoc-skip-member', autodoc_skip_member_handler) + diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index cc70e23ab85080312af2761834d5828ac647be1c..0000000000000000000000000000000000000000 --- a/docs/index.html +++ /dev/null @@ -1,8 +0,0 @@ -<html> - <head> - <title>Home</title> - </head> - <body> - <h1>Hello World!</h1> - </body> - </html> \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..211b359876474a4324b8fdd8feaeb656461d90df --- /dev/null +++ b/docs/index.rst @@ -0,0 +1,29 @@ +.. ews-plotting documentation master file, created by + sphinx-quickstart on Thu May 25 13:28:43 2023. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to ews-plotting's documentation! +======================================== + + +.. toctree:: + :hidden: + + Home page <self> + coordinator API <_autosummary/coordinator> + plotting API <_autosummary/plotting> + post processing API <_autosummary/ews_postprocessing> + met processing processing API <_autosummary/met_processing> + source gen API <_autosummary/source_gen> + + +Indices and tables +================== + +this is is a load of ``text`` that has ``plotting.common.utils`` this function in it + +.. autosummary:: + plotting.common.utils.build_standard_depo_diseases + ews_postprocessing.deposition.NAME_to_csv.NAMEToCSV +