aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ChrisJL <[email protected]>2021-07-23 09:38:33 +0100
committerGravatar GitHub <[email protected]>2021-07-23 09:38:33 +0100
commitd5b750cad7c9f030f6abf9c04e33a6d8b022bdb5 (patch)
treefacd4bf6ab0ecb9ba544587075aa1befa88aa45a
parentMerge pull request #1687 from python-discord/utils/reminder/remove-footer (diff)
parentMerge branch 'main' into patch-1 (diff)
Merge pull request #1686 from NotFlameDev/patch-1
Added docstring tag
-rw-r--r--bot/resources/tags/docstring.md18
1 files changed, 18 insertions, 0 deletions
diff --git a/bot/resources/tags/docstring.md b/bot/resources/tags/docstring.md
new file mode 100644
index 000000000..9457b629c
--- /dev/null
+++ b/bot/resources/tags/docstring.md
@@ -0,0 +1,18 @@
+A [`docstring`](https://docs.python.org/3/glossary.html#term-docstring) is a string with triple quotes that often used in file, classes, functions, etc. A docstring should have a clear explanation of exactly what the function does. You can also include descriptions of the function's parameter(s) and its return type, as shown below.
+```py
+def greet(name, age) -> str:
+ """
+ Return a string that greets the given person, including their name and age.
+
+ :param name: The name to greet.
+ :type name: str
+ :param age: The age to display.
+ :type age: int
+ :return: String of the greeting.
+ """
+ return_string = f"Hello, {name} you are {age} years old!"
+ return return_string
+```
+You can get the docstring by using `.__doc__` attribute. For the last example you can get it through: `print(greet.__doc__)`.
+
+For more details about what docstring is and it's usage check out this guide by [Real Python](https://realpython.com/documenting-python-code/#docstrings-background), or the [PEP-257 docs](https://www.python.org/dev/peps/pep-0257/#what-is-a-docstring).