Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Api Search in text editor #4983

Closed
wants to merge 42 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
3dd8761
Text Editor: add "Search API" button
mrbuds Apr 2, 2024
9df2ba2
fix luacheckrc
mrbuds Apr 4, 2024
121e4dc
fix global
mrbuds Apr 4, 2024
bb196da
on filterInput update add tiny delay before search to avoid bursts of…
mrbuds Apr 4, 2024
96c6da7
support events
mrbuds Apr 4, 2024
c0cfbcf
Add WeakAurasAPI
mrbuds Apr 5, 2024
95a1fb9
improve types conversion
mrbuds Apr 5, 2024
78ebc2f
doc update
mrbuds Apr 5, 2024
b1c6273
use string instead of cstring and workaround alias issue
mrbuds Apr 12, 2024
a003e6b
Add more types to WeakAuras namespace
mrbuds Apr 12, 2024
f7857db
refactor snippet click callback
mrbuds Apr 20, 2024
a42d773
intellissense like experiment
mrbuds Apr 21, 2024
c87af5b
move the api search code to a separate lib
mrbuds Apr 22, 2024
5c18111
use luals 3.8.0, show only public functions, update api
mrbuds Apr 23, 2024
54ff12c
lulas doc_out_path arg was fixes
mrbuds Apr 23, 2024
fa9acd8
WIP
Stanzilla Apr 23, 2024
6c9cf92
WIP2
Stanzilla Apr 23, 2024
95cdcd4
Refactor action
Stanzilla Apr 23, 2024
81d21a5
fix missing checkout
Stanzilla Apr 23, 2024
92d5459
Install homebrew in CI
Stanzilla Apr 23, 2024
01937d2
Mark script executable
Stanzilla Apr 23, 2024
af549ef
Try using pull_request_target
Stanzilla Apr 23, 2024
00b31bd
Trigger on both and set permissions
Stanzilla Apr 23, 2024
a4a4c34
restore entry.name check
Stanzilla Apr 23, 2024
fa42f06
tiny type changes
mrbuds Apr 23, 2024
0a3dccb
test with pat
Stanzilla Apr 23, 2024
7732836
add repo
Stanzilla Apr 23, 2024
3b79d2e
env maybe?
Stanzilla Apr 23, 2024
d4fcd54
pepega
Stanzilla Apr 23, 2024
264f784
I cri
Stanzilla Apr 23, 2024
221c75c
whackamole
Stanzilla Apr 23, 2024
2dc6f85
do we actually need to check out the PR?
Stanzilla Apr 23, 2024
792a63f
ok
Stanzilla Apr 23, 2024
608ac6d
test
Stanzilla Apr 23, 2024
ea7ac97
test
Stanzilla Apr 23, 2024
482b805
Make it so the action runs in main and commits after changes have bee…
Stanzilla Apr 23, 2024
43349c5
WIP
Stanzilla Apr 25, 2024
3b08271
remove duplicate entries
mrbuds Apr 26, 2024
4be36ab
update with changes in APIDoc and don't show a gigantic tooltip for s…
mrbuds Apr 27, 2024
b89d70a
remove result limit, and fix ghost tooltips
mrbuds Apr 29, 2024
ee271ea
set as @private more functions of WeakAuras namespace
mrbuds Apr 29, 2024
d36509f
update embeds, pkgmeta and use new MAJOR
mrbuds Apr 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/scripts/docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
doc.json
output.json
doc.md
*.log
132 changes: 132 additions & 0 deletions .github/scripts/docs/parser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
const fs = require('fs');
const path = require('path');
const namespace = "WeakAuras"

console.log(
`if not WeakAuras.IsLibsOK() then return end
---@type string
local AddonName = ...
---@class OptionsPrivate
local OptionsPrivate = select(2, ...)

local WeakAurasAPI =
{
Name = "WeakAuras",
Type = "System",
Namespace = "WeakAuras",

Functions =
{`
)

function isNilable(obj) {
return obj.view.match("nil|\\?") ? "true" : "false"
}

function wowType(obj) {
if (obj.view.match("string")) {
return "string";
}
if (obj.view.match("boolean")) {
return "bool";
}
if (obj.view.match("integer|number")) {
return "number";
}
if (obj.view === "unknown|nil") {
return "unknown"
}
if (obj.view === "(\"friendly\"|\"hostile\")?") { // I don't know how to handle this alias properly
return "string"
}
return obj.view;
}

