瀏覽代碼

Add more checks for missing links; File watching;

bjorn 9 月之前
父節點
當前提交
8b31575241

+ 60 - 1
api/init.lua

@@ -548,6 +548,29 @@ return {
         }
       }
     },
+    {
+      name = "mount",
+      tag = "callbacks",
+      summary = "Called when the headset is put on or taken off.",
+      description = "The `lovr.mount` callback is called when the headset is put on or taken off.",
+      key = "lovr.mount",
+      module = "lovr",
+      related = {
+        "lovr.headset.isMounted"
+      },
+      variants = {
+        {
+          arguments = {
+            {
+              name = "mounted",
+              type = "boolean",
+              description = "Whether the headset is mounted."
+            }
+          },
+          returns = {}
+        }
+      }
+    },
     {
       name = "mousemoved",
       tag = "callbacks",
@@ -1309,6 +1332,7 @@ return {
       functions = {
         {
           name = "getAbsorption",
+          tag = "listener",
           summary = "Get the absorption coefficients.",
           description = "Returns the global air absorption coefficients for the medium.  This affects Sources that have the `absorption` effect enabled, causing audio volume to drop off with distance as it is absorbed by the medium it's traveling through (air, water, etc.).  The difference between absorption and the attenuation effect is that absorption is more subtle and is frequency-dependent, so higher-frequency bands can get absorbed more quickly than lower ones. This can be used to apply \"underwater\" effects and stuff.",
           key = "lovr.audio.getAbsorption",
@@ -1816,6 +1840,7 @@ return {
         },
         {
           name = "setAbsorption",
+          tag = "listener",
           summary = "Set the absorption coefficients.",
           description = "Sets the global air absorption coefficients for the medium.  This affects Sources that have the `absorption` effect enabled, causing audio volume to drop off with distance as it is absorbed by the medium it's traveling through (air, water, etc.).  The difference between absorption and the attenuation effect is that absorption is more subtle and is frequency-dependent, so higher-frequency bands can get absorbed more quickly than lower ones.  This can be used to apply \"underwater\" effects and stuff.",
           key = "lovr.audio.setAbsorption",
@@ -9501,6 +9526,7 @@ return {
         },
         {
           name = "newFile",
+          tag = "filesystem-files",
           summary = "Open a file, returning a `File` object.",
           description = "Opens a file, returning a `File` object that can be used to read/write the file contents.\n\nNormally you can just use `lovr.filesystem.read`, `lovr.filesystem.write`, etc.  However, those methods open and close the file each time they are called.  So, when performing multiple operations on a file, creating a File object and keeping it open will have less overhead.",
           key = "lovr.filesystem.newFile",
@@ -9687,6 +9713,7 @@ return {
         },
         {
           name = "unwatch",
+          tag = "filesystem-files",
           summary = "Stop watching files.",
           description = "Stops watching files.",
           key = "lovr.filesystem.unwatch",
@@ -9704,6 +9731,7 @@ return {
         },
         {
           name = "watch",
+          tag = "filesystem-files",
           summary = "Start watching the filesystem for changes.",
           description = "Starts watching the filesystem for changes.  File events will be reported by the `lovr.filechanged` callback.\n\nCurrently, on PC, only files in the source directory will be watched.  On Android, files in the save directory will be watched instead, so that pushing new files with `adb` can be detected.",
           key = "lovr.filesystem.watch",
@@ -19328,6 +19356,7 @@ return {
             },
             {
               name = "getLabel",
+              tag = "pass-misc",
               summary = "Get the debug label of the Pass.",
               description = "Returns the debug label of the Pass, which will show up when the Pass is printed and in some graphics debugging tools.  This is set when the Pass is created, and can't be changed afterwards.",
               key = "Pass:getLabel",
@@ -23908,6 +23937,7 @@ return {
             },
             {
               name = "getLabel",
+              tag = "texture-metadata",
               summary = "Get the debug label of the Texture.",
               description = "Returns the debug label of the Texture, which will show up when the Texture is printed and in some graphics debugging tools.  This is set when the Texture is created, and can't be changed afterwards.",
               key = "Texture:getLabel",
@@ -26030,6 +26060,31 @@ return {
             }
           }
         },
+        {
+          name = "isMounted",
+          tag = "headset-misc",
+          summary = "Check if the headset is \"mounted\" (worn on a head).",
+          description = "Returns whether the headset is mounted.  Usually this uses a proximity sensor on the headset to detect whether someone is wearing the headset.",
+          key = "lovr.headset.isMounted",
+          module = "lovr.headset",
+          related = {
+            "lovr.mount",
+            "lovr.headset.isFocused",
+            "lovr.headset.isVisible"
+          },
+          variants = {
+            {
+              arguments = {},
+              returns = {
+                {
+                  name = "mounted",
+                  type = "boolean",
+                  description = "Whether the headset is mounted."
+                }
+              }
+            }
+          }
+        },
         {
           name = "isSeated",
           tag = "playArea",
@@ -26407,6 +26462,7 @@ return {
         },
         {
           name = "start",
+          tag = "headset-misc",
           summary = "Starts the headset session.",
           description = "Starts the headset session.  This must be called after the graphics module is initialized, and can only be called once.  Normally it is called automatically by `boot.lua`.",
           key = "lovr.headset.start",
@@ -27113,7 +27169,7 @@ return {
         {
           name = "Layers",
           tag = "layers",
-          description = "TODO"
+          description = "Layers are 2D textured quads that can be placed in 3D space.  They are higher quality than rendering regular planes in the 3D scene."
         },
         {
           name = "Miscellaneous",
@@ -37280,6 +37336,8 @@ return {
                 "Collider:setPose",
                 "Collider:getLocalPoint",
                 "Collider:getWorldPoint",
+                "Collider:getLocalVector",
+                "Collider:getWorldVector",
                 "Collider:getAABB",
                 "Collider:getLinearVelocity",
                 "Collider:setLinearVelocity",
@@ -43568,6 +43626,7 @@ return {
               name = "Basics",
               links = {
                 "World:update",
+                "World:interpolate",
                 "World:getGravity",
                 "World:setGravity",
                 "World:getCallbacks",

+ 1 - 0
api/lovr/audio/getAbsorption.lua

@@ -1,4 +1,5 @@
 return {
+  tag = 'listener',
   summary = 'Get the absorption coefficients.',
   description = [[
     Returns the global air absorption coefficients for the medium.  This affects Sources that have

+ 1 - 0
api/lovr/audio/setAbsorption.lua

@@ -1,4 +1,5 @@
 return {
+  tag = 'listener',
   summary = 'Set the absorption coefficients.',
   description = [[
     Sets the global air absorption coefficients for the medium.  This affects Sources that have the

+ 21 - 0
api/lovr/callbacks/mount.lua

@@ -0,0 +1,21 @@
+return {
+  tag = 'callbacks',
+  summary = 'Called when the headset is put on or taken off.',
+  description = 'The `lovr.mount` callback is called when the headset is put on or taken off.',
+  arguments = {
+    mounted = {
+      type = 'boolean',
+      description = 'Whether the headset is mounted.'
+    }
+  },
+  returns = {},
+  variants = {
+    {
+      arguments = { 'mounted' },
+      returns = {}
+    }
+  },
+  related = {
+    'lovr.headset.isMounted'
+  }
+}

+ 1 - 0
api/lovr/filesystem/newFile.lua

@@ -1,4 +1,5 @@
 return {
+  tag = 'filesystem-files',
   summary = 'Open a file, returning a `File` object.',
   description = [[
     Opens a file, returning a `File` object that can be used to read/write the file contents.

+ 1 - 0
api/lovr/filesystem/unwatch.lua

@@ -1,4 +1,5 @@
 return {
+  tag = 'filesystem-files',
   summary = 'Stop watching files.',
   description = 'Stops watching files.',
   arguments = {},

+ 1 - 0
api/lovr/filesystem/watch.lua

@@ -1,4 +1,5 @@
 return {
+  tag = 'filesystem-files',
   summary = 'Start watching the filesystem for changes.',
   description = [[
     Starts watching the filesystem for changes.  File events will be reported by the

+ 1 - 0
api/lovr/graphics/Pass/getLabel.lua

@@ -1,4 +1,5 @@
 return {
+  tag = 'pass-misc',
   summary = 'Get the debug label of the Pass.',
   description = [[
     Returns the debug label of the Pass, which will show up when the Pass is printed and in some

+ 1 - 0
api/lovr/graphics/Texture/getLabel.lua

@@ -1,4 +1,5 @@
 return {
+  tag = 'texture-metadata',
   summary = 'Get the debug label of the Texture.',
   description = [[
     Returns the debug label of the Texture, which will show up when the Texture is printed and in

+ 4 - 1
api/lovr/headset/init.lua

@@ -36,7 +36,10 @@ return {
     {
       name = 'Layers',
       tag = 'layers',
-      description = 'TODO'
+      description = [[
+        Layers are 2D textured quads that can be placed in 3D space.  They are higher quality than
+        rendering regular planes in the 3D scene.
+      ]]
     },
     {
       name = 'Miscellaneous',

+ 26 - 0
api/lovr/headset/isMounted.lua

@@ -0,0 +1,26 @@
+return {
+  tag = 'headset-misc',
+  summary = 'Check if the headset is "mounted" (worn on a head).',
+  description = [[
+    Returns whether the headset is mounted.  Usually this uses a proximity sensor on the headset to
+    detect whether someone is wearing the headset.
+  ]],
+  arguments = {},
+  returns = {
+    mounted = {
+      type = 'boolean',
+      description = 'Whether the headset is mounted.'
+    }
+  },
+  variants = {
+    {
+      arguments = {},
+      returns = { 'mounted' }
+    }
+  },
+  related = {
+    'lovr.mount',
+    'lovr.headset.isFocused',
+    'lovr.headset.isVisible'
+  }
+}

+ 1 - 0
api/lovr/headset/start.lua

@@ -1,4 +1,5 @@
 return {
+  tag = 'headset-misc',
   summary = 'Starts the headset session.',
   description = [[
     Starts the headset session.  This must be called after the graphics module is initialized, and

+ 2 - 0
api/lovr/physics/Collider/init.lua

@@ -23,6 +23,8 @@ return {
         'Collider:setPose',
         'Collider:getLocalPoint',
         'Collider:getWorldPoint',
+        'Collider:getLocalVector',
+        'Collider:getWorldVector',
         'Collider:getAABB',
         'Collider:getLinearVelocity',
         'Collider:setLinearVelocity',

+ 1 - 0
api/lovr/physics/World/init.lua

@@ -11,6 +11,7 @@ return {
       name = 'Basics',
       links = {
         'World:update',
+        'World:interpolate',
         'World:getGravity',
         'World:setGravity',
         'World:getCallbacks',

+ 41 - 0
api/main.lua

@@ -347,6 +347,26 @@ local function validateObject(object)
 
   for _, method in ipairs(object.methods or {}) do
     validateFunction(method)
+
+    if object.sections and not method.deprecated then
+      local found = false
+
+      for _, section in ipairs(object.sections) do
+        if section.tag and section.tag == method.tag then
+          found = true
+          break
+        else
+          for _, link in ipairs(section.links or {}) do
+            if link == method.key then
+              found = true
+              break
+            end
+          end
+        end
+      end
+
+      warnIf(not found, '%s is missing a parent link/tag', method.key)
+    end
   end
 
   local metatable = debug.getregistry()[object.name]
@@ -392,9 +412,30 @@ local function validateModule(module)
 
   for _, fn in ipairs(module.functions) do
     validateFunction(fn)
+
     if dev and not fn.deprecated then
       warnIf(t and not t[fn.name], '%s has docs for unknown function %s', module.key, fn.name)
     end
+
+    if module.sections and not fn.deprecated then
+      local found = false
+
+      for _, section in ipairs(module.sections) do
+        if section.tag and section.tag == fn.tag then
+          found = true
+          break
+        else
+          for _, link in ipairs(section.links or {}) do
+            if link == fn.key then
+              found = true
+              break
+            end
+          end
+        end
+      end
+
+      warnIf(not found, '%s is missing a parent link/tag', fn.key)
+    end
   end
 
   for _, fn in ipairs(module.enums) do

+ 2 - 0
guides/Getting_Started_(Quest).md

@@ -54,5 +54,7 @@ Tips
 <pre><code>adb shell am start -S org.lovr.app/org.lovr.app.Activity
 </code></pre>
 
+- You can call `lovr.filesystem.watch` to start watching files in the `sdcard` folder, automatically
+  restarting when new files are pushed.
 - If you need to use `print` in Lua for debug messages, you can see those in a terminal by running
   `adb logcat -s LOVR`.