Skip to content

Commit

Permalink
started sphinx documentation. doesnt work yet
Browse files Browse the repository at this point in the history
  • Loading branch information
Jermiah committed Nov 19, 2023
1 parent ebc3d3b commit fd36a2d
Show file tree
Hide file tree
Showing 12 changed files with 2,833 additions and 48 deletions.
19 changes: 19 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Minimal makefile for Sphinx documentation

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = python -msphinx
SPHINXPROJ = nbiatoolkit
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)
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
```{include} ../CHANGELOG.md
```
2 changes: 2 additions & 0 deletions docs/conduct.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
```{include} ../CONDUCT.md
```
36 changes: 36 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 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

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

project = u"nbiatoolkit"
copyright = u"2023, Jermiah Joseph"
author = u"Jermiah Joseph"

# -- 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 = [
"myst_nb",
"autoapi.extension",
"sphinx.ext.napoleon",
"sphinx.ext.viewcode",
]
autoapi_dirs = ["../src"]

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
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 = "sphinx_rtd_theme"
2 changes: 2 additions & 0 deletions docs/contributing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
```{include} ../CONTRIBUTING.md
```
136 changes: 136 additions & 0 deletions docs/example.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Example Usage: python3 examples.ipynb\n",
"### Description: \n",
"This is a simple example of how to use the `nbiatoolkit` package."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Setup \n",
"\n",
"By default the client will use the Public API with the Guest Login credentials.\n",
"from the nbia which has access to all public data. \n",
"\n",
"To use your own credentials you can pass them in as parameters to the client using:\n",
"\n",
" `NBIAClient(username=\"YOUR_USERNAME\", password=\"YOUR_PASSWORD\")`"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2023-11-19 17:45:24,124 | NBIAClient | INFO | Setting up OAuth2 client... with username nbia_guest\n",
"2023-11-19 17:45:24,124 | NBIAClient | INFO | Setting up OAuth2 client... with username nbia_guest\n"
]
}
],
"source": [
"from nbiatoolkit import NBIAClient\n",
"\n",
"# Instantiate the client. \n",
"client = NBIAClient()"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"# import nbiatoolkit \n",
"# TODO::implement method forprint(nbiatoolkit.__version__)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Get Collection Methods"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Counts of Patients grouped by Body Parts\n",
"`getBodyPartCounts(collection: str = \"\", modality: str = \"\")`"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"2023-11-19 17:42:42,892 | NBIAClient | INFO | Querying API endpoint: https://services.cancerimagingarchive.net/nbia-api/services/getBodyPartValuesAndCounts\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Total Number of Collections:98\n",
"First 5 body parts:\n",
"[{'BodyPartExamined': 'NOT SPECIFIED', 'Count': '8490'},\n",
" {'BodyPartExamined': 'ABDOMEN', 'Count': '2968'},\n",
" {'BodyPartExamined': 'ABDOMEN CAVIT', 'Count': '2'},\n",
" {'BodyPartExamined': 'ABDOMENPELVIC', 'Count': '2'},\n",
" {'BodyPartExamined': 'ABDOMENPELVIS', 'Count': '51'}]\n"
]
}
],
"source": [
"from pprint import pprint\n",
"bodypart_count = client.getBodyPartCounts()\n",
"print(\"Total Number of Collections:\" + str(len(bodypart_count)))\n",
"\n",
"print(\"First 5 body parts:\")\n",
"pprint(bodypart_count[0:5])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.0"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
13 changes: 13 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
```{include} ../README.md
```

```{toctree}
:maxdepth: 1
:hidden:
example.ipynb
changelog.md
contributing.md
conduct.md
autoapi/index
```
36 changes: 36 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=python -msphinx
)
set SOURCEDIR=.
set BUILDDIR=_build
set SPHINXPROJ=nbiatoolkit

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The Sphinx module was not found. Make sure you have Sphinx installed,
echo.then set the SPHINXBUILD environment variable to point to the full
echo.path of the 'sphinx-build' executable. Alternatively you may add the
echo.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%
goto end

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

:end
popd
3 changes: 3 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
myst-nb
sphinx-autoapi
sphinx-rtd-theme

0 comments on commit fd36a2d

Please sign in to comment.