Skip to content

Commit

Permalink
Add documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
sunoru authored Nov 22, 2022
1 parent 1fbad98 commit 8e7496d
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 26 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/Documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Documentation

on:
push:
branches:
- main
tags: '*'
pull_request:

jobs:
build:
permissions:
contents: write
# Since 1.8 is not working on Linux, and 1.9 is not released yet.
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: '1.8'
- name: Install dependencies
run: julia --project=docs/ -e 'using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate()'
- name: Build and deploy
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: julia --project=docs/ docs/make.jl
36 changes: 35 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
# Webviews.jl

[![CI Test](https://github.com/sunoru/Webviews.jl/actions/workflows/CI.yml/badge.svg)](https://github.com/sunoru/Webviews.jl/actions/workflows/CI.yml)
[![codecov](https://codecov.io/gh/sunoru/WebViews.jl/branch/main/graph/badge.svg?token=55lxcNYhBO)](https://codecov.io/gh/sunoru/WebViews.jl)
[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://sunoru.github.io/Webviews.jl/stable)
[![](https://img.shields.io/badge/docs-dev-blue.svg)](https://sunoru.github.io/Webviews.jl/dev)

Julia wrappers for [webview](https://github.com/webview/webview).
Julia wrappers for [webview](https://github.com/webview/webview),
a tiny cross-platform webview library.

## Installation & Dependencies

`Webviews.jl` requires Julia v1.8 or later on Windows and macOS, and Julia v1.9 or later on Linux.

You can install this package with Julia's package manager:

```julia
(@v1.8) pkg> add Webviews
```

For Linux users, you need to install the following dependencies:

```bash
# Fedora
sudo dnf install gtk3-devel webkit2gtk3-devel
# Debian/Ubuntu
sudo apt install libwebkit2gtk-4.0-dev
# Arch Linux
sudo pacman -S webkit2gtk
```

**Note**: `Webviews.jl` downloads its own prebuilt binaries and depends on libraries that are provided by the operating system, instead of using JLL packages.

## Usage

See the [docs](https://sunoru.github.io/Webviews.jl/dev/) or [examples](./examples/).

## LICENSE
[MIT License](./LICENSE).
2 changes: 2 additions & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build/
site/
5 changes: 5 additions & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[deps]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

[compat]
Documenter = "0.27"
12 changes: 12 additions & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Documenter
using Webviews

makedocs(
sitename = "Webviews",
format = Documenter.HTML(),
modules = [Webviews]
)

deploydocs(
repo = "github.com/sunoru/Webviews.jl.git"
)
10 changes: 10 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Webviews.jl

Julia wrappers for [webview](https://github.com/webview/webview),
a tiny cross-platform webview library.

## Library Index

```@index
Pages = ["lib.md"]
```
28 changes: 28 additions & 0 deletions docs/src/lib.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Library

## Index

```@index
Pages = ["lib.md"]
```

## Public Interface

```@docs
Webviews
Webview
WindowSizeHint
run(::Webview)
terminate
destroy
window_handle
title!
resize!(::Webview)
sizehint!(::Webview, ::WindowSizeHint)
navigate!
html!
init!
eval!
bind(::Function, ::Webview, ::AbstractString)
unbind
```
16 changes: 16 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Examples of Webviews.jl

| Example | Description |
| ------- | ----------- |
| [bind](./bind.jl) | Bind Julia functions and call them from JavaScript. |
| [multiple](./multiple.jl) | Create multiple webviews. |
| [server](./server.jl) | Create a HTTP server asychronously and access it from Webview. |

## Usage

It is recommended to use the environment for running the examples:

```bash
$ julia --project=@. -e 'using Pkg; Pkg.instantiate()'
$ julia --project=@. ./server.jl
```
32 changes: 7 additions & 25 deletions src/Webviews.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
```@meta
DocTestSetup = quote
using Webviews
end
```
# Wrappers for https://github.com/webview/webview
"""
Webviews
Julia wrappers for [webview](https://github.com/webview/webview),
a tiny cross-platform webview library.
"""
module Webviews

using Libdl: Libdl
Expand Down Expand Up @@ -166,7 +167,7 @@ mutable struct Webview
size::Tuple{Int32, Int32}
size_hint::WindowSizeHint
_destroyed::Bool
_platform::InstancePlatformSettings
const _platform::InstancePlatformSettings
function Webview(
size::Tuple{Integer, Integer}=(1024, 768);
title::AbstractString="",
Expand Down Expand Up @@ -395,10 +396,6 @@ eval!(w::Webview, js::AbstractString) = (ccall(
w, js
); w)

function _raw_bind(f::Function, w::Webview, name::AbstractString)
cf = @cfunction $f Cvoid (Ptr{Cchar}, Ptr{Cchar}, Ptr{Cvoid})
cf
end
function _return(w::Webview, seq_ptr::Ptr{Cchar}, success::Bool, result)
s = try
if success
Expand Down Expand Up @@ -439,21 +436,6 @@ webview context and the callback automatically converts and returns the
return value to the webview.
**Note:** The callback function must handle a `Tuple` as its argument.
# Example
```jldoctest
julia> webview = Webview();
julia> result = 0;
julia> bind(webview, "add") do (a, b)
global result = a + b
terminate(webview)
end;
julia> html!(webview, "<script>add(1, 2)</script>");
julia> run(webview);
julia> result
3
```
"""
function Base.bind(f::Function, w::Webview, name::AbstractString)
cf = @cfunction _bind_wrapper Cvoid (Ptr{Cchar}, Ptr{Cchar}, Ptr{Cvoid})
Expand Down

2 comments on commit 8e7496d

@sunoru
Copy link
Owner Author

@sunoru sunoru commented on 8e7496d Nov 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/72700

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.1.0 -m "<description of version>" 8e7496d13597adf639f6c6f7f75c62fba01cabf5
git push origin v0.1.0

Please sign in to comment.