Skip to content

Commit

Permalink
API docs updates
Browse files Browse the repository at this point in the history
[CI BUILD]
  • Loading branch information
andybak committed Jul 2, 2023
1 parent f8a4ea0 commit 9fbdc50
Show file tree
Hide file tree
Showing 20 changed files with 514 additions and 107 deletions.
9 changes: 5 additions & 4 deletions Assets/Editor/LuaDocsGenerator.cs
Expand Up @@ -57,12 +57,13 @@ static void GenerateDocs()
{
Name = "Tool",
Methods = new List<LuaDocsMethod>(),
Description = "A class to interact with Scripted Tools",
Properties = new List<LuaDocsProperty>
{
new() {Name="startPosition", PropertyType = vectorProp},
new() {Name="endPosition", PropertyType = vectorProp},
new() {Name="vector", PropertyType = vectorProp},
new() {Name="rotation", PropertyType = rotationProp},
new() {Name="startPosition", PropertyType = vectorProp, Description = "The position of the tool when the trigger was pressed"},
new() {Name="endPosition", PropertyType = vectorProp, Description = "The position of the tool when the trigger was released"},
new() {Name="vector", PropertyType = vectorProp, Description = "The vector from startPosition to endPosition"},
new() {Name="rotation", PropertyType = rotationProp, Description = "The rotation from startPosition to endPosition"},
}
};
LuaDocsRegistration.ApiDocClasses.Add(toolApiDocClass);
Expand Down
171 changes: 126 additions & 45 deletions Assets/Resources/LuaModules/__autocomplete.lua
Expand Up @@ -1661,6 +1661,108 @@ function Svg:DrawPathString(svg, tr) end
---@param svg string
---@param tr Transform
function Svg:DrawDocument(svg, tr) end

---Properties for type Symmetry

---@type Transform
Symmetry.transform = nil

---@type Vector3
Symmetry.position = nil

---@type Rotation
Symmetry.rotation = nil

---@type Vector3
Symmetry.brushOffset = nil

---@type Vector3
Symmetry.wandOffset = nil

---@type Vector3
Symmetry.direction = nil


---Methods for type Symmetry


function Symmetry:Mirror() end


function Symmetry:DoubleMirror() end


function Symmetry:TwoHandeded() end


function Symmetry:SummonWidget() end

---@param xSpeed number
---@param ySpeed number
---@param zSpeed number
function Symmetry:Spin(xSpeed, ySpeed, zSpeed) end

---@param angle number
---@param minorRadius number
---@return number
function Symmetry:Ellipse(angle, minorRadius) end

---@param angle number
---@return number
function Symmetry:Square(angle) end

---@param angle number
---@param n number
---@param a number
---@param b number
---@return number
function Symmetry:Superellipse(angle, n, a, b) end

---@param angle number
---@param halfSideLength number
---@param cornerRadius number
---@return number
function Symmetry:Rsquare(angle, halfSideLength, cornerRadius) end

---@param angle number
---@param numSides number
---@param radius number
---@return number
function Symmetry:Polygon(angle, numSides, radius) end

---@param colors Color[]
function Symmetry:ClearColors(colors) end

---@param color Color
function Symmetry:AddColor(color) end

---@param colors Color[]
function Symmetry:SetColors(colors) end


---@return Color[]
function Symmetry:GetColors() end

---@param brush string
function Symmetry:AddBrush(brush) end

---@param brushes string[]
function Symmetry:ClearBrushes(brushes) end

---@param brushes string[]
function Symmetry:SetBrushes(brushes) end


---@return string[]
function Symmetry:GetBrushNames() end


---@return string[]
function Symmetry:GetBrushGuids() end

---@param path IPath
---@return Path
function Symmetry:PathToPolar(path) end
---Methods for type Timer

---@param fn function
Expand Down Expand Up @@ -1730,7 +1832,7 @@ function Transform:ScaleBy(scale) end
---@param rotation Rotation
---@param scale number
---@return Transform
function Transform:New(translation, rotation, scale) end
function Transform:NewTRS(translation, rotation, scale) end

---@param translation Vector3
---@return Transform
Expand All @@ -1741,10 +1843,6 @@ function Transform:New(translation) end
---@return Transform
function Transform:New(translation, scale) end

---@param scale number
---@return Transform
function Transform:New(scale) end

---@param x number
---@param y number
---@param z number
Expand Down Expand Up @@ -1817,19 +1915,17 @@ Vector2.zero = nil
---@return Vector2
function Vector2:New(x, y) end

---@param a Vector2
---@param b Vector2
---@param other Vector2
---@return number
function Vector2:Angle(a, b) end
function Vector2:Angle(other) end

---@param maxLength number
---@return Vector2
function Vector2:ClampMagnitude(maxLength) end

