Skip to content

Commit

Permalink
Rename developer.rst to CONTRIBUTING.md
Browse files Browse the repository at this point in the history
  • Loading branch information
henrykironde committed Oct 17, 2023
1 parent ca81f64 commit 3391366
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 144 deletions.
130 changes: 130 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Developer's Guide

Deepends on Python 3.5+

## Getting started

1. Quickstart by forking the [main repository](https://github.com/weecology/DeepForest)

2. Clone your copy of the repository.

> - **Using ssh**
> `git clone [email protected]:[your user name]/DeepForest.git`
> - **Using https**
> `git clone https://github.com/[your user name]/DeepForest.git`
3. Link or point your cloned copy to the main repository. (I always
name it upstream)

> - `git remote add upstream https://github.com/weecology/DeepForest.git`
4. Check or confirm your settings using `git remote -v`

```J
origin [email protected]:[your user name]/DeepForest.git (fetch)
origin [email protected]:[your user name]/DeepForest.git (push)
upstream https://github.com/weecology/DeepForest.git (fetch)
upstream https://github.com/weecology/DeepForest.git (push)
```

6. Install the package from the main directory.

Deepforest can be installed using either pip or conda.

**Install using Pip**

Installing with Pip uses [dev_requirements.txt](https://github.com/weecology/DeepForest/blob/main/dev_requirements.txt).

``` bash
$ pip install -r dev_requirements.txt
$ pip install . -U
```

**Install using Conda**

Installing with Conda uses [environment yaml](https://github.com/weecology/DeepForest/blob/main/environment.yml).

Conda-based installs can be slow. We recommend using
[mamba](https://mamba.readthedocs.io/en/latest/user_guide/mamba.html#quickstart)
to speed them up.

``` bash
$ conda create -n deepforest python=3
$ conda activate deepforest
$ pip install . -U
```

7. Check if the package was installed; please test using the [sample
code](https://deepforest.readthedocs.io/en/latest/getting_started.html).

## Testing

### Running tests locally

``` bash
$ pip install . --upgrade # or python setup.py install
$ pytest -v
```

### Testing the Conda Deepforest Build

We use the conda_recipe/meta.yaml to make sure that the conda build can
build the package

``` bash
$ cd conda_recipe
$ conda build conda_recipe/meta.yaml -c conda-forge -c defaults
```

### Conda staged recipe update

Update the Conda recipe after every release.

Clone the [Weecology staged recipes](https://github.com/weecology/staged-recipes).
Checkout deepforest branch, update the `deepforeset/meta.yaml` with
the new version and the sha256 values. Sha256 values are obtained from
the source on [PYPI download files](https://pypi.org/project/deepforest/#files)
using the deepforest-{version-number}.tar.gz

```
{% set version = "fill new" %}
{% set sha256 = "fill new" %}
```

## Documentation

We are using [Sphinx](http://www.sphinx-doc.org/en/stable/) and [Read
the Docs](https://readthedocs.org//) for the documentation.

**Update Documentation**

The documentation is automatically updated for changes in functions.
However, the documentation should be updated after the addition of new
functions or modules.

Change to the docs directory and use sphinx-apidoc to update the doc's
`source`. Exclude the tests and setup.py documentation.

Run

``` bash
sphinx-apidoc -f -o ./source ../ ../tests/* ../setup.py
```

The `source` is the destination folder for the source rst files. `../`
is the path to where the deepforest source code is located relative to
the doc directory.

**Test documentation locally**

``` bash
cd docs # Go to the docs directory and install the current changes.

pip install ../ -U
make clean # Run
make html # Run

Note:
Do not commit the build directory after making html.
```
25 changes: 19 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
# -*- coding: utf-8 -*-
import os
import sys
from typing import Any
import urllib.request
from typing import Any

import recommonmark
from recommonmark.parser import CommonMarkParser
from recommonmark.parser import CommonMarkParser
from recommonmark.parser import CommonMarkParser
from recommonmark.transform import AutoStructify

Expand All @@ -23,13 +20,13 @@
using [reticulate](https://rstudio.github.io/reticulate/) works.
"""
file_obj = open('deepforestr.md','w')
file_obj = open('deepforestr.md', 'w')
readme_url = 'https://raw.githubusercontent.com/weecology/deepforestr/main/README.md'
file_obj.write(deepforestr_title)

with urllib.request.urlopen(readme_url) as response:
lines = response.readlines()
badge_section = True
badge_section = True
for line in lines:
line = line.decode("utf8")
if "## Installation" in line and badge_section:
Expand All @@ -38,6 +35,22 @@
file_obj.write(line)
file_obj.close()

# Create copy of CONTRIBUTING.md
contributing_url = "https://raw.githubusercontent.com/weecology/DeepForest/main/CONTRIBUTING.md"
contributing_url = "https://raw.githubusercontent.com/weecology/DeepForest/main/README.md"
contributing_source = "../CONTRIBUTING.md"

if not os.path.exists(contributing_source):
with urllib.request.urlopen(contributing_url) as response:
lines = response.readlines()
with open(contributing_source, "w") as file1:
file1.write(lines)

# reading from file1 and writing to file2
with open(contributing_source, "r") as file1:
with open("CONTRIBUTING.md", "w") as file2:
file2.write(file1.read())

needs_sphinx = "1.8"

autodoc_default_options = {
Expand Down
137 changes: 0 additions & 137 deletions docs/developer.rst

This file was deleted.

2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ The most helpful thing you can do is leave feedback on DeepForest `issue page`_.
authors.rst
source/modules.rst
use
developer
CONTRIBUTING.md

Indices and tables
==================
Expand Down

0 comments on commit 3391366

Please sign in to comment.