Skip to content

Commit

Permalink
Add templates to docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed Oct 19, 2023
1 parent f7f2829 commit aba8e29
Show file tree
Hide file tree
Showing 5 changed files with 214 additions and 13 deletions.
14 changes: 5 additions & 9 deletions module/lua_juce_core/maths/Range.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
namespace lua_juce {

template<typename T>
auto juce_RangeImpl(sol::table& state, char const* name) -> void
{
// clang-format off
auto range = state.new_usertype<juce::Range<T>>(name,
sol::constructors<juce::Range<T>(), juce::Range<T>(T, T)>(),
"start",
sol::property(&juce::Range<T>::getStart, &juce::Range<T>::setStart),
"end",
sol::property(&juce::Range<T>::getEnd, &juce::Range<T>::setEnd)
);
// clang-format on
auto range = state.new_usertype<juce::Range<T>>(name, sol::constructors<juce::Range<T>(), juce::Range<T>(T, T)>());

range["getStart"] = LUA_JUCE_C_CALL(&juce::Range<T>::getStart);
range["getEnd"] = LUA_JUCE_C_CALL(&juce::Range<T>::getEnd);
}

auto juce_Range(sol::table& state) -> void
Expand Down
168 changes: 168 additions & 0 deletions tool/jml-docgen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@
- [MemoryBlock](#MemoryBlock)
- [MemoryInputStream](#MemoryInputStream)
- [MemoryOutputStream](#MemoryOutputStream)
- [NormalisableRange](#NormalisableRange)
- [OutputStream](#OutputStream)
- [Random](#Random)
- [Range](#Range)
- [RelativeTime](#RelativeTime)
- [Result](#Result)
- [StatisticsAccumulator](#StatisticsAccumulator)
- [String](#String)
- [StringArray](#StringArray)
- [Time](#Time)
Expand All @@ -39,7 +42,10 @@
- [Font](#Font)
- [Graphics](#Graphics)
- [Image](#Image)
- [Line](#Line)
- [Path](#Path)
- [Point](#Point)
- [Rectangle](#Rectangle)
- [juce_gui_basics](#juce_gui_basics)
- [ArrowButton](#ArrowButton)
- [Button](#Button)
Expand Down Expand Up @@ -528,6 +534,23 @@ juce.MemoryOutputStream.toString(...)
juce.MemoryOutputStream.toUTF8(...)
```

## NormalisableRange

```lua
juce.NormalisableRange.__eq(...)
juce.NormalisableRange.convertFrom0to1(...)
juce.NormalisableRange.convertTo0to1(...)
juce.NormalisableRange.end(...)
juce.NormalisableRange.getRange(...)
juce.NormalisableRange.interval(...)
juce.NormalisableRange.new(...)
juce.NormalisableRange.setSkewForCentre(...)
juce.NormalisableRange.skew(...)
juce.NormalisableRange.snapToLegalValue(...)
juce.NormalisableRange.start(...)
juce.NormalisableRange.symmetricSkew(...)
```

## OutputStream

```lua
Expand Down Expand Up @@ -573,6 +596,15 @@ juce.Random.nextInt64(...)
juce.Random.setSeed(...)
```

## Range

```lua
juce.Range.__eq(...)
juce.Range.getEnd(...)
juce.Range.getStart(...)
juce.Range.new(...)
```

## RelativeTime

```lua
Expand Down Expand Up @@ -607,6 +639,19 @@ juce.Result.ok(...)
juce.Result.wasOk(...)
```

## StatisticsAccumulator

```lua
juce.StatisticsAccumulator.__eq(...)
juce.StatisticsAccumulator.getAverage(...)
juce.StatisticsAccumulator.getCount(...)
juce.StatisticsAccumulator.getMaxValue(...)
juce.StatisticsAccumulator.getMinValue(...)
juce.StatisticsAccumulator.getStandardDeviation(...)
juce.StatisticsAccumulator.getVariance(...)
juce.StatisticsAccumulator.new(...)
```

## String

```lua
Expand Down Expand Up @@ -1086,6 +1131,13 @@ juce.Image.rescaled(...)
juce.Image.setPixelAt(...)
```

## Line

```lua
juce.Line.__eq(...)
juce.Line.new(...)
```

## Path

```lua
Expand Down Expand Up @@ -1126,6 +1178,122 @@ juce.Path.toString(...)
juce.Path.writePathToStream(...)
```

## Point

```lua
juce.Point.__eq(...)
juce.Point.__tostring(...)
juce.Point.addXY(...)
juce.Point.applyTransform(...)
juce.Point.getAngleToPoint(...)
juce.Point.getDistanceFrom(...)
juce.Point.getDistanceFromOrigin(...)
juce.Point.getDistanceSquaredFrom(...)
juce.Point.getDistanceSquaredFromOrigin(...)
juce.Point.getX(...)
juce.Point.getY(...)
juce.Point.isFinite(...)
juce.Point.isOrigin(...)
juce.Point.new(...)
juce.Point.roundToInt(...)
juce.Point.setX(...)
juce.Point.setXY(...)
juce.Point.setY(...)
juce.Point.toDouble(...)
juce.Point.toFloat(...)
juce.Point.toInt(...)
juce.Point.toString(...)
juce.Point.transformedBy(...)
juce.Point.translated(...)
juce.Point.withX(...)
juce.Point.withY(...)
```

## Rectangle

```lua
juce.Rectangle.__eq(...)
juce.Rectangle.__tostring(...)
juce.Rectangle.constrainedWithin(...)
juce.Rectangle.enlargeIfAdjacent(...)
juce.Rectangle.expand(...)
juce.Rectangle.findAreaContainingPoints(...)
juce.Rectangle.fromString(...)
juce.Rectangle.getAspectRatio(...)
juce.Rectangle.getBottom(...)
juce.Rectangle.getBottomLeft(...)
juce.Rectangle.getBottomRight(...)
juce.Rectangle.getCentre(...)
juce.Rectangle.getCentreX(...)
juce.Rectangle.getCentreY(...)
juce.Rectangle.getConstrainedPoint(...)
juce.Rectangle.getHeight(...)
juce.Rectangle.getHorizontalRange(...)
juce.Rectangle.getIntersection(...)
juce.Rectangle.getPosition(...)
juce.Rectangle.getRelativePoint(...)
juce.Rectangle.getRight(...)
juce.Rectangle.getSmallestIntegerContainer(...)
juce.Rectangle.getTopLeft(...)
juce.Rectangle.getTopRight(...)
juce.Rectangle.getUnion(...)
juce.Rectangle.getVerticalRange(...)
juce.Rectangle.getWidth(...)
juce.Rectangle.getX(...)
juce.Rectangle.getY(...)
juce.Rectangle.isEmpty(...)
juce.Rectangle.isFinite(...)
juce.Rectangle.leftTopRightBottom(...)
juce.Rectangle.new(...)
juce.Rectangle.proportionOfHeight(...)
juce.Rectangle.proportionOfWidth(...)
juce.Rectangle.reduce(...)
juce.Rectangle.reduceIfPartlyContainedIn(...)
juce.Rectangle.reduced(...)
juce.Rectangle.removeFromBottom(...)
juce.Rectangle.removeFromLeft(...)
juce.Rectangle.removeFromRight(...)
juce.Rectangle.removeFromTop(...)
juce.Rectangle.setBottom(...)
juce.Rectangle.setBounds(...)
juce.Rectangle.setHeight(...)
juce.Rectangle.setHorizontalRange(...)
juce.Rectangle.setLeft(...)
juce.Rectangle.setRight(...)
juce.Rectangle.setSize(...)
juce.Rectangle.setTop(...)
juce.Rectangle.setVerticalRange(...)
juce.Rectangle.setWidth(...)
juce.Rectangle.setX(...)
juce.Rectangle.setY(...)
juce.Rectangle.toDouble(...)
juce.Rectangle.toFloat(...)
juce.Rectangle.toNearestInt(...)
juce.Rectangle.toNearestIntEdges(...)
juce.Rectangle.toString(...)
juce.Rectangle.transformedBy(...)
juce.Rectangle.translate(...)
juce.Rectangle.translated(...)
juce.Rectangle.withBottom(...)
juce.Rectangle.withBottomY(...)
juce.Rectangle.withCentre(...)
juce.Rectangle.withHeight(...)
juce.Rectangle.withLeft(...)
juce.Rectangle.withRight(...)
juce.Rectangle.withRightX(...)
juce.Rectangle.withSize(...)
juce.Rectangle.withSizeKeepingCentre(...)
juce.Rectangle.withTop(...)
juce.Rectangle.withTrimmedBottom(...)
juce.Rectangle.withTrimmedLeft(...)
juce.Rectangle.withTrimmedRight(...)
juce.Rectangle.withTrimmedTop(...)
juce.Rectangle.withWidth(...)
juce.Rectangle.withX(...)
juce.Rectangle.withY(...)
juce.Rectangle.withZeroOrigin(...)
```

## juce_gui_basics

## ArrowButton
Expand Down
3 changes: 3 additions & 0 deletions tool/jml-docgen/doxygen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ end
local function select_xml_file(entity)
entity = entity:gsub('_', '__')
entity = entity:gsub('%.', '_1_1')
entity = entity:gsub('<int>', '')
entity = entity:gsub('<float>', '')
entity = entity:gsub('<double>', '')
local juce_root = "~/Developer/tobiashienzsch/JUCE"
local xml = string.format("%s/docs/doxygen/xml", juce_root)

Expand Down
38 changes: 34 additions & 4 deletions tool/jml-docgen/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ end

local function write_usertype_as_lua_stubs(dir, modules)
local docs, _ = sol2.parse_juce_types(modules)

for module_name, juce_module in pairs(docs) do
for class_name, class in pairs(juce_module[2]) do
local doxygen_spec = doxygen.parse_xml(class_name)
Expand All @@ -43,7 +44,7 @@ local function write_usertype_as_lua_stubs(dir, modules)
end

-- Create lua file
local path = string.format("%s/%s.lua", dir, class_name, ".lua")
local path = string.format("%s/%s.lua", dir, class_name)
local file = io.open(path, "w")
if file == nil then
print("error:", class_name)
Expand Down Expand Up @@ -139,6 +140,31 @@ local function write_usertype_as_lua_stubs(dir, modules)
file:close()
end
end

-- --- Represents a colour, also including a transparency value.
-- -- @module juce

-- --- Constant colors
-- -- @table Colours
-- -- @field black HTML black
-- Colours = {
-- black = ""
-- }

local colours = io.open(string.format("%s/Colours.lua", dir), "w")
colours:write("--- JUCE framework\n")
colours:write("-- @module juce\n\n")
colours:write("--- Contains a set of predefined named colours\n")
colours:write("-- @table Colours\n")
for k, v in pairs(juce.Colours) do
colours:write(string.format("-- @field %s 0x%s\n", k, v))
end
colours:write("Colours = {\n")
for k, v in pairs(juce.Colours) do
colours:write(string.format("\t%-20s = 0x%s\n", k, v))
end
colours:write("}\n\n")

end

local function write_usertype_as_markdown(file, modules)
Expand Down Expand Up @@ -182,17 +208,18 @@ end

local classes = {
juce_core = {
-- juce.Array_double.new(),
juce.BigInteger.new(),
juce.File.new(),
juce.abstract.InputStream,
juce.abstract.MemoryInputStream,
juce.IPAddress.new(),
juce.MemoryBlock.new(),
-- juce.NormalisableRange_double.new(),
juce.NormalisableRange_double.new(),
juce.Random.new(),
-- juce.Range_double.new(0.0, 1.0),
juce.Range_double.new(0.0, 1.0),
juce.Result.ok(),
-- juce.StatisticsAccumulatorDouble.new(),
juce.StatisticsAccumulator.new(),
juce.abstract.OutputStream,
juce.abstract.MemoryOutputStream,
juce.String.new(),
Expand Down Expand Up @@ -220,7 +247,10 @@ local classes = {
juce.Font.new(12.0),
juce.Image.new(),
juce.Graphics.new(juce.Image.new()),
juce.Line_double.new(),
juce.Point_double.new(),
juce.Path.new(),
juce.Rectangle_double.new(),
},
juce_gui_basics = {
juce.abstract.Button,
Expand Down
4 changes: 4 additions & 0 deletions tool/jml-docgen/sol2.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ local function parse_usertype(obj)
doc.name = doc.name:gsub("*", "")
doc.name = doc.name:gsub("&", "")
doc.name = doc.name:gsub("::", ".")
doc.name = doc.name:gsub('<int>', '')
doc.name = doc.name:gsub('<float>', '')
doc.name = doc.name:gsub('<double>', '')
assert(doc.name ~= nil)

for key, value in pairs(meta) do
Expand Down Expand Up @@ -95,4 +98,5 @@ local function test()
end

test()

return sol2

0 comments on commit aba8e29

Please sign in to comment.