Skip to content

Commit

Permalink
Fix formatting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Garulf committed Nov 17, 2023
1 parent f0257fb commit a13ab1a
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 67 deletions.
79 changes: 39 additions & 40 deletions docs/guide/API Requests.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,65 @@
## Sending API requests to FLow Launcher
# Sending API requests to FLow Launcher

You can send special requests to Flow Launcher to control the launcher from your plugin. This communication is currently only one way.

!!! warning

You can not send API requests from a query or context_menu method!
You can not send API requests from a query or context_menu method!

Using API requests in this way will cause your plugin to fail!

### Sending a command from a Result
## Sending a command from a Result

```
from pyflowlauncher import Plugin, Result, send_results, api
from pyflowlauncher.result import JsonRPCAction, ResultResponse
```py
from pyflowlauncher import Plugin, Result, send_results, api
from pyflowlauncher.result import JsonRPCAction, ResultResponse

plugin = Plugin()
plugin = Plugin()


@plugin.on_method
def query(query: str) -> ResultResponse:
r = Result(
Title="This is a title!",
SubTitle="This is the subtitle!",
IcoPath="icon.png",
JsonRPCAction=api.change_query("This is a new query!"),
)
return send_results([r])
@plugin.on_method
def query(query: str) -> ResultResponse:
r = Result(
Title="This is a title!",
SubTitle="This is the subtitle!",
IcoPath="icon.png",
JsonRPCAction=api.change_query("This is a new query!"),
)
return send_results([r])


plugin.run()
```
plugin.run()
```

The example above will change the query in Flow Launcher when the user selects your result.


### Sending a command from a Method
## Sending a command from a Method

You can also send an API request in a custom method like so:

```
from pyflowlauncher import Plugin, Result, send_results, api
from pyflowlauncher.result import JsonRPCAction, ResultResponse
```py
from pyflowlauncher import Plugin, Result, send_results, api
from pyflowlauncher.result import JsonRPCAction, ResultResponse

plugin = Plugin()
plugin = Plugin()


@plugin._on_method
def example_method() -> JsonRPCAction:
# Do stuff here
return api.change_query("This is also a new query!")
@plugin._on_method
def example_method() -> JsonRPCAction:
# Do stuff here
return api.change_query("This is also a new query!")


@plugin.on_method
def query(query: str) -> ResultResponse:
r = Result(
Title="This is a title!",
SubTitle="This is the subtitle!",
IcoPath="icon.png",
)
r.add_action(example_method)
return send_results([r])
@plugin.on_method
def query(query: str) -> ResultResponse:
r = Result(
Title="This is a title!",
SubTitle="This is the subtitle!",
IcoPath="icon.png",
)
r.add_action(example_method)
return send_results([r])


plugin.run()
```
plugin.run()
```
34 changes: 17 additions & 17 deletions docs/guide/Launcher_Icons.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Using icons included with Flow Launcher
# Using icons included with Flow Launcher

Flow Launcher comes with a decent amount of icons that it uses throughout it's UI and plugins.

Expand All @@ -10,25 +10,25 @@ You can use some of these icons in your plugin by importing from the `icons` mod

This will not crash your plugin but will leave the icon blank.

### Example:
## Example

```
from pyflowlauncher import Plugin, Result, send_results
from pyflowlauncher.result import ResultResponse
from pyflowlauncher.icons import ICONS
```
from pyflowlauncher import Plugin, Result, send_results
from pyflowlauncher.result import ResultResponse
from pyflowlauncher.icons import ICONS

plugin = Plugin()
plugin = Plugin()


@plugin.on_method
def query(query: str) -> ResultResponse:
r = Result(
Title="This is a title!",
SubTitle="This is the subtitle!",
IcoPath=ICONS["app"]
)
return send_results([r])
@plugin.on_method
def query(query: str) -> ResultResponse:
r = Result(
Title="This is a title!",
SubTitle="This is the subtitle!",
IcoPath=ICONS["app"]
)
return send_results([r])


plugin.run()
```
plugin.run()
```
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Home

{!README.md!}
{!README.md!}
4 changes: 2 additions & 2 deletions docs/reference/api.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## API Reference
# API Reference

::: pyflowlauncher.api
::: pyflowlauncher.api
11 changes: 6 additions & 5 deletions docs/reference/event.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# event

::: pyflowlauncher.event
handler: python
options:
separate_signature: true
show_signature_annotations: true

handler: python
options:
separate_signature: true
show_signature_annotations: true
2 changes: 1 addition & 1 deletion docs/reference/plugin.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
## Plugin Reference
# Plugin Reference

::: pyflowlauncher.plugin.Plugin
4 changes: 3 additions & 1 deletion docs/reference/result.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
::: pyflowlauncher.result
# result

::: pyflowlauncher.result

0 comments on commit a13ab1a

Please sign in to comment.