const data = fs.readFileSync(path.join(__dirname, 'doc.json'), { encoding: 'utf8', flags: 'r' });
const obj = JSON.parse(data);
const allFunctions = new Object;
for (const entry of obj) {
if (entry.name === namespace) {
if (entry.fields) {
for (const field of entry.fields) {
if (field?.extends?.type === "function" && field?.visible === "public") {
const currFunction = new Object;
const args = field?.extends?.args
if (args && args.length > 0) {
currFunction.arguments = new Array;
for (const arg of args) {
currFunction.arguments.push({ name: arg.name, type: wowType(arg), nilable: isNilable(arg)});
};
}
const returns = field?.extends?.returns
if (returns && returns.length > 0) {
currFunction.returns = new Array;
for (const ret of returns) {
currFunction.returns.push({ name: ret.name, type: wowType(ret), nilable: isNilable(ret)})
};
}
// if there is already a function with this name, we check if the new has more args or returns
if (allFunctions[field.name]) {
const currArgs = currFunction.args ? currFunction.args.length : 0
const oldArgs = allFunctions[field.name].args ? allFunctions[field.name].length : 0
const currRets = currFunction.returns ? currFunction.returns.length : 0
const oldRets = allFunctions[field.name].returns ? allFunctions[field.name].returns.length : 0
if (currArgs > oldArgs || currRets > oldRets) {
allFunctions[field.name] = currFunction
}
} else {
allFunctions[field.name] = currFunction
}
}
};
}
}
}

for (var key in allFunctions) {
const currFunction = allFunctions[key]
console.log(` {`);
console.log(` Name = "${key}",`);
console.log(` Type = "Function",`);
if (currFunction.arguments) {
console.log("");
console.log(` Arguments =`);
console.log(` {`);
for (const arg of currFunction.arguments) {
console.log(` { Name = "${arg.name}", Type = "${arg.type}", Nilable = ${arg.nilable} },`);
};
console.log(` },`);
}
if (currFunction.returns) {
console.log("");
console.log(` Returns =`);
console.log(` {`);
for (const ret of currFunction.returns) {
console.log(` { Name = "${ret.name}", Type = "${ret.type}", Nilable = ${ret.nilable} },`);
};
console.log(` },`);
}
console.log(` },`);
}

console.log(
`
},

Events =
{
},

Tables =
{
},
};
local loaded = false
function OptionsPrivate.LoadDocumentation()
if not loaded then
APIDocumentation:AddDocumentationTable(WeakAurasAPI);
loaded = true
end
end
`
);
7 changes: 7 additions & 0 deletions .github/scripts/docs/update-documentation-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

lua-language-server --doc="." --doc_out_path=".github/scripts/docs"

# jq '[.[] | select(.name | index("WeakAuras") != -1)]' doc.json > output.json

node .github/scripts/docs/parser.js > WeakAurasOptions/WeakAurasAPI.lua
2 changes: 1 addition & 1 deletion .github/workflows/atlas-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
workflow_dispatch:

jobs:
atlasUpdate:
atlas-update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/documentation-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Regenerate Type Definitions

on:
push:
branches:
- main
pull_request_target:

jobs:
type-definitions-update:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout WeakAuras
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Set up Homebrew
id: set-up-homebrew
uses: Homebrew/actions/setup-homebrew@master

- name: Install LuaLS
run: |
brew install lua-language-server

- name: Regenerate Type Definitions
run: |
./.github/scripts/docs/update-documentation-files.sh
shell: bash

- name: Push Changes to PR
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "Update generated types from ${GITHUB_SHA:0:7}"
2 changes: 1 addition & 1 deletion .github/workflows/issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
types: [opened, edited]

jobs:
auto_close_issues:
auto-close-issues:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/modelpaths-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
workflow_dispatch:

jobs:
modelPathsUpdate:
modelpaths-update:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release_notifications.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Send Release Notifications

# See https://github.com/WeakAuras/WeakAuras2/wiki/%5BTEAM-INTERNAL%5D-Setting-up-Release-Notification-Hooks

on:
workflow_dispatch:
release:
types: [published]

jobs:
release-notification-output:
Expand Down
123 changes: 0 additions & 123 deletions .github/workflows/release_notifications_manual_tests.yml

This file was deleted.

Loading
Loading