Skip to content

Commit 1db2524

Browse files
committed
Fix: feedback from @tupui, @NickleDave
1 parent 377fad9 commit 1db2524

File tree

4 files changed

+84
-13
lines changed

4 files changed

+84
-13
lines changed

documentation/contributing-license-coc.md

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,6 @@ review. Some maintainers may also opt to include the development information in
6565
```
6666

6767

68-
69-
7068
```{tip}
7169
[The mozilla open workshop has a nice outline of things to consider when
7270
creating a contributing guide](https://mozillascience.github.io/working-open-workshop/contributing/)
@@ -84,6 +82,22 @@ by the Open Software Initiative (OSI). OSI's website has a
8482

8583
If you choose your license through GitHub, you can also automatically get a copy of the license file to add to your repository.
8684

85+
### Important: make sure that you closely follow the guidelines outlines by the License that you chose
86+
87+
Every license has different guidelines in terms of what code
88+
you can use in your package and also how others can (or can not) use the code in your package.
89+
90+
If you borrow code from other tools or online sources, make
91+
sure that the license for the code that you are using also complies
92+
with the license that you selected for your package.
93+
94+
```{note}
95+
An example of code that would not comply with a BSD or MIT license would be any code copied from StackOverflow website.
96+
[Stack overflow users a Creative Commons Share Alike license.](https://stackoverflow.com/help/licensing) The sharealike license requires you to use the same sharealike license when you reuse any code from stackoverflow. Thus, if you use code from stack overflow in your package and have a MIT license applied to your package, you are violating stack overflow's license requirements! Proceed with caution here!
97+
```
98+
99+
[The SciPy documentation has an excellent license discussion that is worth reading and considering for your project's development guide.](https://docs.scipy.org/doc/scipy/dev/core-dev/index.html#licensing)
100+
87101
## The CODE_OF_CONDUCT.md file
88102
Your package should have a CODE_OF_CONDUCT.md file located
89103
the root of the repository. If you are not comfortable creating

documentation/index.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,11 @@ tools that will help you build your documentation.
1919
## Documentation is critical to the success of your Python open source package
2020

2121
Documentation is as important to the success of your Python open source package
22-
as the code itself. Quality code is of course valuable as it gets the tasks
23-
that your package seeks to achieve, done. However, if users don't understand
22+
as the code itself. Quality code is of course valuable as its how your package gets the tasks done. However, if users don't understand
2423
how to use your package in their workflows, then they won't use it.
2524

26-
Further, if you wish to build a base of contributors to your package, having
27-
explicit information about how to contribute is critical.
25+
Further, explicitly documenting how to contribute is critical if you wish
26+
to build a base of contributors to your package.
2827

2928
## Documentation elements that pyOpenSci looks for when reviewing a Python package
3029

documentation/package-documentation-best-practices.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ def extent_to_json(ext_obj):
168168
"""
169169
```
170170

171+
<!-- I can't seem to get doc targets across pages to work-->
172+
(docstring_best_practice)=
171173
### Best - a docstring with example use of the function
172174

173175
This example contains an example of using the function that is also tested in
@@ -178,15 +180,16 @@ def extent_to_json(ext_obj):
178180
"""Convert bounds to a shapely geojson like spatial object.
179181
This format is what shapely uses. The output object can be used
180182
to crop a raster image.
181-
Parameters
183+
184+
Parameters
182185
----------
183-
ext_obj: list or geopandas.GeoDataFrame
186+
ext_obj : list or geopandas.GeoDataFrame
184187
If provided with a `geopandas.GeoDataFrame`, the extent
185188
will be generated from that. Otherwise, extent values
186189
should be in the order: minx, miny, maxx, maxy.
187190
Return
188191
------
189-
extent_json: A GeoJSON style dictionary of corner coordinates
192+
extent_json : A GeoJSON style dictionary of corner coordinates
190193
for the extent
191194
A GeoJSON style dictionary of corner coordinates representing
192195
the spatial extent of the provided spatial object.
@@ -198,7 +201,14 @@ def extent_to_json(ext_obj):
198201
>>> import geopandas as gpd
199202
>>> import earthpy.spatial as es
200203
>>> from earthpy.io import path_to_example
204+
205+
We start by loading a Shapefile.
206+
201207
>>> rmnp = gpd.read_file(path_to_example('rmnp.shp'))
208+
209+
And then use `extent_to_json` to do the conversion from `shp` to
210+
`geopandas.GeoDataFrame`.
211+
202212
>>> es.extent_to_json(rmnp)
203213
{'type': 'Polygon', 'coordinates': (((-105.4935937, 40.1580827), ...),)}
204214

documentation/python-package-documentation-tools.md

Lines changed: 52 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ important points page -->
1111
* Publish your documentation on ReadTheDocs (or GitHub pages if you are more advanced and also prefer to maintain your website locally)
1212
* Use `myST` syntax to write your documentation
1313
* Use sphinx gallery to write tutorials using .py files that automagically have downloadable .py and jupyter notebook files. Use nbsphinx if you prefer writing tutorials in jupyter notebook format and don't need a grid formatted gallery. *Both of these tools will run your tutorials from beginning to end providing an addition layer of testing to your package!*
14-
14+
* OPTIONAL: Use [doctest](https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html) to run the examples in your code's docstrings as a way to make sure that your code's functions and methods (the API) are running as you expect them to.
1515
```
1616

1717
In addition to your:
@@ -125,12 +125,12 @@ Both of these tools act as sphinx extensions and:
125125

126126
### [sphinx gallery:](https://sphinx-gallery.github.io/stable/index.html)
127127

128-
If you prefer to write your tutorials using python **.py** scripts, you
128+
If you prefer to write your tutorials using Python **.py** scripts, you
129129
may enjoy using sphinx gallery. Sphinx gallery uses **.py** files with
130-
text and code sections that mimics the Jupyter Notebook format. When you build
130+
text and code sections that mimic the Jupyter Notebook format. When you build
131131
your documentation, the gallery extension:
132132

133-
1. Runs the code in each tutorial: this acts as a check to ensure your package is working as you think it is!
133+
1. Runs the code in each tutorial. Running your tutorial this acts as a check to ensure your package functions and classes (ie the API) are working as they should.
134134
1. Creates a downloadable Jupyter Notebook **.ipynb** file and a **.py** script for your tutorial that a user can quickly download and run.
135135
1. Creates a rendered **.html** page with the code elements and code outputs in a user-friendly tutorial gallery.
136136
1. Creates a gallery landing page with visual thumbnails for each tutorial that you create
@@ -248,4 +248,52 @@ _build/
248248
...
249249
```
250250

251+
## Using doctest to run docstring examples in your packages methods and functions
252+
<!-- This link isn't working no matter how i create the target. not sure
253+
why -->
254+
[In the package documentation page we provided some examples of good, better, best docstring formats](package-documentation-best-practices.html#docstring_best_practice). If you wish, you can also add the [doctest](https://www.sphinx-doc.org/en/master/usage/extensions/doctest.html) extension to your Sphinx build
255+
as an addition check for docstrings with example code in them.
256+
Doctest, runs the example code in your docstring `Examples` checking
257+
that the expected output is in fact correct. Similar to running
258+
tutorials in your documentation, doctest can be a useful step that
259+
assures that your packages code (API) runs as you expect it to.
260+
261+
```{note}
262+
It's important to keep in mind that examples in your docstrings
263+
help users using your package. Running `doctest` on those examples provides a
264+
check of your package's API. doctest ensures that the functions and methods in your package
265+
run as you expect them to. Neither of these items replace a separate,
266+
stand-alone test suite that is designed to test your package's core functionality
267+
across operating systems and Python versions.
268+
```
269+
270+
Below is an example of a docstring with an example.
271+
doctest will run the example below and test that if you provide
272+
`add_me` with the values 1 and 3 it will return 4.
273+
274+
275+
```python
276+
def add_me(aNum, aNum2):
277+
"""A function that prints a number that it is provided.
278+
279+
Parameters
280+
----------
281+
aNum : int
282+
An integer value to be printed
283+
284+
Returns
285+
-------
286+
Prints the integer that you provide the function.
287+
288+
"""
289+
return aNum + aNum2
290+
291+
Examples
292+
--------
293+
Below you can see how the `print_me` function will print a number that
294+
you provide it.
295+
296+
>>> add_me(1+3)
297+
4
251298

299+
```

0 commit comments

Comments
 (0)