Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
1780e6e
remove redundant files
ImpleLee Mar 6, 2021
8736ae5
more newlines
ImpleLee Mar 6, 2021
817884e
generate better type
ImpleLee Mar 6, 2021
618f928
reconstruct genFunction
ImpleLee Mar 6, 2021
a0434c2
generate enums first
ImpleLee Mar 6, 2021
0b8cbb8
add callbacks
ImpleLee Mar 6, 2021
0f7199b
fix supertypes
ImpleLee Mar 6, 2021
70ee994
new enum generation
ImpleLee Mar 6, 2021
e4935ac
temporary workaround for multi-line enum comment
ImpleLee Mar 6, 2021
8a8dceb
fix parameters that share type and document
ImpleLee Mar 6, 2021
8a95af9
fix typename
ImpleLee Mar 6, 2021
8abb9fc
fix enum
ImpleLee Mar 6, 2021
62b2249
add additional definitions
ImpleLee Mar 6, 2021
577ad04
fix module
ImpleLee Mar 6, 2021
ff2be4a
update submodule
ImpleLee Mar 6, 2021
96d2983
update README
ImpleLee Mar 6, 2021
85ec4f5
update README
ImpleLee Mar 6, 2021
a4b23c2
fix README
ImpleLee Mar 6, 2021
ce03abc
Squashed commit of the following:
ImpleLee Mar 6, 2021
52479fb
remove `merge` from actions `on`
ImpleLee Mar 6, 2021
4e4986c
describe the GitHub actions in the README
ImpleLee Mar 6, 2021
fa8f83a
add a link in README
ImpleLee Mar 6, 2021
fe01a10
remove the `zip` in the workflow
ImpleLee Mar 6, 2021
57c0677
update usage and example workflow in README
ImpleLee Mar 8, 2021
4b067da
update the usage as Lua plugin on VSCode changes
ImpleLee Mar 9, 2021
80007a3
properly escape the string, fixes #8
ImpleLee Mar 13, 2021
e52d91e
fix wrong type annotation, fixes #8
ImpleLee Mar 13, 2021
547077d
got comment on enums, fixes #2
ImpleLee Mar 18, 2021
e3e9875
update submodule `love-api`
ImpleLee Apr 1, 2021
510d0f3
A total rewrite
ImpleLee Apr 1, 2021
8f23f15
fix workflow and use generated annotations
ImpleLee Apr 1, 2021
d20e22d
simple format change
ImpleLee Apr 2, 2021
150ebbd
better error reporting in `genEmmyAPI.lua`
ImpleLee Apr 2, 2021
9b1d8d4
generate not type when returning `...`
ImpleLee Apr 2, 2021
def8c58
update submodule
ImpleLee Apr 30, 2021
d11b02d
remove unnecessary symbolic link
ImpleLee Apr 30, 2021
71f19a0
update github workflow and readme
ImpleLee Apr 30, 2021
37a1087
split `checkAPIformat.lua` into multiple files
ImpleLee Apr 30, 2021
c080135
log to `stderr` instead of `stdout`
ImpleLee Apr 30, 2021
79f3cd7
update README
ImpleLee Apr 30, 2021
047914a
new default syntax
ImpleLee Apr 30, 2021
3567b8a
Mention `Lua.workspace.preloadFileSize` in README
ImpleLee Jun 27, 2021
6160fce
remove credit section in `README`
ImpleLee Jun 27, 2021
b0dd7f9
add `?` to optional field and return value
ImpleLee Jul 2, 2021
4fb5747
use `?` to notate generation code
ImpleLee Jul 2, 2021
fa3d541
use `lightuserdata` where the doc says so
ImpleLee Jul 2, 2021
3d13c3d
preserve order of definition of fields
ImpleLee Jul 5, 2021
cbb6677
add traceback to `type_corrector`
ImpleLee Jul 5, 2021
0c6db6e
fix
ImpleLee Jul 5, 2021
2035c6e
add [] for positional field and comment them out temporarily
ImpleLee Jul 5, 2021
c17b1ae
uncomment `[1]`-like fields, close #9
ImpleLee Jul 23, 2021
1167098
fix some warnings from language server
ImpleLee Apr 28, 2023
b97e41f
move api definitions to its own file
ImpleLee Apr 28, 2023
833e0d8
better handling for callbacks
ImpleLee Apr 28, 2023
5ea561a
`cdata` -> `ffi.cdata*`
ImpleLee Apr 28, 2023
c5aa812
add `---@meta` to generated files
ImpleLee Apr 28, 2023
882ef02
set love as a global variable
ImpleLee May 1, 2023
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
19 changes: 19 additions & 0 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
on: [push, pull_request_review]
jobs:
packaging-actions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: leafo/gh-actions-lua@v8.0.0
with:
luaVersion: "5.3.3"
- run: cd /home/runner/work/Emmy-love-api/Emmy-love-api
- run: mkdir api/love -p
- run: lua checkAPIformat.lua
- run: lua genEmmyAPI.lua
- uses: actions/upload-artifact@v2
with:
name: api
path: /home/runner/work/Emmy-love-api/Emmy-love-api/api
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
api/
/api-definition.lua
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "love-api"]
path = love-api
url = https://github.com/26f-studio/love-api
68 changes: 33 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,46 @@ A script to generate [LÖVE](https://love2d.org/) API autocomplete files for [Em

## How to use it

1. Donwload or clone the [LÖVE API](https://github.com/love2d-community/love-api) into a directory on your computer (if you want the API for an older version, check the "releases" of that repository).
2. Create a directory named `api` in the directory, do not put any files in there or run anything in it.
3. Download `genEmmyAPI.lua` from this repository into the same directory (either click on the filename and click "Raw" and save the file, or donwload or clone repository to your computer and move the file over).
4. Run `genEmmyAPI.lua` in the directory, i.e. run `lua genEmmyAPI.lua` in the terminal. This will generate the API autocomplete files in the `api` folder.
5. Copy the `api` folder into your project's source folder, the same folder where `main.lua` is (you can rename it whatever you want, it doesn't have to be called `api`).
### Prepare the `api` folder to put your api in

Once you start or refresh your IDE (might be automatic) you should have autocomplete and quick documentation for LÖVE!
- You can download the `api.zip` from the artifacts of the latest [GitHub Actions](https://github.com/26F-Studio/Emmy-love-api/actions) and unzip the `api` from it.
- Alternatively, you can build the `api` folder by yourself.

#### How to build the `api` folder manually

1. Clone this repository *recursively* `--recursive`.
2. Create path `api/love` in the same folder where `genEmmyAPI.lua` is.
3. `lua genEmmyAPI.lua` and the API is generated in `api`.

## Other LÖVE versions

When you want to change the LÖVE version you use, just delete the `api` folder from your project, and redo the steps above for the appropriate version of the API.
### Use the APIs in your project

- Copy the content of `api` folder into your project's root directory (the same folder where `main.lua` is). The content is just `love.lua` and a folder called `love`.
- If you use [the Lua plugin on VS code](https://github.com/sumneko/lua-language-server), rather than copying, you can [specify the API](https://github.com/sumneko/lua-language-server/wiki/EmmyLua-Libraries).
Note that some API files might be too large for this plugin, and you should change the setting `Lua.workspace.preloadFileSize` to be at least `250` to fix it.

Once you start or refresh your IDE (might be automatic) you should have autocomplete and quick documentation for LÖVE!

## Example workflow (Linux)

```
kirby@devbox:~/devel$ git clone https://github.com/love2d-community/love-api.git
Cloning into 'love-api'...
remote: Enumerating objects: 34, done.
remote: Counting objects: 100% (34/34), done.
remote: Compressing objects: 100% (31/31), done.
remote: Total 4170 (delta 15), reused 15 (delta 3), pack-reused 4136
Receiving objects: 100% (4170/4170), 4.29 MiB | 3.90 MiB/s, done.
Resolving deltas: 100% (2617/2617), done.
kirby@devbox:~/devel$ git clone https://github.com/kindfulkirby/Emmy-love-api.git
$ git clone https://github.com/26F-Studio/Emmy-love-api.git --recursive --depth=1 --shallow-submodules --single-branch
Cloning into 'Emmy-love-api'...
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Enumerating objects: 12, done.
remote: Counting objects: 100% (12/12), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 210 (delta 1), reused 2 (delta 0), pack-reused 201
Receiving objects: 100% (210/210), 186.86 KiB | 898.00 KiB/s, done.
Resolving deltas: 100% (91/91), done.
kirby@devbox:~/devel$ cp Emmy-love-api/genEmmyAPI.lua love-api/
kirby@devbox:~/devel$ cd love-api/
kirby@devbox:~/devel/love-api$ mkdir api
kirby@devbox:~/devel/love-api$ lua genEmmyAPI.lua
--finished.
kirby@devbox:~/devel/love-api$ cp -r api/ ../mygame/src/
kirby@devbox:~/devel/love-api$
remote: Total 12 (delta 0), reused 5 (delta 0), pack-reused 0
Unpacking objects: 100% (12/12), 6.49 KiB | 830.00 KiB/s, done.
Submodule 'love-api' (https://github.com/26f-studio/love-api) registered for path 'love-api'
Cloning into '/tmp/Emmy-love-api/love-api'...
remote: Enumerating objects: 195, done.
remote: Counting objects: 100% (195/195), done.
remote: Compressing objects: 100% (153/153), done.
remote: Total 195 (delta 83), reused 81 (delta 30), pack-reused 0
Receiving objects: 100% (195/195), 174.27 KiB | 281.00 KiB/s, done.
Resolving deltas: 100% (83/83), done.
Submodule path 'love-api': checked out '0333363b76aa8e2372c3545f9aea1d31c68f6c39'
$ cd Emmy-love-api
$ mkdir -p api/love
$ lua genEmmyAPI.lua 2>/dev/null
```


## Credits

Original script by https://github.com/tangzx
One tiny modification of the script, README by https://github.com/kindfulkirby
Loading