luaprovider

package module
v0.11.3 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2024 License: Unlicense Imports: 23 Imported by: 2

README

a logo depicting a moon

Lua Provider

Go Reference

Warning

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.

Note: This is a fork of mangalorg/luaprovider.

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 (still in the original repo).

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 (still in the original repo).

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

Credits

Moon logo: Moon phase icons created by vectorsmarket15 - Flaticon

Documentation

Index

Constants

This section is empty.

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

func LuarcJSON() string

func NewLoader

func NewLoader(script []byte, info lm.ProviderInfo, options Options) (lm.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
	UserAgent    string
	HTTPStore    func(providerID string) (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