Skip to content

Commit 7d95ecf

Browse files
finish contributors guide (#11)
1 parent 5c1fcab commit 7d95ecf

File tree

2 files changed

+105
-4
lines changed

2 files changed

+105
-4
lines changed

docs/dev_guide/contribute.md

Lines changed: 103 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Contributors guide
2-
Thank you for considering making a contribution to CDIPpy! We welcome all types on contributions, including:
2+
Thank you for considering making a contribution to CDIPpy! We welcome all types of contributions, including:
33

44
- **new features**: do you have a cool workflow or product that uses CDIP? We'd love to see it!
55
- **bug fixes**: have you found something that doesn't work? We'd love help fixing it!
66
- **code cleanup**: some of this code is *really old*; if you have ideas for making if cleaner or more efficient, we want to hear them!
77
- **documentation and examples**: we would love more examples of `cdippy` library usage
88

99
## Setting up your git workflow
10-
This project uses a fork-and-contribute workflow. You will need to make your [fork](https://github.com/cdipsw/CDIPpy/fork) of the repository to work in, and submit changes to CDIPpy via pull request. To set up your workflow, follow these instructions:
10+
This project uses a fork-and-pull-request workflow. You will need to make your [fork](https://github.com/cdipsw/CDIPpy/fork) of the repository to work in, and submit changes to CDIPpy via pull request. To set up your workflow, follow these instructions:
1111

1212
1. Fork the respository at [https://github.com/cdipsw/CDIPpy/fork](https://github.com/cdipsw/CDIPpy/fork)
1313
2. Clone the repository from your fork `git clone https://github.com/{your_github_username}/CDIPpy.git` - this will add your own fork as your `origin` remote repo. *Note: If you already have the main fork cloned, skip to the next step and follow instuctions to add your fork as another remote.*
@@ -20,17 +20,118 @@ git remote -v
2020
If this worked, the last command will show your fork as `origin` and CDIP's as `cdip` (or whatever you have named them, respectively).
2121

2222
## Making your changes
23+
Before starting to develop, make sure you're working from the latest commit:
24+
```bash
25+
git checkout main # make sure this is cdip/main not your fork
26+
git pull
27+
git checkout -b example-branch
28+
```
29+
This will create a new branch called `example-branch` based on the lastest commit to `main`. Now you can start making your changes.
2330

31+
Any changes you plan to contribute should be sure to follow the project's style guide, testing structure, and be up-to-date with documentation.
2432

2533
### linting
34+
First you'll need to make sure your code style matches the rest of `cdippy` by using the `flake8` linter to check for adherance to the [PEP8](https://peps.python.org/pep-0008/) style guide:
35+
```bash
36+
flake8 .
37+
```
38+
If this commnad is successful, your style is up to date! Otherwise, the output will indicate where in the project the style is not compliant. You can manually fix these style deviations, or use a tool like [`black`](https://black.readthedocs.io/en/stable/) to autolint:
39+
```bash
40+
black .
41+
```
42+
43+
This project also provides a [`pre-commit`](https://pre-commit.com/) hook to manage style for you autmatically on every `git commit`. From the porject root:
44+
```bash
45+
pre-commit install
46+
```
47+
When you run `git commit` from your repo with the pre-commit hook installed, `black` will attempt to autolint the code and `flake8` will verify the results; the commit will fail if style errors are found, and you will need to manually fix them and try to commit again.
2648

2749
### testing
50+
With very few exceptions, every change should be tested! Your contribution cannot be accepted with failing tests or with large volumes of untested code. This project uses [`unittest`](https://docs.python.org/3/library/unittest.html) and [`coverage`](https://coverage.readthedocs.io/en/7.8.2/) to check that the code is thoroughly tets.
51+
52+
Make sure all tests pass by running `python -m unittest discover` from the project root.
53+
Learn more about running specific tests or subsets from the [`unittest` docs](https://docs.python.org/3/library/unittest.html).
54+
55+
Make sure test coverage is high by running `coverage run -m unittest discover`, which will run all tests and generate a file called `.coverage`. When tests have complete, run `coverage report`. The output of `report` will show what percentage of the code base was executed by the test suite - higher coverage means a more reliable library!
56+
57+
Learn more about interpreting coverage reports from the [docs](https://coverage.readthedocs.io/en/7.8.2/).
58+
2859

2960
### documenting
61+
Some contributions may require edits to the documentation,such as: new features, documentation for previously undocumented features, or changes to end behavior. This project uses [`mkdocs`](https://www.mkdocs.org/) to build a static site which is hosted on [GitHub pages](https://docs.github.com/en/pages). Before creating a pull request, be sure make any necessary changes to the documentation.
62+
63+
---
64+
**1) Edit a page**
65+
Make edits to the `.md` file under ['/docs/'](https://github.com/cdipsw/CDIPpy/tree/main/docs) which corresponds to the page you're editing
66+
67+
---
68+
**2) Make a new page or section**
69+
To add new pages to navigation, you'll need to create a new `.md` file in `/docs/` and edit [`mkdocs.yml`](https://github.com/cdipsw/CDIPpy/blob/main/mkdocs.yml) to include it.
70+
71+
For example:
72+
Create a new folder called "my_changes" and a file called "mychanges/change_1.md" under '/docs'.
73+
Add it to the `nav` tag of `mkdocs.yml`:
74+
75+
```yml
76+
nav:
77+
- Home: index.md
78+
- Quick start: quickstart.md
79+
...
80+
- My changes:
81+
- First change: my_changes/change_1.md
82+
```
83+
84+
---
85+
**3) Preview your changes**
86+
You can preview your changes locally by running `mkdocs serve` and going to [http://localhost:8000/](http://localhost:8000/).
87+
88+
---
89+
**4) Using and building site macros**
90+
Reusable site4 macros are defined in `./main.py`. The current list of supported macros are:
91+
92+
- Under construction banner:
93+
```html
94+
/* remove spaces between curly braces */
95+
{ { under_construction("Your text here") } }
96+
```
97+
{{ under_construction("Your text here") }}
98+
99+
---
100+
**4) Publish your changes**
101+
Publishing the updated documentation to the live site will be handled for you automatically by GitHub! If you're interested in how it works, read on, otherwise, skip to the next section.
102+
103+
How publishing works:
104+
105+
1. When you open a pull request with changes to either `mkdocs.yml` or the `/docs/` directory, [this workflow](https://github.com/cdipsw/CDIPpy/blob/main/.github/workflows/docs.yml) will be triggered and will build the static site (html) and push it to a branch called `gh-pages`.
106+
2. If the build is successful, a new job will run which will serve the new source in `gh-pages`.
107+
3. You can view running and completed workflows [here](https://github.com/cdipsw/CDIPpy/actions).
108+
109+
110+
---
111+
112+
####
30113

31114
## Making your pull request
32115
Once you are satisfied with your changes (or just ready to get more eyes on them), open a pull request at: [https://github.com/cdipsw/CDIPpy/pulls](https://github.com/cdipsw/CDIPpy/pulls).
33116

117+
Step 1: open the pull request
118+
a. select 'New pull request'
119+
b. make sure the `base` branch is `cdipsw/CDIPpy/main`
120+
c. choose a branch to compare - make sure you have selected "compare across forks" so that you can choose branches from your own fork
121+
d. Click "Create pull request".
122+
Step 2: edit the pull request
123+
a. give your PR a descriptive title
124+
b. tag any issues your PR resolves
125+
c. provide a description with an overview of your changes and any details a reviewer might need to know.
126+
d. verify that your changes look correct
127+
e. Click "Create pull request"
128+
Step 3: meet merge criteria - the next step is to see if the PR build passes. Checks will should up on your PR page with a status (Not started, passed, failed, canceled, etc.)
129+
a. all tests must pass
130+
b. test coverage must meet the threshold
131+
c. contributors must sign a CLA
132+
d. one reviewer must approve the PR - optionally, you can request reviews from specific users from the top right of your PR page under "Reviewers".
133+
134+
Once all status checks have turned green, the "merge" button will be enabled and the code can be merged into the `main` branch. Congrats, you've made a contribution!
34135

35136
## Get help
36137
If you have an idea but aren't sure how to implement it or would like others to weigh in, open an issue on GitHub at [https://github.com/cdipsw/CDIPpy/issues](https://github.com/cdipsw/CDIPpy/issues)!

docs/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ A goal of publishing this library as an open source, contributable package is to
66
## Navigating these docs
77
The CDIP user community spans a brooad expertise and vastly different backgrounds in python development and usage - use the following guidelines to determine where to start in the documentation:
88

9-
* If you a relatively comfortable working with python, visit the [Quickstart Guide](quickstart.md).
10-
* If you would like more explicit, step by step instructions for:
9+
* If you are relatively comfortable working with python, visit the [Quickstart Guide](quickstart.md).
10+
* If you would like more explicit, step-by-step instructions for:
1111
* Using `cdippy` as an end user: see the [Users Guide](user_guide/index.md)
1212
* Making changes to `cdippy`: see the [Developers Guide](dev_guide/index.md)

0 commit comments

Comments
 (0)