Skip to content

Commit

Permalink
add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
afrendeiro committed Oct 19, 2024
1 parent 06fb396 commit 6de81ee
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# .readthedocs.yaml
version: 2
sphinx:
configuration: docs/conf.py
python:
version: "3.10"
install:
- method: pip
path: .
formats:
- html
24 changes: 24 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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

clean:
rm -rf "$(BUILDDIR)"
rm -rf $(SOURCEDIR)/api/_autogen/*

# 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)
35 changes: 35 additions & 0 deletions docs/source/api.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
API reference
---------------

.. currentmodule:: wsi

.. autoclass:: WholeSlideImage

.. automethod:: __init__

.. rubric:: Methods

.. autosummary::

~WholeSlideImage.__init__
~WholeSlideImage.get_thumbnail
~WholeSlideImage.segment
~WholeSlideImage.plot_segmentation
~WholeSlideImage.save_segmentation
~WholeSlideImage.load_segmentation
~WholeSlideImage.tile
~WholeSlideImage.plot_tile_graph
~WholeSlideImage.save_tile_images
~WholeSlideImage.has_tile_coords
~WholeSlideImage.has_tile_images
~WholeSlideImage.has_tissue_contours
~WholeSlideImage.get_tile_coordinate_level_size
~WholeSlideImage.get_tile_coordinates
~WholeSlideImage.get_tile_graph
~WholeSlideImage.get_tile_images
~WholeSlideImage.get_tile_polygons
~WholeSlideImage.get_tile_tissue_piece
~WholeSlideImage.inference
~WholeSlideImage.as_tile_bag
~WholeSlideImage.as_data_loader
~WholeSlideImage.as_torch_geometric_data
52 changes: 52 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from datetime import datetime

import wsi

project = "wsi"
copyright = f"{datetime.now().year}, Rendeiro Lab"
author = "wsi contributors"
release = wsi.__version__

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

extensions = [
"numpydoc",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.autosectionlabel",
"matplotlib.sphinxext.plot_directive",
"sphinx.ext.intersphinx",
"sphinx_design",
"sphinx_copybutton",
"sphinx_click",
"myst_nb",
]
autoclass_content = "class"
autodoc_docstring_signature = True
autodoc_default_options = {"members": None, "undoc-members": None}
autodoc_typehints = "none"
# setting autosummary
autosummary_generate = True
numpydoc_show_class_members = False
add_module_names = False

templates_path = ["_templates"]
exclude_patterns = []


html_theme = "pydata_sphinx_theme"
html_sidebars = {"installation": [], "api": []}
copybutton_prompt_text = r">>> |\.\.\. |\$ |In \[\d*\]: | {2,5}\.\.\.: | {5," r"8}: "
copybutton_prompt_is_regexp = True

# Plot directive
plot_include_source = True
plot_html_show_source_link = False
plot_html_show_formats = False
plot_formats = [("png", 200)]

intersphinx_mapping = {
"torch": ("https://pytorch.org/docs/stable/", None),
"torch_geometric": ("https://pytorch-geometric.readthedocs.io/en/stable/", None),
}
42 changes: 42 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
wsi
===

**wsi** is a Python library for processing whole slide images (WSI).

It is a simple library with an object-oriented interface where all operations are performed with a WholeSlideImage object.
It has the goal of doing basic processing of WSIs with reasonable defaults, but high customizability.
For example, to go from a slide remotely hosted to a torch geometric graph with ResNet50 features, the following lines suffice:

.. code-block:: python
from wsi import WholeSlideImage
slide = WholeSlideImage("https://brd.nci.nih.gov/brd/imagedownload/GTEX-O5YU-1426")
slide.segment()
slide.tile()
data = slide.as_torch_geometric_data(model_name='resnet50')
Head over to the `Installation <install.html>`_ and `API reference <api.html>`_ pages to learn more.


.. toctree::
:maxdepth: 1
:hidden:

install
api


.. grid:: 1 2 2 2
:gutter: 2

.. grid-item-card:: Installation
:link: install
:link-type: doc

Instructions for installation

.. grid-item-card:: API
:link: api
:link-type: doc

API documentation
21 changes: 21 additions & 0 deletions docs/source/install.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Installation
============

To install the package from the GitHub repository, follow the steps below.

1. Ensure you have Python 3.10 or higher installed.
2. Install the package using `pip` by running the following command:

.. code-block:: bash
pip install git+https://github.com/rendeirolab/wsi.git
3. Verify that the package is correctly installed by importing it in Python:

.. code-block:: python
import wsi
If the installation was successful, you should not encounter any errors.

For further details, please visit our `GitHub repository <https://github.com/rendeirolab/wsi>`_.

0 comments on commit 6de81ee

Please sign in to comment.