---@param a Vector2
---@param b Vector2
---@param other Vector2
---@return number
function Vector2:Distance(a, b) end
function Vector2:Distance(other) end

---@param a Vector2
---@param b Vector2
Expand Down Expand Up @@ -1858,25 +1954,22 @@ function Vector2:Max(a, b) end
---@return Vector2
function Vector2:Min(a, b) end

---@param current Vector2
---@param target Vector2
---@param maxDistanceDelta number
---@return Vector2
function Vector2:MoveTowards(current, target, maxDistanceDelta) end
function Vector2:MoveTowards(target, maxDistanceDelta) end

---@param a Vector2
---@param b Vector2
---@param normal Vector2
---@return Vector2
function Vector2:Reflect(a, b) end
function Vector2:Reflect(normal) end

---@param other Vector2
---@return Vector2
function Vector2:Scale(other) end

---@param other Vector2
---@param axis Vector2
---@return number
function Vector2:SignedAngle(other, axis) end
function Vector2:SignedAngle(other) end

---@param a Vector2
---@param b Vector2
Expand Down Expand Up @@ -2012,10 +2105,9 @@ Vector3.zero = nil
---@return Vector3
function Vector3:New(x, y, z) end

---@param a Vector3
---@param b Vector3
---@param other Vector3
---@return number
function Vector3:Angle(a, b) end
function Vector3:Angle(other) end

---@param maxLength number
---@return Vector3
Expand All @@ -2026,10 +2118,9 @@ function Vector3:ClampMagnitude(maxLength) end
---@return Vector3
function Vector3:Cross(a, b) end

---@param a Vector3
---@param b Vector3
---@param other Vector3
---@return number
function Vector3:Distance(a, b) end
function Vector3:Distance(other) end

---@param a Vector3
---@param b Vector3
Expand All @@ -2053,36 +2144,32 @@ function Vector3:Max(a, b) end
---@return Vector3
function Vector3:Min(a, b) end

---@param current Vector3
---@param target Vector3
---@param maxDistanceDelta number
---@return Vector3
function Vector3:MoveTowards(current, target, maxDistanceDelta) end
function Vector3:MoveTowards(target, maxDistanceDelta) end

---@param other Vector3
---@return Vector3
function Vector3:Project(other) end

---@param vector Vector3
---@param planeNormal Vector3
---@return Vector3
function Vector3:ProjectOnPlane(vector, planeNormal) end
function Vector3:ProjectOnPlane(planeNormal) end

---@param other Vector3
---@param normal Vector3
---@return Vector3
function Vector3:Reflect(other) end
function Vector3:Reflect(normal) end

---@param current Vector3
---@param target Vector3
---@param maxRadiansDelta number
---@param maxMagnitudeDelta number
---@return Vector3
function Vector3:RotateTowards(current, target, maxRadiansDelta, maxMagnitudeDelta) end
function Vector3:RotateTowards(target, maxRadiansDelta, maxMagnitudeDelta) end

---@param a Vector3
---@param b Vector3
---@param other Vector3
---@return Vector3
function Vector3:ScaleBy(a, b) end
function Vector3:ScaleBy(other) end

---@param other Vector3
---@param axis Vector3
Expand Down Expand Up @@ -2125,10 +2212,6 @@ function Vector3:Subtract(x, y, z) end
---@return Vector3
function Vector3:Multiply(value) end

---@param other Vector3
---@return Vector3
function Vector3:ScaleBy(other) end

---@param x number
---@param y number
---@param z number
Expand Down Expand Up @@ -2190,8 +2273,8 @@ Visualizer.duration = nil

---Methods for type Visualizer

---@param name string
function Visualizer:EnableScripting(name) end

function Visualizer:EnableScripting() end


function Visualizer:DisableScripting() end
Expand Down Expand Up @@ -2422,19 +2505,17 @@ function Waveform:PerlinNoise(time, frequency, duration, sampleRate, amplitude)
---@return number[]
function Waveform:WhiteNoise(duration, sampleRate, amplitude) end

---@param previous number
---@param duration number
---@param sampleRate number
---@param amplitude number
---@return number[]
function Waveform:BrownNoise(previous, duration, sampleRate, amplitude) end
function Waveform:BrownNoise(duration, sampleRate, amplitude) end

---@param previous number
---@param duration number
---@param sampleRate number
---@param amplitude number
---@return number[]
function Waveform:BlueNoise(previous, duration, sampleRate, amplitude) end
function Waveform:BlueNoise(duration, sampleRate, amplitude) end
---Methods for type WebRequest

