aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar NotFlameDev <[email protected]>2021-07-21 10:14:02 +0700
committerGravatar GitHub <[email protected]>2021-07-21 10:14:02 +0700
commitd6c237cc6d2b1efa21d917df1afa5b5c425c0cc6 (patch)
tree44e652ee675734d594facb8337eaa0cb901c71e3
parentMerge pull request #1666 from python-discord/new-discord-features (diff)
Added docstring tag
-rw-r--r--bot/resources/tags/docstring.md16
1 files changed, 16 insertions, 0 deletions
diff --git a/bot/resources/tags/docstring.md b/bot/resources/tags/docstring.md
new file mode 100644
index 000000000..88f6b3a1d
--- /dev/null
+++ b/bot/resources/tags/docstring.md
@@ -0,0 +1,16 @@
+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. Docstrings usually has clear explanation, parameter(s) and return type.
+
+Here's an example of usage of a docstring:
+```py
+def greet(name, age) -> str:
+ """
+ :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__)`.