npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

reascriptluaparser

v2.0.2

Published

Parser for Reascript API HTML file from Reaper DAW. Use as module or global CLI

Downloads

24

Readme

reascriptluaparser

About

This tool parses the reascripthelp.html file generated by Reaper and generates a JSON containing an array of methods from the api. It can be used as as CLI that will write a reaperAPI.json file to the same directory of the given html file, or as a module that receives a string with the html and returns an array of methods.

If you need help generating reascripthelp.html from reaper, see Generating Reaper API HTML

The resulting api has been eye checked but not extensively manually checked yet. if you find any bugs or unexpected output, please open an issue.

Example parsed result

[
  // Lua: MediaItem reaper.AddMediaItemToTrack(MediaTrack tr)
  {
    "name": "AddMediaItemToTrack",
    "params": [{ "type": "MediaTrack", "name": "tr" }],
    "returns": [{ "type": "MediaItem" }],
    "namespace": "reaper",
    "description": "creates a new media item."
  },
  // Lua: integer reaper.AddProjectMarker(ReaProject proj, boolean isrgn, number pos, number rgnend, string name, integer wantidx)
  {
    "name": "AddProjectMarker",
    "params": [
      { "type": "ReaProject", "name": "proj" },
      { "type": "boolean", "name": "isrgn" },
      { "type": "number", "name": "pos" },
      { "type": "number", "name": "rgnend" },
      { "type": "string", "name": "name" },
      { "type": "integer", "name": "wantidx" }
    ],
    "returns": [{ "type": "integer" }],
    "namespace": "reaper",
    "description": "Returns the index of the created marker/region, or -1 on failure. Supply wantidx>=0 if you want a particular index number, but you'll get a different index number a region and wantidx is already in use."
  },
  // Lua: integer reaper.DeleteTakeStretchMarkers(MediaItem_Take take, integer idx, optional number countIn)
  {
    "name": "DeleteTakeStretchMarkers",
    "params": [
      { "type": "MediaItem_Take", "name": "take" },
      { "type": "integer", "name": "idx" },
      { "type": "number", "name": "countIn", "optional": true }
    ],
    "namespace": "reaper",
    "description": "Deletes one or more stretch markers. Returns number of stretch markers deleted."
  }
]

Install

Use as a CLI:

npm install --global reascriptluaparser

Use as a module in your project:

npm install reascriptluaparser

CLI Usage

This tool does one thing, and one thing only: It parses a given html file and saves the parsed array to a JSON file in the same directory of the source file.

reascriptluaparser /path/to/reascripthelp.html

options:

Options:
  -V, --version  output the version number
  -h, --help     display help for command

Module Usage

This package is written in Typescript and bundles it's own types declarations. It can therefore be used out of the box in JS or TS projects.

It exports a single Synchronous method that takes a string containing the HTML from the file and returns an array of methods

In case of malformed HTML or invalid input the parser will throw.

Minimal Example

Javascript + Node

const fs = require('fs')
const { parser } = require('reascriptluaparser')

const html = fs.readFileSync('./reascripthelp.html', 'utf8')
const api = parser(html)

Typescript (depends on your tsconfig.json)

import fs = require('fs')
import { parser } from 'reascriptluaparser'

const html = fs.readFileSync('./reascripthelp.html', 'utf8')
const api = parser(html)

Types

typescript types:

interface Method {
  name: string
  params?: Variable[]
  returns?: Variable[]
  description?: string
  namespace?: string
}

interface Variable {
  type?: string
  name?: string
  optional?: boolean
}

reascriptluaparser returns type Method[]

Generating Reaper API HTML

  1. Open Reaper
  2. Select Help -> ReaScript Documentation from the top menu. this will open a page in your browser
  3. The address for the page points to the generated file. You might want to copy it somewhere else.

Known Issues

  • parser ignores entries Lua: reaper.new_array([table|array][size]), gfx.triangle(x1,y1,x2,y2,x3,y3[x4,y4...]), and gfx.printf("format"[, ...])