---@param url string
Expand Down
4 changes: 2 additions & 2 deletions Assets/Scripts/API/Lua/Wrappers/CameraPathApiWrapper.cs
Expand Up @@ -406,8 +406,8 @@ public TrTransform Sample(float time, bool loop = true, bool pingpong = false)
[LuaDocsDescription("Simplifies the camera path")]
[LuaDocsExample("newPath = oldPath:Simplify(1.2, 1)")]
[LuaDocsParameter("tolerance", "The tolerance used for simplification")]
[LuaDocsParameter("smoothing", "The smoothing factor applied to the simplified camera path")]
[LuaDocsReturnValueAttribute("A new CameraPathApiWrapper instance for the simplified camera path")]
[LuaDocsParameter("smoothing", "The smoothing factor used for simplification")]
[LuaDocsReturnValue("A new simplified Camera Path")]
public CameraPathApiWrapper Simplify(float tolerance, float smoothing)
{
List<Vector3> inputPoints = _CameraPathWidget.Path.PositionKnots.Select(knot => knot.transform.position).ToList();
Expand Down
17 changes: 10 additions & 7 deletions Assets/Scripts/API/Lua/Wrappers/CameraPathListApiWrapper.cs
Expand Up @@ -10,7 +10,7 @@ public class CameraPathListApiWrapper
[MoonSharpHidden]
public List<CameraPathWidget> _CameraPaths;

[LuaDocsDescription("Returns the last CameraPathApiWrapper in the list")]
[LuaDocsDescription("Returns the last Camera Path")]
public CameraPathApiWrapper last => (_CameraPaths == null || _CameraPaths.Count == 0) ? null : new CameraPathApiWrapper(_CameraPaths[^1]);

public CameraPathListApiWrapper()
Expand All @@ -23,27 +23,30 @@ public CameraPathListApiWrapper(List<CameraPathWidget> cameraPaths)
_CameraPaths = cameraPaths;
}

[LuaDocsDescription("Gets the CameraPathApiWrapper at the specified index")]
[LuaDocsDescription("Gets a Camera Path by it's index")]
public CameraPathApiWrapper this[int index] => new CameraPathApiWrapper(_CameraPaths[index]);

[LuaDocsDescription("Gets the number of CameraPathWidgets in the list")]
[LuaDocsDescription("The number of Camera Paths")]
public int count => _CameraPaths?.Count ?? 0;


[LuaDocsDescription("Gets or sets the active CameraPathWidget")]
[LuaDocsDescription("Gets or sets the active Camera Path")]
public CameraPathWidget active
{
get => WidgetManager.m_Instance.GetCurrentCameraPath().WidgetScript;
set => WidgetManager.m_Instance.SetCurrentCameraPath(value);
}

[LuaDocsDescription("Shows all CameraPaths in the list")]
[LuaDocsDescription("Makes all Camera Paths visible")]
[LuaDocsExample("Sketch.cameraPaths:ShowAll()")]
public void ShowAll() => WidgetManager.m_Instance.CameraPathsVisible = true;

[LuaDocsDescription("Hides all CameraPaths in the list")]
[LuaDocsDescription("Hides all Camera Paths")]
[LuaDocsExample("Sketch:cameraPaths:HideAll()")]
public void HideAll() => WidgetManager.m_Instance.CameraPathsVisible = false;

[LuaDocsDescription("Previews the active path")]
[LuaDocsDescription("Sets whether to preview the active path or not")]
[LuaDocsExample("Sketch.cameraPaths:PreviewActivePath(true)")]
[LuaDocsParameter("active", "A boolean value indicating whether to preview the active path or not")]
public void PreviewActivePath(bool active) => WidgetManager.m_Instance.FollowingPath = active;
}
Expand Down
10 changes: 10 additions & 0 deletions Assets/Scripts/API/Lua/Wrappers/EnvironmentListApiWrapper.cs
Expand Up @@ -9,7 +9,11 @@ public class EnvironmentListApiWrapper
{
[MoonSharpHidden]
public List<Environment> _Environments;

[LuaDocsDescription("Returns the last environment")]
public EnvironmentApiWrapper last => new EnvironmentApiWrapper(_Environments[^1]);

[LuaDocsDescription("Returns the current environment")]
public EnvironmentApiWrapper current
{
get
Expand All @@ -32,9 +36,15 @@ public EnvironmentListApiWrapper(List<Environment> environments)
_Environments = environments;
}

[LuaDocsDescription("Returns the environment at the given index")]
public EnvironmentApiWrapper this[int index] => new EnvironmentApiWrapper(_Environments[index]);

[LuaDocsDescription("The number of available environments")]
public int count => _Environments?.Count ?? 0;

[LuaDocsDescription("Returns the environment with the given name, or nil if no environment has that name")]
[LuaDocsExample(@"env = Sketch.environments:ByName(""Pistachio"")")]
[LuaDocsParameter("name", "The name of the environment to get")]
public EnvironmentApiWrapper ByName(string name) => new EnvironmentApiWrapper(_Environments.FirstOrDefault(e => e.Description == name));
}

Expand Down

0 comments on commit 9fbdc50

Please sign in to comment.