Skip to content

Commit

Permalink
Add raw API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
leaanthony committed Sep 25, 2023
1 parent fb820bc commit 4663a45
Show file tree
Hide file tree
Showing 9 changed files with 4,644 additions and 30 deletions.
6 changes: 6 additions & 0 deletions mkdocs-website/Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,9 @@ tasks:
msg: "Looks like mkdocs isn't installed. Run `wails3 task setup` or `task setup` in the documentation directory to install it."
cmds:
- mkdocs serve --config-file mkdocs.insiders.yml

update:api:
summary: Updates the API documentation
dir: generate
cmds:
- go run .
37 changes: 14 additions & 23 deletions mkdocs-website/docs/API/application.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,29 +186,6 @@ API: `CurrentWindow() *WebviewWindow`
window := app.CurrentWindow()
```

### NewSystemTray

API: `NewSystemTray() *SystemTray`

`NewSystemTray()` creates and returns a new system tray instance.

```go
// Create a new system tray
tray := app.NewSystemTray()
```


### NewMenu

API: `NewMenu() *Menu`

This method, belonging to App struct and not Menu struct, also initialises and returns a new `Menu`.

```go
// Create a new menu
menu := app.NewMenu()
```

### RegisterContextMenu

API: `RegisterContextMenu(name string, menu *Menu)`
Expand Down Expand Up @@ -251,31 +228,45 @@ API: `ShowAboutDialog()`

### Info

API: `InfoDialog()`

`InfoDialog()` creates and returns a new instance of `MessageDialog` with an `InfoDialogType`. This dialog is typically used to display informational messages to the user.

### Question

API: `QuestionDialog()`

`QuestionDialog()` creates and returns a new instance of `MessageDialog` with a `QuestionDialogType`. This dialog is often used to ask a question to the user and expect a response.


### Warning

API: `WarningDialog()`

`WarningDialog()` creates and returns a new instance of `MessageDialog` with a `WarningDialogType`. As the name suggests, this dialog is primarily used to display warning messages to the user.

### Error

API: `ErrorDialog()`

`ErrorDialog()` creates and returns a new instance of `MessageDialog` with an `ErrorDialogType`. This dialog is designed to be used when you need to display an error message to the user.

### OpenFile

API: `OpenFileDialog()`

`OpenFileDialog()` creates and returns a new `OpenFileDialogStruct`. This dialog prompts the user to select one or more files from their file system.

### SaveFile

API: `SaveFileDialog()`

`SaveFileDialog()` creates and returns a new `SaveFileDialogStruct`. This dialog prompts the user to choose a location on their file system where a file should be saved.

### OpenDirectory

API: `OpenDirectoryDialog()`

`OpenDirectoryDialog()` creates and returns a new instance of `MessageDialog` with an `OpenDirectoryDialogType`. This dialog enables the user to choose a directory from their file system.


Expand Down
4,336 changes: 4,336 additions & 0 deletions mkdocs-website/docs/API/fullapi.md

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions mkdocs-website/docs/API/menu.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# Menu

### `type Menu struct`
Menus can be created and added to the application. They can be used to create context menus, system tray menus and application menus.

The `Menu` struct holds information about a menu, including which items it contains and its label.
To create a new menu, call:

### `func NewMenu() *Menu`
```go
// Create a new menu
menu := app.NewMenu()
```

This function initializes a new Menu.
The following operations are then available on the `Menu` type:

### Add

Expand Down
9 changes: 6 additions & 3 deletions mkdocs-website/docs/API/systray.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@

The system tray houses notification area on a desktop environment, which can contain both icons of currently-running applications and specific system notifications.

### NewSystemTray
You create a system tray by calling `app.NewSystemTray()`:

API: `NewSystemTray(id uint) *SystemTray`
```go
// Create a new system tray
tray := app.NewSystemTray()
```

The `NewSystemTray` function constructs an instance of the `SystemTray` struct. This function takes a unique identifier of type `uint`. It returns a pointer to a `SystemTray` instance.
The following methods are available on the `SystemTray` type:

### SetLabel

Expand Down
57 changes: 57 additions & 0 deletions mkdocs-website/generate/generate.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package main

import (
"go/build"
"os"
"path/filepath"

"github.com/princjef/gomarkdoc"
"github.com/princjef/gomarkdoc/lang"
"github.com/princjef/gomarkdoc/logger"
)

func main() {
// Create a renderer to output data
out, err := gomarkdoc.NewRenderer()
if err != nil {
// handle error
}

wd, err := os.Getwd()
if err != nil {
// handle error
}

packagePath := filepath.Join(wd, "../../v3/pkg/application")

buildPkg, err := build.ImportDir(packagePath, build.ImportComment)
if err != nil {
// handle error
}

// Create a documentation package from the build representation of our
// package.
log := logger.New(logger.DebugLevel)
pkg, err := lang.NewPackageFromBuild(log, buildPkg)
if err != nil {
// handle error
panic(err)
}

// Write the documentation out to console.
data, err := out.Package(pkg)
if err != nil {
panic(err)
}

cwd, err := os.Getwd()
if err != nil {
panic(err)
}
println(cwd)

err = os.WriteFile(filepath.Join("..", "docs", "API", "fullapi.md"), []byte(data), 0644)
if err != nil {
panic(err)
}
}
39 changes: 39 additions & 0 deletions mkdocs-website/generate/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
module generate

go 1.21

require github.com/princjef/gomarkdoc v1.1.0

require (
github.com/Microsoft/go-winio v0.5.0 // indirect
github.com/VividCortex/ewma v1.2.0 // indirect
github.com/cheggaaa/pb/v3 v3.0.8 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/fatih/color v1.11.0 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
github.com/go-git/go-billy/v5 v5.3.1 // indirect
github.com/go-git/go-git/v5 v5.3.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/kevinburke/ssh_config v1.1.0 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mattn/go-runewidth v0.0.12 // indirect
github.com/mgutz/ansi v0.0.0-20200706080929-d51e80ef957d // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/princjef/mageutil v1.0.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/sergi/go-diff v1.3.1 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/x-cray/logrus-prefixed-formatter v0.5.2 // indirect
github.com/xanzy/ssh-agent v0.3.0 // indirect
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect
golang.org/x/net v0.0.0-20210520170846-37e1c6afe023 // indirect
golang.org/x/sys v0.0.0-20210514084401-e8d321eab015 // indirect
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
mvdan.cc/xurls/v2 v2.2.0 // indirect
)
Loading

0 comments on commit 4663a45

Please sign in to comment.