Skip to content

Commit

Permalink
resolve conflict and merge
Browse files Browse the repository at this point in the history
  • Loading branch information
martahan committed May 30, 2024
2 parents baf35c8 + 325ef2f commit 23ca936
Show file tree
Hide file tree
Showing 13 changed files with 378 additions and 1,221 deletions.
2 changes: 2 additions & 0 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
'nbsphinx_link'
]

autosectionlabel_prefix_document = True

templates_path = ['_templates']
exclude_patterns = []
napoleon_custom_sections = [('Returns', 'params_style')]
Expand Down
3 changes: 3 additions & 0 deletions docs/source/notebooks/SeismoStats.nblink
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"path": "../../../notebooks/SeismoStats.ipynb"
}
3 changes: 0 additions & 3 deletions docs/source/notebooks/catalog_Tools.nblink

This file was deleted.

30 changes: 30 additions & 0 deletions docs/source/reference/analysis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Analysis

```{eval-rst}
.. currentmodule:: seismostats
```

## Estimating b-Values

```{eval-rst}
.. autosummary::
:toctree: api/
estimate_b
shi_bolt_confidence
analysis.estimate_b_tinti
analysis.estimate_b_positive
analysis.estimate_b_utsu
analysis.estimate_b_laplace
analysis.estimate_b_weichert
analysis.estimate_b_kijko_smit
```

## Estimating the Completeness Magnitude
```{eval-rst}
.. autosummary::
:toctree: api/
analysis.mc_ks
analysis.mc_max_curvature
```
1 change: 1 addition & 0 deletions docs/source/reference/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
catalog
config
plots
analysis
```
106 changes: 104 additions & 2 deletions docs/source/user/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,113 @@
- `make server` to build the documentation and start a local server on http://localhost:8000 to view the documentation and rebuild automatically.
- `make clean` to remove the built documentation.

## Writing the Documentation
## Structure of the Documentation
Currently, the documentation has two main sections: The {doc}`index` which serves as a written tutorial for the project and the {doc}`../reference/index` which serves as a technical reference for the project.

### The User Guide
This is a written tutorial for the project. It should be written in a way that a new user can understand and use the project. Background on methods and concepts can and should be included.

### The API Reference
This is a technical reference for the project. The user can go and look up the specifics of a method or class, including specific examples. This is generated to a big extent from the docstrings in the code. The developer mostly just needs to decide on the structure of this part of the documentation, and write the docstrings in the code accordingly.
This is a technical reference for the project. The user can go and look up the specifics of a method or class, including specific examples. This is generated to a big extent from the docstrings in the code. The developer mostly just needs to decide on the structure of this part of the documentation, and write the docstrings in the code accordingly.

## Technical Details
### How to Autogenerate Documentation
It is possible to autogenerate documentation from the docstrings in the code. We use this feature to generate the API reference. The docstrings should be written in reStructuredText format, using the [Google Style Python Docstrings](https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html).

#### How to Add a New Section
First, create a new `.md` file in the `/docs/source/reference` directory and add the new file to the `toctree` in `/docs/source/reference/index.md`.

At the start of the file you can define the current module, which will be used to find the functions and classes in the module. This is done with the following code (the `>` characters are added to avoid execution of the directives):
````
> ```{eval-rst}
> .. currentmodule:: seismostats
> ```
````
You can then add the references to the functions and classes using the relative import path to the function
or class name.
````
> ```{eval-rst}
> .. autosummary::
> :toctree: api/
>
> Catalog
> ```
````
This creates a list of references to the functions and classes, as well as, inside the `api` directory, a `.rst` file with the documentation for the functions and classes.

Optimally you would structure this documentation logically, and provide a minimal description of the groups
of functions and classes.

If you would like to have the documentation for a function or class directly in the current file, you can first use the `currentmodule` as above, and then the `autofunction` directive.
````
> ```{eval-rst}
> .. autofunction:: _example
> ```
````


### How to Use Crossreferences

#### Document
How to reference a document in the documentation.

**Code**
```
Using a custom name: {doc}`Reference <../reference/index>`
Using the title of the document: {doc}`../reference/index`
```

**Output**
Using a custom name: {doc}`Reference <../reference/index>`
Using the top level title of the document: {doc}`../reference/index`

#### Reference
How to reference a section in the documentation.

**Code**
```
Using a custom name: {ref}`Reference <reference/catalog:transformation>`
Using the title of the section: {ref}`/reference/catalog.md#transformation`
```

**Output**
Using a custom name: {ref}`Reference <reference/catalog:transformation>`
Using the title of the section: {ref}`/reference/catalog.md#transformation`

#### Function / Class
How to reference a function or class in the documentation.

**Code**
```
Using a custom name: {func}`Bin Magnitudes <seismostats.Catalog.bin_magnitudes>`
Using the function name: {func}`~seismostats.Catalog.bin_magnitudes`
Or with the whole path: {func}`seismostats.Catalog.bin_magnitudes`
```

**Output**
Using a custom name: {func}`Bin Magnitudes <seismostats.Catalog.bin_magnitudes>`
Using the title of the function: {func}`~seismostats.Catalog.bin_magnitudes`
Or with the whole path: {func}`seismostats.Catalog.bin_magnitudes`

#### Use Crossreferences in a Docstring
How to use crossreferences in a docstring.

**Code**
```python
def _example():
"""
This function is purely used as an example for the documentation.
See Also:
:func:`seismostats.Catalog.bin_magnitudes`
"""
pass
```

**Output**
```{eval-rst}
.. module:: seismostats.utils.docs
```
```{eval-rst}
.. autofunction:: _example
```
2 changes: 1 addition & 1 deletion docs/source/user/examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
:maxdepth: 1
../notebooks/catalog_examples.nblink
../notebooks/catalog_Tools.nblink
../notebooks/SeismoStats.nblink
```
Loading

0 comments on commit 23ca936

Please sign in to comment.