Skip to content

Commit

Permalink
Add documentation for the orthanc_sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
gacou54 committed Oct 18, 2023
1 parent 19837ef commit 4b08c38
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 10 deletions.
40 changes: 40 additions & 0 deletions docs/api/orthanc_sdk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Orthanc SDK

The `orthanc_sdk` is useful when developing with the Orthanc's Python Plugin,
it exposes `orthanc` module when available (i.e. used as an Orthanc script),
or expose the functions/classes signatures when not for linting and autocomplete.

Use it the same way you would use the Python Plugin:

```python
from pyorthanc import orthanc_sdk

def on_get(output: orthanc_sdk.RestOutput, *_, **__):
output.AnswerBuffer('ok', 'text/plain')

orthanc_sdk.RegisterRestCallback('/test', on_get)
```


## How it works
When developing importing the Orthanc Python Plugin with `import orthanc` will raise a `ModuleNotFoundError`.
This where the `orthanc_sdk` submodule is interesting. When `orthanc` is available, it uses it.
When not, `orthanc_sdk` expose mock functions/classes of everything available from `orthanc`, however, these functions/classes does nothing.

```python
try:
from orthanc import *

except ModuleNotFoundError:
"""Orthanc SDK methods wrapped in python (plugin version 4.0)"""
...
```


## Reference

::: pyorthanc.orthanc_sdk
options:
members: true
:docstring:
:members:
17 changes: 14 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,17 @@ for patient in patients:
pydicom_ds = instance.get_pydicom()
```

Use the `orthanc_sdk` when developing with the Orthanc's Python Plugin

```python
from pyorthanc import orthanc_sdk

def on_get(output: orthanc_sdk.RestOutput, *_, **__):
output.AnswerBuffer('ok', 'text/plain')

orthanc_sdk.RegisterRestCallback('/test', on_get)
```

## [First steps](tutorial/quickstart.md#first-steps)
### [Getting started](tutorial/quickstart.md#getting-started)
* [Import pyorthanc library](tutorial/quickstart.md#import-pyorthanc-library)
Expand All @@ -64,9 +75,9 @@ for patient in patients:
* [Access instance informations](tutorial/quickstart.md#access-instance-informations)
### [Advanced examples](tutorial/advanced.md)
* [Transfer data from a PACS to a Orthanc server](tutorial/advanced.md#transfer-data-from-a-pacs-to-a-orthanc-server)
### [Releases](releases/releases.md)
* [Lastest release : 1.12.1](releases/releases.md#lastest-release-1121)
* [Release 1.11.5](releases/releases.md#release-1115)
### [Releases](releases.md)
* [Lastest release : 1.12.1](releases.md#lastest-release-1121)
* [Release 1.11.5](releases.md#release-1115)
## [Contacts](contacts.md#contacts)
* [Maintainers Team](contacts.md#maintainers-team)
* [Useful links](contacts.md#useful-links)
Expand Down
File renamed without changes.
3 changes: 0 additions & 3 deletions docs/releases/roadmap.md

This file was deleted.

18 changes: 18 additions & 0 deletions docs/tutorial/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,24 @@ __Note__ that this function may take a while to run since each resource level is
Using `find()` on large Orthanc server is not recommended.


#### Develop with the Orthanc's Python Plugin
The `orthanc_sdk` is useful when developing with the Orthanc's Python Plugin,
it exposes `orthanc` module when available (i.e. used as an Orthanc script),
or expose the functions/classes signatures when not for linting and autocomplete.

Use it the same way you would use the Python Plugin:

```python
# Has the same signature as `import orthanc`
from pyorthanc import orthanc_sdk

def on_get(output: orthanc_sdk.RestOutput, *_, **__):
output.AnswerBuffer('ok', 'text/plain')

orthanc_sdk.RegisterRestCallback('/test', on_get)
```


## Full basic examples

Be sure that Orthanc is running. The default URL (if running locally) is `http://localhost:8042`.
Expand Down
7 changes: 3 additions & 4 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ nav:
- 'Api Reference':
'Orthanc': 'api/client.md'
'Asynchronous Orthanc': 'api/async_client.md'
'Orthanc SDK': 'api/orthanc_sdk.md'
'Patient': 'api/resources/patient.md'
'Study': 'api/resources/study.md'
'Series': 'api/resources/series.md'
Expand All @@ -27,11 +28,9 @@ nav:
'Jobs': 'api/jobs.md'
'Util': 'api/util.md'
'Resource': 'api/resources/resource.md'
'Retrieve': 'api/retrieve.md'


- 'Releases & Roadmap':
- 'Releases': 'releases/releases.md'

- 'Releases': 'releases.md'

- 'More informations':
- 'Contributing': 'contributing.md'
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ pydicom = "^2.3.0"
pytest = "^7.1.0"
simple-openapi-client = "^0.5.2"

[tool.poetry.group.docs.dependencies]
mkdocs = "^1.5.3"
mkdocstrings = {extras = ["python"], version = "^0.23.0"}
mkdocs-material = "^9.4.6"
jinja2 = "^3.1.2"

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

0 comments on commit 4b08c38

Please sign in to comment.