luaprovider

package module
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 16, 2023 License: Unlicense Imports: 19 Imported by: 1

README

a logo depicting a moon

Lua Provider

Warning

This is a beta software. The API is not stable and may change at any time.

This is a generic provider for libmangal that uses Lua scripts to create subproviders.

It uses native go implementation of the Lua interpreter and provides a set of libraries that can be used in the scripts.

Take a look at the official lua scripts repository

Features

  • Built-in Lua VM without CGO with gopher-lua
  • Batteries-included library
  • Ships with CLI helper tools for generating templates & probing.
  • Luadoc generation which enables autocompletion for you IDE
  • Script template generation

Note

It is recommended to use lua-language-server to get nice completions for your IDE

VSCode extension

Scripts

Overview

See examples of scripts

See SDK documentation

Scripts must look like this:

function SearchMangas(query)
  return {}
end

function MangaVolumes(manga)
 return {}
end

function VolumeChapters(volume)
 return {}
end

function ChapterPages(chapter)
  return {}
end

Notice the four required global functions

  • SearchMangas - searches for mangas based on the given query.
  • MangaVolumes - gets manga volumes. Each manga must have at least 1 volume.
  • VolumeChapters - gets chapters of the given volume.
  • ChapterPages - gets pages of the given chapter.

The scripts can load sdk with

local sdk = require("sdk")

Which provides these packages:

Documentation

Packages

Script Development

Install helper tools

just install-cmd

Then use it to generate a new workflow

lua-provider-gen -sdk -provider -luarc

This command will create the following files:

  • sdk.lua - gives IDE autocompletion
  • provider.lua - a provider script template
  • .luarc.json - a language server configuration

Documentation

Index

Constants

View Source
const Version = "0.5.2"

Variables

This section is empty.

Functions

func LuaDoc

func LuaDoc() string

LuaDoc will generate library documentation so that language servers can benefit from it.

It's optimized for the https://github.com/LuaLS/lua-language-server

func LuaTemplate

func LuaTemplate() string

LuaTemplate will generate template for the valid lua script used by this provider.

func LuarcJSON added in v0.3.4

func LuarcJSON() string

func NewLoader

func NewLoader(script []byte, info libmangal.ProviderInfo, options Options) (libmangal.ProviderLoader, error)

NewLoader creates new lua provider loader for the given script.

It won't run the script itself.

Types

type IntoLValue

type IntoLValue interface {
	IntoLValue() lua.LValue
}

type Options

type Options struct {
	HTTPClient        *http.Client
	HTTPStoreProvider func() (gokv.Store, error)
	PackagePaths      []string
}

func DefaultOptions

func DefaultOptions() Options

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL