Skip to content

Commit 39d9235

Browse files
committed
DOC: Add documentation for Bot module.
1 parent aa75950 commit 39d9235

File tree

4 files changed

+63
-2
lines changed

4 files changed

+63
-2
lines changed

docs/api/bot.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Bot API
2+
3+
This module containes the base class for all bots `BaseBot` but also
4+
specialized implementations such as `DesktopBot` which is described below.
5+
6+
You are expected to implement the `action` method of the `DesktopBot` class in
7+
your Bot class.
8+
9+
Here is a very brief example of a bot which opens the BotCity website:
10+
11+
```python
12+
from botcity.core import DesktopBot
13+
14+
15+
class Bot(DesktopBot):
16+
def action(self, execution):
17+
# Opens the BotCity website.
18+
self.browse("https://botcity.dev/en")
19+
20+
21+
if __name__ == '__main__':
22+
Bot.main()
23+
```
24+
25+
26+
All functions from the API described below are accessible via the bot class as
27+
methods without the need to import any other module.
28+
29+
E.g.:
30+
31+
```python
32+
class Bot(DesktopBot):
33+
def action(self, execution):
34+
# using browse from browser module
35+
self.browse(...)
36+
# using find from display module
37+
self.find(...)
38+
# using mouse_move from mouse module
39+
self.mouse_move(x=100, y=200)
40+
# using enter from keyboard module
41+
self.enter()
42+
43+
```
44+
45+
## DesktopBot API
46+
47+
::: botcity.core.bot.DesktopBot

docs/api/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The API is divided into the following modules:
1212

1313
- *misc*: this module contains miscellaneous functions such as executing applications, and wait/print.
1414

15+
- *bot*: this module contains the base class for Bots, including the DesktopBot
1516

1617
In order to make it easy for users, all modules are available
1718
via the core module.

docs/intro.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@ which takes as argument a URL.
1919
browser("https://www.botcity.dev/en")
2020
```
2121

22+
## Template Project
23+
24+
We created a template project using Cookiecutter to help
25+
you create new bots using BotCity's Python Framework.
26+
27+
Take a look into the [template project website](https://github.com/botcity-dev/bot-python-template) for more information
28+
on how to use it and get started.
29+
2230
## Next Steps
2331

24-
Check our example and experiment with the API.
25-
Let us know where it can be improved.
32+
Check our examples and experiment with the API.
33+
Let us know where it can be improved.

mkdocs.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ nav:
1313
- 'Mouse': api/mouse.md
1414
- 'Keyboard': api/keyboard.md
1515
- 'Misc': api/misc.md
16+
- 'Bot': api/bot.md
1617
theme:
1718
icon:
1819
repo: fontawesome/brands/github
@@ -35,6 +36,10 @@ theme:
3536
icon: material/toggle-switch
3637
name: Switch to light mode
3738

39+
markdown_extensions:
40+
- pymdownx.highlight
41+
- pymdownx.superfences
42+
3843
extra:
3944
generator: false
4045
social:

0 commit comments

Comments
 (0)