Skip to content

Commit f621ffc

Browse files
committed
docs: include more documentation and docstrings
1 parent 2acc722 commit f621ffc

31 files changed

Lines changed: 868 additions & 4933 deletions

.github/workflows/release.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ on:
77
pull_request:
88
branches: [ main ]
99

10+
concurrency:
11+
group: ci-${{ github.ref }}
12+
cancel-in-progress: true
13+
1014
jobs:
1115
build:
1216
runs-on: ubuntu-latest
@@ -39,3 +43,55 @@ jobs:
3943
run: |
4044
poetry config pypi-token.pypi ${PYPI_TOKEN}
4145
make release
46+
47+
docs:
48+
runs-on: ubuntu-latest
49+
50+
defaults:
51+
run:
52+
shell: bash -l {0}
53+
54+
permissions:
55+
contents: read
56+
pages: write
57+
id-token: write
58+
59+
environment:
60+
name: github-pages
61+
url: ${{ steps.deployment.outputs.page_url }}
62+
63+
steps:
64+
- uses: actions/checkout@v4
65+
66+
- uses: conda-incubator/setup-miniconda@v3
67+
with:
68+
miniforge-version: latest
69+
environment-file: conda/dev.yaml
70+
channels: conda-forge,nodefaults
71+
activate-environment: pysus
72+
auto-update-conda: true
73+
conda-solver: libmamba
74+
75+
- name: Install dependencies
76+
run: |
77+
pip install poetry poetry-plugin-export
78+
poetry config virtualenvs.create false
79+
poetry install --with docs --extras dbc
80+
81+
- name: Build docs
82+
run: |
83+
cd docs
84+
make html
85+
86+
- name: Configure GitHub Pages
87+
uses: actions/configure-pages@v5
88+
89+
- name: Upload artifact
90+
uses: actions/upload-pages-artifact@v3
91+
with:
92+
path: docs/build/html
93+
94+
- name: Deploy to GitHub Pages
95+
if: github.ref == 'refs/heads/main'
96+
id: deployment
97+
uses: actions/deploy-pages@v4

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,16 @@ df = sih(state="SP", year=2024, month=[1, 2, 3])
5555
df = cnes(state="SP", year=2024, month=1)
5656
```
5757

58+
### Listing the files
59+
60+
You can also list the files within the dataset to check which files are available to download
61+
62+
```python
63+
from pysus import list_files
64+
65+
list_files("SINAN")
66+
```
67+
5868
### Using the PySUS Client
5969

6070
```python

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
nbsphinx
22
sphinx
33
sphinx-rtd-theme
4+
standard-imghdr

docs/source/api.rst

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
API Reference
2+
=============
3+
4+
The ``pysus.api`` package provides a layered architecture for discovering,
5+
downloading, and reading data from Brazilian public health databases
6+
(DATASUS). It supports three remote data sources.
7+
8+
Architecture Overview
9+
---------------------
10+
11+
The package is organized into a hierarchy of abstract base classes and
12+
concrete implementations::
13+
14+
pysus/api/
15+
├── __init__.py # Package entry (re-exports PySUS)
16+
├── client.py # Main PySUS orchestrator
17+
├── extensions.py # File format handlers
18+
├── models.py # Abstract base classes
19+
├── types.py # Type aliases
20+
├── _impl/
21+
│ └── databases.py # High-level convenience functions
22+
├── ducklake/ # S3 DuckLake catalog client
23+
├── ftp/ # FTP client
24+
└── dadosgov/ # dados.gov.br API client
25+
26+
Quick Start
27+
-----------
28+
29+
The simplest way to use PySUS is via the high-level convenience
30+
functions::
31+
32+
from pysus import sinan
33+
34+
df = sinan(disease="dengue", year=2023)
35+
36+
Or with the async API::
37+
38+
from pysus.api.client import PySUS
39+
40+
async with PySUS() as pysus:
41+
files = await pysus.query(dataset="sinan", group="DENG", year=2023)
42+
for f in files:
43+
await pysus.download(f)
44+
45+
46+
Main Client
47+
-----------
48+
49+
.. automodule:: pysus.api.client
50+
:members:
51+
:undoc-members:
52+
:show-inheritance:
53+
54+
Types
55+
-----
56+
57+
.. automodule:: pysus.api.types
58+
:members:
59+
:undoc-members:
60+
61+
File Format Handlers
62+
--------------------
63+
64+
.. automodule:: pysus.api.extensions
65+
:members:
66+
:undoc-members:
67+
:show-inheritance:
68+
69+
Abstract Base Models
70+
--------------------
71+
72+
.. automodule:: pysus.api.models
73+
:members:
74+
:undoc-members:
75+
:show-inheritance:
76+
77+
High-Level Data Functions
78+
-------------------------
79+
80+
.. automodule:: pysus.api._impl.databases
81+
:members:
82+
:undoc-members:
83+
:show-inheritance:
84+
85+
DuckLake Client
86+
---------------
87+
88+
.. automodule:: pysus.api.ducklake.client
89+
:members:
90+
:undoc-members:
91+
:show-inheritance:
92+
93+
.. automodule:: pysus.api.ducklake.catalog
94+
:members:
95+
:undoc-members:
96+
:show-inheritance:
97+
98+
.. automodule:: pysus.api.ducklake.models
99+
:members:
100+
:undoc-members:
101+
:show-inheritance:
102+
103+
FTP Client
104+
----------
105+
106+
.. automodule:: pysus.api.ftp.client
107+
:members:
108+
:undoc-members:
109+
:show-inheritance:
110+
111+
.. automodule:: pysus.api.ftp.databases
112+
:members:
113+
:undoc-members:
114+
:show-inheritance:
115+
116+
.. automodule:: pysus.api.ftp.models
117+
:members:
118+
:undoc-members:
119+
:show-inheritance:
120+
121+
DadosGov Client
122+
---------------
123+
124+
.. automodule:: pysus.api.dadosgov.client
125+
:members:
126+
:undoc-members:
127+
:show-inheritance:
128+
129+
.. automodule:: pysus.api.dadosgov.databases
130+
:members:
131+
:undoc-members:
132+
:show-inheritance:
133+
134+
.. automodule:: pysus.api.dadosgov.models
135+
:members:
136+
:undoc-members:
137+
:show-inheritance:

docs/source/conf.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@
1212
# All configuration values have a default; values that are commented out
1313
# serve to show the default.
1414

15-
# If extensions (or modules to document with autodoc) are in another directory,
16-
# add these directories to sys.path here. If the directory is relative to the
17-
# documentation root, use os.path.abspath to make it absolute, like shown here.
18-
#
19-
# import os
20-
# import sys
21-
# sys.path.insert(0, os.path.abspath('.'))
15+
import os
16+
import sys
17+
18+
sys.path.insert(0, os.path.abspath("../.."))
2219

2320
# -- General configuration ------------------------------------------------
2421

@@ -33,9 +30,14 @@
3330
"sphinx.ext.autodoc",
3431
"sphinx.ext.mathjax",
3532
"sphinx.ext.viewcode",
33+
"sphinx.ext.intersphinx",
3634
"nbsphinx",
3735
]
3836

37+
intersphinx_mapping = {
38+
"sqlalchemy": ("https://docs.sqlalchemy.org/en/20/", None),
39+
}
40+
3941
# Add any paths that contain templates here, relative to this directory.
4042
templates_path = ["_templates"]
4143

0 commit comments

Comments
 (0)