Giter VIP home page Giter VIP logo

love-api's People

Contributors

aiq0 avatar alloyed avatar azariasb avatar bandaloo avatar bartbes avatar brenobaptista avatar c3pa avatar dail8859 avatar daviel avatar davisdude avatar doctorgester avatar fang- avatar hahawoo avatar hazzard993 avatar leafi avatar lowne avatar massette avatar michcioperz avatar mikuauahdark avatar oniietzschan avatar pablomayobre avatar rameshvarun avatar rm-code avatar sheepolution avatar steveroll-git avatar sumneko avatar sylviblossom avatar tesselode avatar turtlep avatar uradasources avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

love-api's Issues

Any interest in adding "skeleton" code to the README?

Sometimes I want to do something simple and small with love-api, and I had been wishing I could copy and paste some base code so I could change it to do I wanted instead of having to look at the table structure and write code to loop through everything.

So maybe it would be useful to add something like this to the README?

Here is what I have now: (not thoroughly tested!)

local api = require('love-api.love_api')

-- api.version

local function loopArgumentsOrReturns(arguments, argumentOrReturn, function_, variant, module_, moduleOrTypeOrCallback, prefix)
    for _, argument in ipairs(arguments or {}) do
        -- argument.type
        -- argument.name
        -- argument.description
        -- argument.default (optional)

        for _, flag in ipairs(argument.table or {}) do
            -- flag.type
            -- flag.name
            -- flag.description
            -- flag.default (optional)
        end
    end
end

local function loopFunctions(functions, module_, moduleOrTypeOrCallback, prefix)
    for _, function_ in ipairs(functions or {}) do
        -- function_.name
        -- function_.description

        for _, variant in ipairs(function_.variants) do
            loopArgumentsOrReturns(variant.arguments, 'argument', function_, variant, module_, moduleOrTypeOrCallback, prefix)
            loopArgumentsOrReturns(variant.returns, 'return', function_, variant, module_, moduleOrTypeOrCallback, prefix)
        end
    end
end

local function loopTypes(types, module_)
    for _, type_ in ipairs(types or {}) do
        -- type_.name
        -- type_.description
        -- type_.parenttype

        for _, constructor in ipairs(type_.constructors or {}) do
            -- constructor
        end

        for _, supertype in ipairs(type_.supertypes or {}) do
            -- supertype
        end

        for _, subtype in ipairs(type_.subtypes or {}) do
            -- subtype
        end

        loopFunctions(type_.functions, type_, 'type', type_.name..':')
    end
end

loopFunctions(api.functions, nil, 'module', 'love.')
loopFunctions(api.callbacks, nil, 'callback', 'love.')
loopTypes(api.types, nil)

for _, module_ in ipairs(api.modules) do
    -- module_.name
    -- module_.description

    loopFunctions(module_.functions, module_, 'module', 'love.'..module_.name..'.')
    loopTypes(module_.types, module_)

    for _, enum in ipairs(module_.enums or {}) do
        -- enum.name
        -- enum.description

        for _, constant in ipairs(enum.constants or {}) do
            -- constant.name
            -- constant.description
        end
    end
end

So if I wanted to, for example, print out the functions which return a single boolean and have one or more arguments, I can copy and paste the code above and just write this in the variant loop:

if variant.returns and #variant.returns == 1 and variant.returns[1].type == 'boolean' and variant.arguments then
    print(prefix..function_.name)
    break
end

Typo in getPixelDimensions method definition

Hello,

I noticed a typo in the getPixelDimensions method, it currently reads getPixelDimenions().

Relevant code snippet:

{
name = 'getPixelDimenions',
description = 'Gets the width and height in pixels of the window.\n\nlove.graphics.getDimensions gets the dimensions of the window in units scaled by the screen\'s DPI scale factor, rather than pixels. Use getDimensions for calculations related to drawing to the screen and using the graphics coordinate system (calculating the center of the screen, for example), and getPixelDimensions only when dealing specifically with underlying pixels (pixel-related calculations in a pixel Shader, for example).',
variants = {
{
returns = {
{
type = 'number',
name = 'pixelwidth',
description = 'The width of the window in pixels.',
},
{
type = 'number',
name = 'pixelheight',
description = 'The height of the window in pixels.',
},
},
},
},
},

Reference: https://love2d.org/wiki/love.graphics.getPixelDimensions

Missing type definitions: CanvasFormat, TextureFormat, MouseConstant

These guys are missing definitions:

  • CanvasFormat (used with love.graphics.newCanvas)
  • TextureFormat (used with love.graphics.newImage)
  • MouseConstant (used with love.mouse.isDown)

(Also love.graphics.newShader uses mat4 and vec4, but those aren't explicitly defined either...)

Move love.conf to callbacks

The love.conf is currently documented in love-api in the functions of the love module. However, this function is not provided by Löve2D, but is expected to be provided by the Löve2D users. Furthermore, the Löve2D wiki does not list it with the functions of the love module, but with the callbacks. So it should be documented in the callbacks of the love module.

Add test to make sure there is a variants table

For example love.window.restore caused some issues for love-atom, because the empty variants table was omitted.

        {
            name = 'restore',
            description = 'Restores the size and position of the window if it was minimized or maximized.',
            variants = {
                {}
            }
        },

@positive07 Maybe you have some time to take a look at this? :)

Wrong structure

{
name = 'getChildren',
description = 'Gets the child indices of the shapes of the two colliding fixtures. For ChainShapes, an index of 1 is the first edge in the chain.\nUsed together with Fixture:rayCast or ChainShape:getChildEdge.',
variants = {
returns = {
{
type = 'number',
name = 'indexA',
description = 'The child index of the first fixture\'s shape.'
},
{
type = 'number',
name = 'indexB',
description = 'The child index of the second fixture\'s shape.'
}
}
}
},

Missed table between variants and returns

How to handle function variants

Some functions have multiple variants like love.graphics.push. These variants sometimes have their descriptions on the wiki. The question is how to handle these in the documentation.

My suggestion would be this:

{
    name = 'push',
    description = 'Copies and pushes the current coordinate transformation to the transformation stack.\n\nThis function is always used to prepare for a corresponding pop operation later. It stores the current coordinate transformation state into the transformation stack and keeps it active. Later changes to the transformation can be undone by using the pop operation, which returns the coordinate transform to the state it was in before calling push.',
    functions = {
        {
            description = 'Pushes the current transformation to the transformation stack.',
        },
        { 
            description = 'Pushes a specific type of state to the stack.',
            arguments = {
                {
                    type = 'StackType',
                    name = 'stack',
                    description = 'The type of stack to push (e.g. just transformation state, or all love.graphics state).'
                },
            }
        }
    }
},

Translations

I think it might be nice if love-api had translated descriptions.

Things I'm unsure of:

  • How can the translated text can be automatically retrieved from the wiki? Would the scraper from SublimeLove be a useful starting point?

  • What's the best way of putting the translations into the love-api table?

One option is to have a translations table next to every description:

{
    name = 'hasTextInput',
    description = 'Gets whether text input events are enabled.',
    translations = {
        de = 'Gibt zurück, ob Texteingaben-Ereignisse aktiviert sind.',
        ja = 'テキスト入力イベントが有効であるかどうか取得します。',
        ko = '텍스트 입력을 감지하고 있는지 확인합니다.'
    }
    variants = {
	{
	    returns = {
		{
		    type = 'boolean',
		    name = 'enabled',
		    description = 'Whether text input events are enabled.'
                    translatations = {
                        de = 'Ob Text-Ereignisse aktiviert sind, oder nicht.',
                        jp = 'テキスト入力イベントが有効であれば true を、無効であれば false を返します。',
                        ko = '텍스트 입력을 감지하고 있으면 true.'
                    }
		}
	    }
	}
    }
},
  • Would it be useful to automatically translate (using Google Translate or something) missing descriptions? Maybe it could have tag at the end or something letting love-api users know what's automatically translated and what's not, like de = Ob Texteingabeereignisse aktiviert sind. [auto]'`

@rm-code, since you're a wiki translator I'm sure you have a much better idea about all of this stuff than me! :)

Also I just noticed now how much better the documentation could be for languages other than English... The module pages (e.g. http://www.love2d.org/wiki/love.keyboard_(Deutsch) ) only list translated functions (surely it would be better if the English version was there if the translated version was unavailable?), and the module links on the left side bar only link to English pages.

So, this all seems like a lot of work and I don't think it will/should happen necessarily, but I just wanted to post this as a "pie in the sky" feature. :)

Links

As discussed in the forum thread, having local links pointing to other sections of the doc would be nice, also having external links wouldnt hurt either. I would love to work on this feature, just wanted to know what format should we use for the links.

I was thinking that maybe using

`local link`

to enclose the text would be nice for local links and something like markdown []() syntax for external links.

What do you say?

Also there should be a method to get the url for a link (parse the text?), and a method to completely unformat the text (delete the characters [](), ` and links in order to make it clearer)

Lua 5.4's `require` corrupts tables

As of Lua 5.4, require returns a second value.

Docs of require for Lua 5.3:

Once a loader is found, require calls the loader with two arguments: modname and an extra value dependent on how it got the loader. (If the loader came from a file, this extra value is the file name.) If the loader returns any non-nil value, require assigns the returned value to package.loaded[modname]. If the loader does not return a non-nil value and has not assigned any value to package.loaded[modname], then require assigns true to this entry. In any case, require returns the final value of package.loaded[modname].

Docs of require for Lua 5.4 (emphasis mine)

Once a loader is found, require calls the loader with two arguments: modname and an extra value, a loader data, also returned by the searcher. The loader data can be any value useful to the module; for the default searchers, it indicates where the loader was found. (For instance, if the loader came from a file, this extra value is the file path.) If the loader returns any non-nil value, require assigns the returned value to package.loaded[modname]. If the loader does not return a non-nil value and has not assigned any value to package.loaded[modname], then require assigns true to this entry. In any case, require returns the final value of package.loaded[modname]. Besides that value, require also returns as a second result the loader data returned by the searcher, which indicates how require found the module.

If using Lua 5.4 or greater, this breaks many scripts that rely on each module being a valid table object. This is because many of the tables, e.g. types / enums, are just made by calling require on the constituent objects. For example an example of how this breaks things, see, vim-love-docs.

Enforce HTTPS Access

I don't have access to the Settings page of this repo so I can't change this.

0.10.0 Update

The update to 0.10.0 is now happening on the develop branch. It's hard to differentiate between changes which are made because of 0.10.0 or just concern 0.9.2. So I will treat all changes as changes towards 0.10.0.

Feel free to contribute based on the changelog.

Latest revision as of 03:15, 17 December 2015

Additions

  • Added an iOS port.
  • Added an Android port.
  • Added support for reading accelerometer values on mobile devices. Accelerometers are exposed as 3-axis Joysticks.
  • Added the flag t.accelerometerjoystick to love.conf. Disables accelerometer-as-joystick functionality on mobile devices when false.
  • Added the flag t.gammacorrect to love.conf (replaces t.window.srgb.) Enabling it globally enables gamma-correct rendering, when supported.
  • Added video playback support for Ogg Theora videos, via love.graphics.newVideo.
  • Added love.video module. It is not used for displaying videos on-screen (see Video objects for that).
  • Added love.touch module. Note that it has important differences from the touch implementation in the LÖVE 0.9.2 Android and iOS ports.
  • Added love.touch.getTouches
  • Added love.touch.getPosition
  • Added love.touch.getPressure
  • Added love.touchpressed, love.touchreleased, and love.touchmoved.
  • Added love.system.vibrate.
  • Added love.filesystem.setRequirePath and love.filesystem.getRequirePath.
  • Added an optional program exit status number argument to love.event.quit.
  • Added love.filedropped and love.directorydropped event callback functions.
  • Added love.lowmemory event callback function, called when the app is running out of memory on mobile operating systems.
  • Added love.textedited event callback function, called when the user is compositing text (e.g. via an IME.)
  • Added love.wheelmoved event callback function (replaces "wu" and "wd" constants for love.mousepressed.)
  • Added love.mouse.hasCursor.
  • Added a boolean argument to love.mousepressed and love.mousereleased indicating whether the button event originated from a touch press.
  • Added love.keyboard.isScancodeDown.
  • Added optional x/y/width/height arguments to love.keyboard.setTextInput. They tell the system where text will show up so on-screen keyboards can avoid that area.
  • Added Source:getType (replaces Source:isStatic.)
  • Added Source:getDuration and Decoder:getDuration.
  • Added an optional string argument containing raw pixel data to the width/height variant of [[love.image.newImageData]].
  • Added love.graphics.ellipse.
  • Added rounded-rectangle support to love.graphics.rectangle.
  • Added love.graphics.points (replaces love.graphics.point).
  • Added love.graphics.intersectScissor.
  • Added an optional argument to love.graphics.setBlendMode which indicates whether to treat the colors of drawn objects as having pre-multiplied alpha.
  • Added a new built-in shader variable: "mat3 NormalMatrix".
  • Added love.graphics.getSupported (replaces love.graphics.isSupported.)
  • Added love.graphics.getSystemLimits (replaces love.graphics.getSystemLimit.)
  • Added love.graphics.stencil, love.graphics.setStencilTest and love.graphics.getStencilTest (replaces love.graphics.setStencil.)
  • Added love.graphics.isActive.
  • Added color arguments to love.graphics.clear. It no longer always uses the background color value.
  • Added love.graphics.discard.
  • Added love.graphics.isGammaCorrect
  • Added the "clampzero" WrapMode.
  • Added the ability to specify custom mipmaps when creating an image, via [[love.graphics.newImage]](filename, {mipmaps={mip1, mip2, ...}}).
  • Added optional x/y/width/height arguments to Image:refresh and Canvas:newImageData.
  • Added Image:getFlags.
  • Added one- and two-channel Canvas formats: r8, rg8, r16f, rg16f, r32f, and rg32f.
  • Added support for different formats in each Canvas when using multi-canvas rendering. Added the "multicanvasformats" GraphicsFeature constant.
  • Added support for OpenGL ES 2 and 3.
  • Added support for loading ETC, EAC, PVRTC and ASTC compressed textures on systems that support them.
  • Added custom vertex attribute support for Meshes via new variants of love.graphics.newMesh.
  • Added Mesh:setVertexAttribute and Mesh:getVertexAttribute.
  • Added Mesh:getVertexFormat.
  • Added an optional 'startvertex' argument to Mesh:setVertices.
  • Added the ability for love.graphics.newMesh and Mesh:setVertices to accept a Data object.
  • Added Mesh:flush.
  • Added Mesh:setAttributeEnabled and Mesh:isAttributeEnabled.
  • Added Mesh:attachAttribute.
  • Added SpriteBatch:attachAttribute.
  • Added Shader:sendColor.
  • Added new shader functions: gammaCorrectColor, gammaToLinear, and linearToGamma. The functions also have 'precise' and 'fast' variants.
  • Added Text objects and love.graphics.newText.
  • Added per-character color support to love.graphics.print, love.graphics.printf, and Text objects.
  • Added BMFont bitmap font file support to love.graphics.newFont and love.font.
  • Added kerning support for TrueType/OpenType and BMFont Fonts.
  • Added an optional font hinting argument to love.graphics.newFont when loading TrueType fonts.
  • Added an optional spacing argument to love.graphics.newImageFont, which applies additional spacing to all rendered glyphs.
  • Added Font:setFallbacks.
  • Added love.window.maximize.
  • Added love.window.close.
  • Added love.window.requestAttention.
  • Added love.window.setDisplaySleepEnabled and love.window.isDisplaySleepEnabled.
  • Added BezierCurve:renderSegment and BezierCurve:removeControlPoint.
  • Added BezierCurve:getSegment.
  • Added love.math.compress and love.math.decompress.
  • Added Channel:performAtomic.

Removals

  • Removed callback variant of love.filesystem.getDirectoryItems
  • Removed the "wu" and "wd" constants for love.mousepressed (replaced by love.wheelmoved.)
  • Removed the named mouse button constants (replaced by button numbers.)
  • Removed Source:isStatic (replaced by Source:getType.)
  • Removed image loading support for all (non-compressed texture) file formats except for PNG, JPEG, TGA, and BMP.
  • Removed JPEG encoding support from ImageData:encode.
  • Removed love.graphics.point (replaced by love.graphics.points).
  • Removed love.graphics.setPointStyle and love.graphics.getPointStyle.
  • Removed love.graphics.isSupported (replaced by love.graphics.getSupported.)
  • Removed love.graphics.getSystemLimit (replaced by love.graphics.getSystemLimits.)
  • Removed love.graphics.setStencil (replaced by love.graphics.stencil and love.graphics.setStencilTest.)
  • Removed the "canvas", "shader", "npot", "subtractive", and "mipmap" GraphicsFeature constants (the features always have guaranteed support now.)
  • Removed the "multicanvas" GraphicsFeature constant (use love.graphics.getSystemLimits instead.)
  • Removed the "srgb" GraphicsFeature constant (use love.graphics.isGammaCorrect or love.graphics.getCanvasFormats().srgb instead.)
  • Removed the "srgb" flag in love.window.setMode and in the t.window table in love.conf (Replaced by t.gammacorrect.)
  • Removed the "premultiplied" BlendMode (love.graphics.setBlendMode("alpha", "premultiplied") now does the same thing.)
  • Removed Canvas:getPixel (use Canvas:newImageData instead.)
  • Removed Canvas:clear (use love.graphics.clear instead.)
  • Removed Mesh:getVertices.
  • Removed Mesh:setVertexColors and Mesh:hasVertexColors (use Mesh:setAttributeEnabled("VertexColor", enable) instead.)

Functions deprecated in 0.9.x

  • Removed love.graphics.getMaxImageSize and love.graphics.getMaxPointSize (replaced by love.graphics.getSystemLimits.)
  • Removed Mesh:setImage, Mesh:getImage, SpriteBatch:setImage, SpriteBatch:getImage, ParticleSystem:setImage, and ParticleSystem:getImage (replaced by set/getTexture.)
  • Removed SpriteBatch:bind and SpriteBatch:unbind.
  • Removed Canvas:getFSAA and the "fsaa" flag in love.conf and love.window.setMode (replaced by Canvas:getMSAA and the "msaa" flag.)
  • Removed the "dxt" and "bc5" GraphicsFeature constants (replaced by love.graphics.getCompressedImageFormats.)
  • Removed the "hdrcanvas" GraphicsFeature constant (replaced by love.graphics.getCanvasFormats.)
  • Removed love.window.getWidth, love.window.getHeight and love.window.getDimensions (use love.graphics.getWidth, love.graphics.getHeight, love.graphics.getDimensions or love.window.getMode instead.)

Renamed APIs

  • Renamed the fullscreen type "normal" to "exclusive".
  • Renamed the DistanceModel constants "inverse clamped", "linear clamped", and "exponent clamped" to "inverseclamped", "linearclamped", and "exponentclamped".
  • Renamed blend modes "additive", "subtractive", and "multiplicative" to "add", "subtract", and "multiply".
  • Renamed the key constant and Scancode representing the spacebar from " " to "space".
  • Renamed File:eof to File:isEOF.
  • Renamed Canvas:getImageData to Canvas:newImageData.
  • Renamed love.image's CompressedData type to CompressedImageData.

Other Missing Items

Summary
The following methods are undocumented both here and the LÖVE Wiki.
These will need to be added to the LÖVE Wiki before adding them here, as per the contributing guidelines.
However, the two filesystem methods, should they be documented? Or at they marked as internal-only?

love.filesystem

  • getExecutablePath
  • setFused

Video Object

  • Video:getPixelDimensions
  • Video:getPixelHeight
  • Video:getPixelWidth

Physics Objects

  • Body:getKinematicState
  • Body:setKinematicState
  • Contact:getTangentSpeed
  • Contact:isDestroyed
  • Contact:setTangentSpeed
  • DistanceJoint:getStiffness
  • DistanceJoint:setStiffness
  • Fixture:getType
  • MotorJoint:getCorrectionFactor
  • MotorJoint:getMaxForce
  • MotorJoint:getMaxTorque
  • MotorJoint:setCorrectionFactor
  • MotorJoint:setMaxForce
  • MotorJoint:setMaxTorque
  • MouseJoint:getStiffness
  • MouseJoint:setStiffness
  • PolygonShape:validate
  • WeldJoint:getStiffness
  • WeldJoint:setStiffness
  • WheelJoint:getSpringStiffness
  • WheelJoint:setSpringStiffness

Embed CSS into HTML

While generally not considered best practice, I think sticking the CSS into a <style> tag would be good for this. It would allow people to download the whole API reference, styled, in a single file.

Also maybe bump the font size up a bit? it's pretty small~

Description of structure in README

Maybe it would help people make use of it faster if there is a description of the table structure in the README. Here's what I came up with:

return {
    version = '0.10.1',
    functions = { -- love.something functions, currently only love.getVersion
        -- See function structure below
    },
    modules = {
        {
            name = 'modulename',
            description = 'Description.',
            types = {
                -- See type structure below
            },
            functions = {
                -- See function structure below
            },
            enums = {
                {
                    name = 'EnumName',
                    description = 'Description.',
                    constants = {
                        {
                            name = 'constantname',
                            description = 'Description.'
                        }
                    }
                }
            }
        }
    },
    types = { -- Currently only supertypes
        -- See type structure below
    },
    callbacks = {
        -- See function structure below
    }
}
types = {
    {
        name = 'TypeName',
        description = 'Description.',
        constructors = { -- Optional
            'newTypeName'
        },
        functions = { -- Optional
            -- See function structure below
        },
        supertypes = { -- Optional
            'Supertype'
        },
        subtypes = { -- Optional
            'Subtype'
        }
    }
}
functions = { -- callbacks = {
    {
        name = 'functionName',
        description = 'Description.',
        variants = {
            {
                returns = { -- Optional
                    {
                        type = 'type',
                        name = 'name',
                        description = 'Description.',
                        table = { -- If type is table
                            {
                                type = 'string',
                                name = 'name',
                                description = 'Description.'
                            }
                        }
                    }
                },
                arguments = { -- Optional
                    {
                        type = 'type',
                        name = 'name',
                        default = 'default argument', -- Optional
                        description = 'Description.',
                        table = { -- If type is table
                            {
                                type = 'string',
                                name = 'name',
                                default = 'nil', -- Optional
                                description = 'Description.'
                            }
                        }
                    }
                }
            }
        }
    }
}

Empty tables instead of nil for optional tables

Currently, one has to check if an optional table (i.e. functions, types, enums, returns, arguments, constructors, supertypes, subtypes) exists before looping though it, like this:

if variant.arguments then
	for _, argument in ipairs(variant.arguments) do
	end
end

I think it would be nicer to use if had an empty table instead of nil, so things could be looped through without checking if they exist first.

To avoid adding unnecessary stuff to the files, I suggest that the empty tables be added after the table is created, i.e.:

local api =  {
    -- etc.
}

local function functions(f)
    for _, function_ in ipairs(f) do
        for _, variant in ipairs(function_.variants) do
            if not variant.returns then variant.returns = {} end
            if not variant.arguments then variant.arguments = {} end
        end
    end
end

local function types(t)
    for _, type_ in ipairs(t) do
        if not type_.functions then type_.functions = {} end
        if not type_.constructors then type_.constructors = {} end
        if not type_.supertypes then type_.supertypes = {} end
        if not type_.subtypes then type_.subtypes = {} end

        functions(type_.functions)
    end
end

functions(api.functions)
functions(api.callbacks)
types(api.types)

for _, module_ in ipairs(api.modules) do
    if not module_.functions then module_.functions = {} end
    if not module_.types then module_.types = {} end
    if not module_.enums then module_.enums = {} end

    functions(module_.functions)
    types(module_.types)
end

return api

This change can break things if the script using it is checking to see if something exists for purposes other than looping, so sometimes if variant.arguments then has to become if #variant.arguments > 0 then.

I don't want to make this change now and unexpectedly break people's scripts, but I think it's a worthwhile change, so maybe scripts using the current love-api table could use the above code to test and see if it breaks their code (and enjoy simplifying their code because of the change!), and if it all works then love-api could be changed.

I've updated html-generator.lua to use this empty table format, I'll make a pull request for it.

Error in documentation of methods

The following methods documented in love-api do not exist in Löve2D:

  • Canvas:isActive
  • Font:hasGlyph (it should be "hasGlyphs" according to the Löve2D wiki)

Add license

In the löve discord, someone brought this issue up since they can't incorporate this into their project since they cannot provide a license for it.

Start Documenting 12.0 Functions

While it's unknown when 12.0 will arrive, 12.0 bring many changes by whole that once 12.0 is released it may took long time to get this love-api adapted to all the change.

I'd suggest doing these in forks. Not sure if I have permission to set up new branch in this repository though.

Font size is too small, page does not respond to zoom well

Title says it all. On my 27" 1440p monitor at 100% scaling in Windows, the page looks like this:

image

Text is hard to read so I try zooming to 200%:

image

You can see the sidebar gets cut off on the bottom.

image

Also not sure what's up with the first two items in the list but figured I'd screenshot it too~

If I were to make a suggestion, you could create a couple font size buttons for users to be able to select. Maybe Small: 10pt, Normal: 16pt, and Large: 20, 22, or 24pt?

Other Libraries

LÖVE provides a whole set of libraries with it:

It would be nice to provide access to this libraries in the same format, Is this in the scope of this project? If this is fine, I can write a few of them (UTF and Network libs mostly, since I have used them many times)

Better Specs

With busted and travis set up it makes sense to add some more fine-grained tests to this repo. This should include checking if values have the correct type, if arguments and return variables are formatted correctly etc.

Santos sent me this on the love forums, but I didn't have time to port it to busted yet:

local api = require( 'love_api' )

local function check(t, ok, info)
    for ok_i, ok_v in ipairs(ok) do
        if (ok_v.optional and t[ok_v.name] ~= nil) or (not ok_v.optional) then
            if not (type(t[ok_v.name]) == ok_v.type) then
            print()
            print('Trying to find: '..info.. ' > '..ok_v.name)
            if type(t) == 'table' then
               print()
               print('Table contains:')
               for k, v in pairs(t) do
                  print(k, v)
               end
               print()
            else
               error('Is not table')
            end
            print('Found: '..tostring(t[ok_v.name]))
            print('Should be type: '..ok_v.type)
            print('Is type: '..type(t[ok_v.name]))
            print('Optional: '..tostring(ok_v.optional))
            error('')
         end
        end
    end

    for k, v in pairs(t) do
        local contains = false
        for ok_i, ok_v in ipairs(ok) do
            if k == ok_v.name then
                contains = true
            end
        end
      if not (contains == true) then
         print('Found extra key: '..info..' > '..k)
      end
    end
end

local function check_functions(functions, info)
    if not functions then
        return
    end

    for _, f in ipairs(functions) do
        check(f, {
            {name = 'name', type = 'string'},
            {name = 'description', type = 'string'},
            {name = 'variants', type = 'table'},
        }, info)

        for _, variant in ipairs(f.variants) do
            check(variant, {
                {name = 'returns', type = 'table', optional = true},
                {name = 'arguments', type = 'table', optional = true},
                {name = 'description', type = 'string', optional = true},
            }, info .. ' > variants')

            local function check_returns_or_arguments(a, info)
                if a then
                    for _, r in pairs(a) do
                        check(r, {
                            {name = 'type', type = 'string'},
                            {name = 'name', type = 'string'},
                            {name = 'default', type = 'string', optional = true},
                            {name = 'description', type = 'string'},
                            {name = 'table', type = 'table', optional = true},
                        }, info)

                        if r.table then
                            for _, v in pairs(r.table) do
                                check(v, {
                                    {name = 'type', type = 'string'},
                                    {name = 'name', type = 'string'},
                                    {name = 'default', type = 'string', optional = true},
                                    {name = 'description', type = 'string'},
                                }, info .. ' > table')
                            end
                        end
                    end
                end
            end

            check_returns_or_arguments(variant.returns, info .. ' > '..f.name..' > variants > returns')
            check_returns_or_arguments(variant.arguments, info .. ' > '..f.name..' > variants > returns')
        end
    end
end


local function check_types(types, info)
    if not types then
        return
    end

    for _, t in ipairs(types) do
      check(t, {
         {name = 'name', type = 'string'},
         {name = 'description', type = 'string'},
         {name = 'functions', type = 'table', optional = true},
         {name = 'supertypes', type = 'table', optional = true},
         {name = 'constructors', type = 'table', optional = true},
      }, info)

        check_functions(t.functions, info ..' > '..t.name..' > functions')
    end
end

local function check_enums(enums, info)
    if not enums then
        return
    end

    for _, enum in ipairs(enums) do
        check(enum, {
            {name = 'name', type = 'string'},
            {name = 'description', type = 'string', optional = true},
            {name = 'constants', type = 'table'},
        }, info)

        for _, constant in ipairs(enum.constants) do
            check(constant, {
                {name = 'name', type = 'string'},
                {name = 'description', type = 'string'},
            {name = 'notes', type = 'string', optional = true},
            }, info..' > '..enum.name..' > constants')
        end
    end
end

check(api, {
    {name = 'functions', type = 'table'},
    {name = 'modules', type = 'table'},
    {name = 'types', type = 'table'},
    {name = 'callbacks', type = 'table'},
    {name = 'config', type = 'table'},
}, 'love')

check_functions(api.functions, 'love > functions')
check_functions(api.callbacks, 'love > callbacks')
check_types(api.types, 'love > types')

for _, m in ipairs(api.modules) do
    check(m, {
        {name = 'name', type = 'string'},
        {name = 'description', type = 'string'},
        {name = 'types', type = 'table', optional = true},
        {name = 'functions', type = 'table', optional = true},
        {name = 'enums', type = 'table', optional = true},
    }, 'love > modules')

    check_functions(m.functions, 'love > modules > '..m.name..' > functions')
    check_types(m.types, 'love > modules > '..m.name..' > types')
    check_enums(m.enums, 'love > modules > '..m.name..' > enums')
end

love.graphics is undefined

I use the Lua extention by sumneko for VS Code. Config:

{
  "Lua.runtime.version": "LuaJIT",
  "Lua.diagnostics.globals": ["love", "lldebugger"],
  "Lua.workspace.library": ["${3rd}/love2d/library"],
  "Lua.workspace.checkThirdParty": false
}

But I get errors / warnings that graphics does not exist on love. But e.g. love.audio works. What's wrong?

image

.vscode\extensions\sumneko.lua-2.6.0\server\meta\3rd\love2d\library\love.lua

---@meta

-- version: 11.3
---@class love
love = {}

Merging modules back into love-api

In a personal conversation Santos brought up some good points for having the documentation as a single file.

Would love to hear what other people think, because for my own project (which uses the api) it doesn't matter at all.

Wiki scraping

I've finally made a wiki scraper, which means (ideally) we don't have to manually edit the table anymore.

It's not perfect, for example it doesn't scrape modules for their names and descriptions.

Removing variants which are redundant due to default arguments in other variants

For example, love.physics.newMotorJoint currently has two variants:

love.physics.newMotorJoint(body1, body2, correctionFactor [default: 0.3])
love.physics.newMotorJoint(body1, body2, correctionFactor [default: 0.3], collideConnected [default: false])

when really it has one variant, because the "collideConnected" argument has a default.

The functions I found which might be in this category are:

love.filesystem.mount (appendToPath default is false)
love.graphics.arc (ArcType default is "pie")
love.graphics.circle (segments has a default)
love.graphics.ellipse (segments has a default)
love.graphics.newFont (size default is 12)
love.graphics.newImage (has default flags)
love.graphics.newImageFont (extraspacing default is 0)
love.graphics.rectangle (rx default is 0)
love.graphics.setBlendMode (BlendAlphaMode default is "alphamultiply")
love.keyboard.isDown (extra keys are optional)
love.math.random (min default is 1)
love.physics.newMotorJoint (collideConnected is false)
love.physics.newPrismaticJoint (reference angle is 0)
love.physics.newWeldJoint (reference angle is 0)
love.window.setFullscreen (fstype is "desktop" or last used)
Joystick:setVibration (duration is -1)

This can be corrected in the wiki as well, however sometimes it might not always be appropriate to remove the variant from the wiki because the wiki retains information about all LOVE versions and the variants may have been added in different versions. If there are any instances of this I think love-api should differ from the wiki and remove them anyway because love-api only contains information for the version which it targets.

There is also another concept which the wiki doesn't currently use which is that an argument can be left out, i.e. be "none". I'm not suggesting we do anything about this necessarily, I just thought it was interesting:

love.image.newImageData (data can be none)
love.graphics.newMesh (vertexformat can be none)
love.joystick.saveGamepadMappings (file can be none)

If anyone is interested, here is a script which prints out functions which have more than one variant that I used to find the functions above:

api = require('love-api.love_api')

function printFunctions(functions, parent)
  for _, function_ in ipairs(functions) do
    if function_.variants and #function_.variants > 1 then
      for _, variant in ipairs(function_.variants) do
        local output = ''
        for returnIndex, return_ in ipairs(variant.returns or {}) do
          output = output..return_.name
          if returnIndex ~= #variant.returns then
            output = output..','
          end
          output = output..' '
        end
        if variant.returns then
          output = output..'= '
        end
        output = output..parent..function_.name..'('
        for argumentIndex, argument in ipairs(variant.arguments or {}) do
          output = output..argument.name
          if argument.default then
            output = output..' ['..argument.default..']'
          end
          if argumentIndex ~= #variant.arguments then
            output = output..', '
          end
        end
        output = output..')'
        print(output)
      end
    end
  end
end

printFunctions(api.functions, 'love.')

for _, module_ in ipairs(api.modules) do
  printFunctions(module_.functions, 'love.'..module_.name..'.')
  for _, type_ in ipairs(module_.types or {}) do
    if type_.functions then
      printFunctions(type_.functions, type_.name..':')
    end
  end
end

And the output is:

source = love.audio.newSource(filename, type ["stream"])
source = love.audio.newSource(file, type ["stream"])
source = love.audio.newSource(decoder, type ["stream"])
source = love.audio.newSource(soundData)
source = love.audio.newSource(fileData)
love.audio.pause()
love.audio.pause(source)
love.audio.resume()
love.audio.resume(source)
love.audio.rewind()
love.audio.rewind(source)
love.audio.stop()
love.audio.stop(source)
love.event.quit()
love.event.quit(exitstatus [0])
love.event.quit("restart")
success = love.filesystem.mount(archive, mountpoint)
success = love.filesystem.mount(archive, mountpoint, appendToPath [false])
data = love.filesystem.newFileData(contents, name, decoder ["file"])
data, err = love.filesystem.newFileData(filepath)
success, message = love.filesystem.write(name, data, size [all])
success, message = love.filesystem.write(name, data, size [all])
love.graphics.arc(drawmode, x, y, radius, angle1, angle2, segments [10])
love.graphics.arc(drawmode, arctype, x, y, radius, angle1, angle2, segments [10])
love.graphics.circle(mode, x, y, radius)
love.graphics.circle(mode, x, y, radius, segments)
love.graphics.clear()
love.graphics.clear(r, g, b, a [255])
love.graphics.clear(color, ...)
love.graphics.discard(discardcolor [true], discardstencil [true])
love.graphics.discard(discardcolors, discardstencil [true])
love.graphics.draw(drawable, x [0], y [0], r [0], sx [1], sy [sx], ox [0], oy [0], kx [0], ky [0])
love.graphics.draw(texture, quad, x [0], y [0], r [0], sx [1], sy [sx], ox [0], oy [0], kx [0], ky [0])
love.graphics.ellipse(mode, x, y, radiusx, radiusy)
love.graphics.ellipse(mode, x, y, radiusx, radiusy, segments)
love.graphics.intersectScissor(x, y, width, height)
love.graphics.intersectScissor()
love.graphics.line(x1, y1, x2, y2, ...)
love.graphics.line(points)
font = love.graphics.newFont(filename)
font = love.graphics.newFont(filename, size)
font = love.graphics.newFont(filename, imagefilename)
font = love.graphics.newFont(size)
mesh = love.graphics.newMesh(vertices, mode ["fan"], usage ["dynamic"])
mesh = love.graphics.newMesh(vertexcount, mode ["fan"], usage ["dynamic"])
mesh = love.graphics.newMesh(vertexformat, vertices, mode ["fan"], usage ["dynamic"])
mesh = love.graphics.newMesh(vertexformat, vertexcount, mode ["fan"], usage ["dynamic"])
image = love.graphics.newImage(filename)
image = love.graphics.newImage(imageData)
image = love.graphics.newImage(compressedImageData)
image = love.graphics.newImage(filename, flags)
font = love.graphics.newImageFont(filename, glyphs)
font = love.graphics.newImageFont(imageData, glyphs)
font = love.graphics.newImageFont(filename, glyphs, extraspacing [0])
shader = love.graphics.newShader(code)
shader = love.graphics.newShader(pixelcode, vertexcode)
video = love.graphics.newVideo(filename, loadaudio [nil])
video = love.graphics.newVideo(videostream, loadaudio [nil])
love.graphics.points(x, y, ...)
love.graphics.points(points)
love.graphics.points(points)
love.graphics.polygon(mode, ...)
love.graphics.polygon(mode, vertices)
love.graphics.print(text, x, y, r [0], sx [1], sy [sx], ox [0], oy [0], kx [0], ky [0])
love.graphics.print(coloredtext, x, y, angle [0], sx [1], sy [sx], ox [0], oy [0], kx [0], ky [0])
love.graphics.printf(text, x, y, limit, align ["left"], r [0], sx [1], sy [sx], ox [0], oy [0], kx [0], ky [0])
love.graphics.printf(coloredtext, x, y, wraplimit, align, angle [0], sx [1], sy [sx], ox [0], oy [0], kx [0], ky [0])
love.graphics.rectangle(mode, x, y, width, height)
love.graphics.rectangle(mode, x, y, width, height, rx, ry [rx], segments [nil])
love.graphics.setBackgroundColor(r, g, b, a [255])
love.graphics.setBackgroundColor(rgba)
love.graphics.setBlendMode(mode)
love.graphics.setBlendMode(mode, alphamode ["alphamultiply"])
love.graphics.setCanvas(canvas, ...)
love.graphics.setCanvas()
love.graphics.setCanvas(canvas1, canvas2, ...)
love.graphics.setColor(red, green, blue, alpha)
love.graphics.setColor(rgba)
love.graphics.setColorMask(red, green, blue, alpha)
love.graphics.setColorMask()
font = love.graphics.setNewFont(filename, size [12])
font = love.graphics.setNewFont(file, size [12])
font = love.graphics.setNewFont(data, size [12])
love.graphics.setShader()
love.graphics.setShader(shader)
love.graphics.setScissor(x, y, width, height)
love.graphics.setScissor()
love.graphics.setStencilTest(comparemode, comparevalue)
love.graphics.setStencilTest()
data = Canvas:newImageData()
data = Canvas:newImageData(x, y, width, height)
hasglyph = Font:hasGlyphs(character)
hasglyph = Font:hasGlyphs(codepoint)
attributecomponent, ... = Mesh:getVertex(index)
x, y, u, v, r, g, b, a = Mesh:getVertex(index)
Mesh:setDrawRange(min, max)
Mesh:setDrawRange()
Mesh:setTexture()
Mesh:setTexture(texture)
Mesh:setVertex(index, attributecomponent, ...)
Mesh:setVertex(index, vertex)
Mesh:setVertex(index, x, y, u, v, r [255], g [255], b [255], a [255])
Mesh:setVertex(index, vertex)
Mesh:setVertexMap(map)
Mesh:setVertexMap(vi1, vi2, vi3)
Mesh:setVertices(vertices)
Mesh:setVertices(vertices)
data = Image:getData()
data = Image:getData()
Image:refresh()
Image:refresh(x, y, width, height)
Image:setMipmapFilter(filtermode, sharpness [0])
Image:setMipmapFilter()
ParticleSystem:setQuads(quad1, quad2)
ParticleSystem:setQuads(quads)
Shader:send(name, number, ...)
Shader:send(name, vector, ...)
Shader:send(name, matrix, ...)
Shader:send(name, texture)
Shader:send(name, boolean, ...)
id = SpriteBatch:add(x, y, r [0], sx [1], sy [sx], ox [0], oy [0], kx [0], ky [0])
id = SpriteBatch:add(quad, x, y, r [0], sx [1], sy [sx], ox [0], oy [0], kx [0], ky [0])
SpriteBatch:set(id, x, y, r [0], sx [1], sy [sx], ox [0], oy [0], kx [0], ky [0])
SpriteBatch:set(id, quad, x, y, r [0], sx [1], sy [sx], ox [0], oy [0], kx [0], ky [0])
SpriteBatch:setColor(r, g, b, a [255])
SpriteBatch:setColor()
index = Text:add(textstring, x, y, angle [0], sx [1], sy [sx], ox [0], oy [0], kx [0], ky [0])
index = Text:add(coloredtext, x, y, angle [0], sx [1], sy [sx], ox [0], oy [0], kx [0], ky [0])
index = Text:addf(textstring, wraplimit, align, x, y, angle [0], sx [1], sy [sx], ox [0], oy [0], kx [0], ky [0])
index = Text:addf(coloredtext, wraplimit, align, x, y, angle [0], sx [1], sy [sx], ox [0], oy [0], kx [0], ky [0])
width, height = Text:getDimensions()
width, height = Text:getDimensions(index)
height = Text:getHeight()
height = Text:getHeight(index)
width = Text:getWidth()
width = Text:getWidth(index)
Text:set(textstring)
Text:set(coloredtext)
Text:set()
Text:setf(textstring, wraplimit, align ["left"])
Text:setf(coloredtext, wraplimit, align ["left"])
Text:setf()
compressed = love.image.isCompressed(filename)
compressed = love.image.isCompressed(fileData)
compressedImageData = love.image.newCompressedData(filename)
compressedImageData = love.image.newCompressedData(fileData)
imageData = love.image.newImageData(width, height)
imageData = love.image.newImageData(width, height, data)
imageData = love.image.newImageData(filename)
imageData = love.image.newImageData(filedata)
width, height = CompressedImageData:getDimensions()
width, height = CompressedImageData:getDimensions(level)
height = CompressedImageData:getHeight()
height = CompressedImageData:getHeight(level)
width = CompressedImageData:getWidth()
width = CompressedImageData:getWidth(level)
love.joystick.loadGamepadMappings(filename)
love.joystick.loadGamepadMappings(mappings)
mappings = love.joystick.saveGamepadMappings(filename)
mappings = love.joystick.saveGamepadMappings()
success = love.joystick.setGamepadMapping(guid, button, inputtype, inputindex, hatdirection)
success = love.joystick.setGamepadMapping(guid, axis, inputtype, inputindex, hatdirection)
inputtype, inputindex, hatdirection = Joystick:getGamepadMapping(axis)
inputtype, inputindex, hatdirection = Joystick:getGamepadMapping(button)
success = Joystick:setVibration(left, right)
success = Joystick:setVibration()
success = Joystick:setVibration(left, right, duration)
down = love.keyboard.isDown(key)
anyDown = love.keyboard.isDown(key, ...)
love.keyboard.setTextInput(enable)
love.keyboard.setTextInput(enable, x, y, w, h)
compressedData = love.math.compress(rawstring, format ["lz4"], level [-1])
compressedData = love.math.compress(data, format ["lz4"], level [-1])
rawstring = love.math.decompress(compressedData)
rawstring = love.math.decompress(compressedString, format)
rawstring = love.math.decompress(data, format)
lr, lg, lb = love.math.gammaToLinear(r, g, b)
lr, lg, lb = love.math.gammaToLinear(color)
lc = love.math.gammaToLinear(c)
convex = love.math.isConvex(vertices)
convex = love.math.isConvex(x1, y1, x2, y2, x3, y3, ...)
cr, cg, cb = love.math.linearToGamma(lr, lg, lb)
cr, cg, cb = love.math.linearToGamma(color)
c = love.math.linearToGamma(lc)
curve = love.math.newBezierCurve(vertices)
curve = love.math.newBezierCurve(x1, y1, x2, y2, x3, y3, ...)
rng = love.math.newRandomGenerator()
rng = love.math.newRandomGenerator(seed)
rng = love.math.newRandomGenerator(low, high)
value = love.math.noise(x)
value = love.math.noise(x, y)
value = love.math.noise(x, y, z)
value = love.math.noise(x, y, z, w)
number = love.math.random()
number = love.math.random(max)
number = love.math.random(min, max)
love.math.setRandomSeed(seed)
love.math.setRandomSeed(low, high)
triangles = love.math.triangulate(polygon)
triangles = love.math.triangulate(x1, y1, x2, y2, x3, y3, ...)
number = RandomGenerator:random()
number = RandomGenerator:random(max)
number = RandomGenerator:random(min, max)
RandomGenerator:setSeed(seed)
RandomGenerator:setSeed(low, high [0])
cursor = love.mouse.newCursor(imageData, hotx [0], hoty [0])
cursor = love.mouse.newCursor(filepath, hotx [0], hoty [0])
cursor = love.mouse.newCursor(fileData, hotx [0], hoty [0])
love.mouse.setCursor()
love.mouse.setCursor(cursor)
shape = love.physics.newChainShape(loop, x1, y1, x2, y2, ...)
shape = love.physics.newChainShape(loop, points)
shape = love.physics.newCircleShape(radius)
shape = love.physics.newCircleShape(x, y, radius)
joint = love.physics.newMotorJoint(body1, body2, correctionFactor [0.3])
joint = love.physics.newMotorJoint(body1, body2, correctionFactor [0.3], collideConnected [false])
shape = love.physics.newPolygonShape(x1, y1, x2, y2, ...)
shape = love.physics.newPolygonShape(vertices)
joint = love.physics.newPrismaticJoint(body1, body2, x, y, ax, ay, collideConnected [false])
joint = love.physics.newPrismaticJoint(body1, body2, x1, y1, x2, y2, ax, ay, collideConnected [false])
joint = love.physics.newPrismaticJoint(body1, body2, x1, y1, x2, y2, ax, ay, collideConnected [false], referenceAngle [0])
shape = love.physics.newRectangleShape(width, height)
shape = love.physics.newRectangleShape(x, y, width, height, angle [0])
joint = love.physics.newRevoluteJoint(body1, body2, x, y, collideConnected [false])
joint = love.physics.newRevoluteJoint(body1, body2, x1, y1, x2, y2, collideConnected [false], referenceAngle [0])
joint = love.physics.newWeldJoint(body1, body2, x, y, collideConnected [false])
joint = love.physics.newWeldJoint(body1, body2, x1, y1, x2, y2, collideConnected [false])
joint = love.physics.newWeldJoint(body1, body2, x1, y1, x2, y2, collideConnected [false], referenceAngle [0])
Body:applyForce(fx, fy)
Body:applyForce(fx, fy, x, y)
Body:applyLinearImpulse(ix, iy)
Body:applyLinearImpulse(ix, iy, x, y)
decoder = love.sound.newDecoder(file, buffer [2048])
decoder = love.sound.newDecoder(filename, buffer [2048])
soundData = love.sound.newSoundData(filename)
soundData = love.sound.newSoundData(file)
soundData = love.sound.newSoundData(data)
soundData = love.sound.newSoundData(samples, rate [44100], bits [16], channels [2])
thread = love.thread.newThread(filename)
thread = love.thread.newThread(fileData)
thread = love.thread.newThread(codestring)
Thread:start()
Thread:start(arg1, arg2, ...)
videostream = love.video.newVideoStream(filename)
videostream = love.video.newVideoStream(file)
value = love.window.fromPixels(pixelvalue)
x, y = love.window.fromPixels(px, py)
success = love.window.setFullscreen(fullscreen)
success = love.window.setFullscreen(fullscreen, fstype)
success = love.window.showMessageBox(title, message, type ["info"], attachtowindow [true])
pressedbutton = love.window.showMessageBox(title, message, buttonlist, type ["info"], attachtowindow [true])
pixelvalue = love.window.toPixels(value)
px, py = love.window.toPixels(x, y)

Making the reference work well offline

I think it would be good if the API reference worked well offline. There are two issues I can see:

1: The page uses an image. If the page is saved from a browser, the image will be saved with the HTML file in a folder. I think it would be better if there was just a single HTML page to download, and the image was embedded. My data-url-embedder could help with this.

2: If the page is saved from Chrome using "Save as..." the links on the page will link to the URLs on GitHub making them unusable, i.e. the link to "#callbacks" becomes "https://love2d-community.github.io/love-api/#callbacks". If the page is saved from right clicking on a link to it, or by finding the HTML file on GitHub, then the links are fine, but the menu is unusable because the image is missing. I can think of two solutions to this:

1: Have a download link on the page to itself, and embed the image.

2: Change the links using JavaScript by putting this code at end of the body:

<script>
var a = document.getElementsByTagName('a');
for (var i = 0; i < a.length; i++) {
    a[i].href = a[i].href.replace("https://love2d-community.github.io/love-api/", "");
}
</script>

Some ideas

I've had a few ideas about this project, and I thought I'd put them all in one issue instead of creating heaps of issues, all of which maybe no one else would think are good ideas. :P I'm sorry there's so much text here, feel free to not read it anyone.

Some of these ideas involve diverging from the wiki a bit, and the idea of this project currently is to stick to what is in the wiki, and I respect that so I might make my own "experimental" fork (and move out the code I've been temporarily storing in the "test" folder of the gh-pages branch), but I thought I'd share my ideas here anyway just in case any of them are useful.

Here are the ideas:

  • Have a "serializer" for the table, so the table can be changed in Lua code and then resaved into the same file structure. This could be useful for adding/changing fields or table structure. I've kind of already made this here, using LOVE so that creating directories is easy (maybe it's also easy in plain Lua too, I didn't try).
  • Have extra commas at the end of tables (i.e. "},"), it might look a bit weird but it could make copy and pasting and removing code in the table easier, and plus I think it makes the serializer code a little bit simpler.
  • Maybe it would be cool to have support for images (or maybe not). If there were images, there should also be a way to get the description without images, for text-only uses.
  • Also support for example code, maybe? (I actually don't think example code or images are necessarily appropriate for this API reference, because I think it would be more suitable for a different type of documentation; like how the function descriptions in the Lua reference manual don't have many code examples. But, maybe.)
  • Putting the "love" module in its own module folder like the other modules may or may not be useful.
  • When I first made the table my idea was to put the wiki information in a table in the simplest way possible, but what I should have done also is to provide easy ways of using it. I thought of adding some base code to the README for this purpose (#51), but now I think it would be more useful to post-process the table to make it easier to use so that code isn't necessary (the full table structure I have in mind and post-processing code can be found here):
    • Tables for functions, types, arguments etc. could have a "what" field with what that table is, i.e. 'function', 'type', etc.
    • There could be a list of all the tables with a "what" field, and other lists which contain just the functions, just the types, etc.
    • Each table could have references to its "context", i.e. a method could have references to its type, the module it's in, etc.
    • There could be other fields which would be useful, like a full name for a function (i.e. the name 'draw' and the full name 'love.graphics.draw'), the corresponding getter/setter of a function, and whatever else would be useful. There are things I haven't added yet which may or may not be useful, like a synopsis for variants and unique string IDs for each table.
  • This is an extremely minor and silly quibble, but I'm not sure about the repo name and the table name differing only by the hyphen/underscore, because it leads to it being required like 'love-api.love_api', which is so close to the same name twice, I think I tripped up on this one time using two underscores or something and got confused, so I would be inclined to want it to be either the same name twice.

These are the "diverging from the wiki" ideas:

  • Removing the "notes" field from KeyConstant enum. The "notes" field isn't used anywhere else, and the information can be merged in to the "description" field.
  • Global/object state can have an initial value, which isn't documented in the wiki, for example the initial color state is (255, 255, 255, 255). It might be useful to document this.
  • It might also be useful to document ways in the which the function can error or fail without error (i.e. the filesystem functions).
  • The wiki has mini description for functions which are used on the module/type pages, which I think could be useful especially for languages other than English where the function name by itself isn't self-explanatory. I wrote some code which grabbed this information from the wiki, but then I realized that it's basically a copy of the first line of the full description. So, perhaps "the first line of the description should work as the mini description" could be a thing.
  • Checking the consistency of the documentation. For example, the description of getters often start with both "Returns the" and "Gets the", and names of argument/returns sometimes use camelCase and sometimes use lowercase.
  • Removing references in descriptions to previous versions, i.e. 'In version 0.9.2 and older...'. I don't think this is useful information to keep around, because if one is using a previous version they can use a previous release of the LOVE-API table.
  • Combining variants which differ only by argument type (see this thread).

0.11.0 Update

Started a branch at https://github.com/love2d-community/love-api/tree/update_to_love0110

TODO:

  • love.data.decompress
  • love.filesystem.getCRequirePath
  • love.filesystem.setCRequirePath
  • Image:replacePixels
  • Channel:demand
  • Channel:supply
  • World:update
  • love.data.decode
  • love.data.encode
  • love.data
  • RecordingDevice
  • Texture:getMipmapCount
  • Texture
  • Texture:getTextureType
  • Texture:getDepth
  • Texture:getLayerCount
  • Texture:getFormat
  • Texture:isReadable
  • love.graphics.applyTransform
  • love.graphics.replaceTransform
  • love.graphics.getFrontFaceWinding‎
  • love.graphics.setFrontFaceWinding‎
  • love.data.hash
  • HashFunction
  • ContainerType
  • love.math.newTransform‎
  • PixelFormat
  • love.graphics.transformPoint
  • love.graphics.inverseTransformPoint
  • love.graphics.setMeshCullMode
  • love.graphics.getMeshCullMode
  • love.graphics.getDepthMode
  • love.graphics.setDepthMode
  • SpriteBatch:addLayer
  • SpriteBatch:set
  • SpriteBatch:setLayer
  • Body:isTouching
  • ParticleSystem:setEmissionArea‎
  • ParticleSystem:getEmissionArea‎
  • Texture:getPixelWidth‎
  • Canvas:newImageData
  • Texture:getPixelHeight‎
  • Texture:getPixelDimensions‎
  • Texture:getFormat
  • Texture:getFilter‎
  • Texture:setFilter‎
  • love.graphics.getPixelWidth‎
  • love.graphics.getPixelHeight
  • love.graphics.getPixelDimensions
  • Texture‎
  • CompressedImageFormat‎
  • TextureType
  • love.data.compress‎
  • love.data.decompress‎
  • Source:tell‎
  • Source:seek
  • Source:getDuration
  • love.physics.newRopeJoint‎
  • Transform:reset‎
  • Transform:clone
  • Transform:setTransformation
  • Transform:reset
  • Transform
  • Transform:transformPoint‎
  • Transform:inverseTransformPoint‎
  • Transform:translate
  • Transform:rotate
  • Transform:scale
  • Transform:shear
  • Transform:apply
  • Transform:getMatrix
  • Transform:setMatrix

Remove keyreleased variant

All callbacks should have a single variant, since all arguments will always be provided, it's the decision of the user to ignore them or not. This is the case for ALL callbacks but keyreleased.

This callback provides both a variant with a second argument which is the Scancode and a variant without.

My proposal is to remove the variant that has no Scancode which can be found in lines 775 to 783

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.