Skip to content

Commit

Permalink
feat: configure make, readthedocs
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidni committed Feb 20, 2024
1 parent ece9f66 commit 84ad67a
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 31 deletions.
31 changes: 31 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# .readthedocs.yaml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.12"
# You can also specify other tool versions:
# nodejs: "19"
# rust: "1.64"
# golang: "1.19"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py
# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
# python:
# install:
# - requirements: docs/requirements.txt
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ help:
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

server:
sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
sphinx-autobuild "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) --watch "../seismostats"

clean:
rm -rf $(BUILDDIR)/
16 changes: 16 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,19 @@

html_theme = 'pydata_sphinx_theme'
html_static_path = ['_static']
html_theme_options = {
"use_edit_page_button": False,
"icon_links": [
{
"name": "GitHub",
"url": "https://github.com/swiss-seismological-service/SeismoStats",
"icon": "fa-brands fa-square-github",
"type": "fontawesome",
}
]
}
html_show_sourcelink = False
navigation_with_keys = True
html_context = {
"default_mode": "light",
}
9 changes: 4 additions & 5 deletions docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ User Guide <user/index>
API reference <reference/index>
```

```{include} ../../README.md
:relative-images:
```
# Seismo Stats

Measure your seismicity with **SeismoStats**, a Python package for seismicity analysis.

Check out the {doc}`user/usage` section for further information, including how to
{ref}`install <installation>` the project.
Check out the {doc}`user/usage` section for further information, or the {doc}`reference/index` for a technical reference.


<!-- ## Indices and tables
Expand Down
2 changes: 1 addition & 1 deletion docs/source/user/docs.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Creating and Building the Documentation
# Adding Documentation

## Building the Documentation
1. Install the project including documentation dependencies using `pip install -e .[doc]` from the root of the project.
Expand Down
24 changes: 3 additions & 21 deletions docs/source/user/usage.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
# Usage

## Installation

```bash
pip install -e .
python3 -m venv env

# activate it
source env/bin/activate

# update build tools
pip install -U pip wheel setuptools

# install this package + requirements + development requirements ([dev])
pip install -e '.[dev]'

# run tests
tox
```

## Code
You can use the {py:func}`seismostats.Catalog` class to load a catalog.
```{include} ../../../README.md
:relative-images:
```
28 changes: 25 additions & 3 deletions seismostats/seismicity/catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,36 @@ class Catalog(pd.DataFrame):
Data to initialize the catalog with.
name : str, optional
Name of the catalog.
args, kwargs : optional
Additional arguments and keyword arguments to pass to pandas
args : optional
Additional arguments to pass to pandas
DataFrame constructor.
kwargs: optional
Additional keyword arguments to pass to pandas
DataFrame constructor.
Notes:
The Catalog class is a subclass of pandas DataFrame, and inherits
all of its methods and attributes.
Examples:
Create a Catalog from a dictionary.
>>> import pandas as pd
>>> from seismostats.seismicity import Catalog
>>> data = {'longitude': [0, 1, 2],
... 'latitude': [0, 1, 2],
... 'depth': [0, 1, 2],
... 'time': pd.to_datetime(['2021-01-01 00:00:00',
... '2021-01-01 00:00:00',
... '2021-01-01 00:00:00']),
... 'magnitude': [1, 2, 3]}
>>> catalog = Catalog(data)
>>> catalog
longitude latitude depth time magnitude
0 0 0 0 2021-01-01 00:00:00 1
1 1 1 1 2021-01-01 00:00:00 2
2 2 2 2 2021-01-01 00:00:00 3
"""

_metadata = ['name', '_required_cols']
_required_cols = REQUIRED_COLS_CATALOG

Expand Down

0 comments on commit 84ad67a

Please sign in to comment.