Skip to content

Commit

Permalink
update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhealy1 committed Apr 10, 2024
1 parent b795502 commit 5b3c435
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 103 deletions.
70 changes: 40 additions & 30 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,48 +1,58 @@
# Contributing

Issues and pull requests are more than welcome.


**dev install**
### Development Environment Setup

```bash
git clone https://github.com/stac-utils/stac-fastapi.git
cd stac-fastapi
python -m pip install -e stac_fastapi/api[dev]
To install the classes in your local Python env, run:

```shell
pip install -e 'stac_fastapi/elasticsearch[dev]'
```

or

```shell
pip install -e 'stac_fastapi/opensearch[dev]'
```

**pre-commit**
### Pre-commit

This repo is set to use `pre-commit` to run *ruff*, *pydocstring* and mypy when committing new code.
Install [pre-commit](https://pre-commit.com/#install).

```bash
Prior to commit, run:

```shell
pre-commit install
```
pre-commit run --all-files
```

### Docs
### Testing

```bash
git clone https://github.com/stac-utils/stac-fastapi.git
cd stac-fastapi
python pip install -e stac_fastapi/api["docs"]
```shell
make test
```
Test against OpenSearch only

Hot-reloading docs:

```bash
$ mkdocs serve -f docs/mkdocs.yml
```shell
make test-opensearch
```

To manually deploy docs (note you should never need to do this because GitHub
Actions deploys automatically for new commits.):
Test against Elasticsearch only

```shell
make test-elasticsearch
```

```bash
Create API documentations
$ pdocs as_markdown \
--output_dir docs/src/api/ \
--exclude_source \
--overwrite \
stac_fastapi.opensearch
### Docs

# deploy
$ mkdocs gh-deploy -f docs/mkdocs.yml
```
```shell
make docs
```

Hot-reloading docs locally:

```shell
mkdocs serve -f docs/mkdocs.yml
```
44 changes: 2 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,8 @@ pip install stac_fastapi.opensearch

#### For changes, see the [Changelog](CHANGELOG.md)


## Development Environment Setup

To install the classes in your local Python env, run:

```shell
pip install -e 'stac_fastapi/elasticsearch[dev]'
```

or

```shell
pip install -e 'stac_fastapi/opensearch[dev]'
```


### Pre-commit

Install [pre-commit](https://pre-commit.com/#install).

Prior to commit, run:

```shell
pre-commit run --all-files
```

#### Development notes: [Contributing](CONTRIBUTING.md)

## Build Elasticsearh API backend

```shell
Expand Down Expand Up @@ -135,22 +111,6 @@ Options:
python3 data_loader.py --base-url http://localhost:8080
```

## Testing

```shell
make test
```
Test against OpenSearch only

```shell
make test-opensearch
```

Test against Elasticsearch only

```shell
make test-elasticsearch
```

## Elasticsearch Mappings

Expand Down
32 changes: 1 addition & 31 deletions docs/src/tips-and-tricks.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,3 @@
# Tips and Tricks

This page contains a few 'tips and tricks' for getting **stac-fastapi** working in various situations.

## Get stac-fastapi working with CORS

CORS (Cross-Origin Resource Sharing) support may be required to use stac-fastapi in certain situations.
For example, if you are running [stac-browser](https://github.com/radiantearth/stac-browser) to browse the STAC catalog created by **stac-fastapi**, then you will need to enable CORS support.
To do this, edit your backend's `app.py` and add the following import:

```python
from fastapi.middleware.cors import CORSMiddleware
```

and then edit the `api = StacApi(...` call to add the following parameter:

```python
middlewares=[lambda app: CORSMiddleware(app, allow_origins=["*"])]
```

If needed, you can edit the `allow_origins` parameter to only allow CORS requests from specific origins.

## Enable the Context extension

The Context STAC extension provides information on the number of items matched and returned from a STAC search.
This is required by various other STAC-related tools, such as the pystac command-line client.
To enable the extension, edit your backend's `app.py` and add the following import:

```python
from stac_fastapi.extensions.core.context import ContextExtension
```

and then edit the `api = StacApi(...` call to add `ContextExtension()` to the list given as the `extensions` parameter.
This page contains a few 'tips and tricks' for working with **sfeos**.

0 comments on commit 5b3c435

Please sign in to comment.