You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: documentation/contributing-license-coc.md
+16-2Lines changed: 16 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -65,8 +65,6 @@ review. Some maintainers may also opt to include the development information in
65
65
```
66
66
67
67
68
-
69
-
70
68
```{tip}
71
69
[The mozilla open workshop has a nice outline of things to consider when
72
70
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
84
82
85
83
If you choose your license through GitHub, you can also automatically get a copy of the license file to add to your repository.
86
84
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
+
87
101
## The CODE_OF_CONDUCT.md file
88
102
Your package should have a CODE_OF_CONDUCT.md file located
89
103
the root of the repository. If you are not comfortable creating
Copy file name to clipboardExpand all lines: documentation/python-package-documentation-tools.md
+52-4Lines changed: 52 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ important points page -->
11
11
* Publish your documentation on ReadTheDocs (or GitHub pages if you are more advanced and also prefer to maintain your website locally)
12
12
* Use `myST` syntax to write your documentation
13
13
* 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.
15
15
```
16
16
17
17
In addition to your:
@@ -125,12 +125,12 @@ Both of these tools act as sphinx extensions and:
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
129
129
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
131
131
your documentation, the gallery extension:
132
132
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.
134
134
1. Creates a downloadable Jupyter Notebook **.ipynb** file and a **.py** script for your tutorial that a user can quickly download and run.
135
135
1. Creates a rendered **.html** page with the code elements and code outputs in a user-friendly tutorial gallery.
136
136
1. Creates a gallery landing page with visual thumbnails for each tutorial that you create
@@ -248,4 +248,52 @@ _build/
248
248
...
249
249
```
250
250
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
+
defadd_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
0 commit comments