mirror of
https://github.com/Ukendio/jecs.git
synced 2025-06-19 15:59:18 +00:00
Fix line endings (#233)
This commit is contained in:
parent
803616a005
commit
e74924ec07
16 changed files with 1162 additions and 1162 deletions
4
.gitattributes
vendored
4
.gitattributes
vendored
|
@ -1,2 +1,2 @@
|
||||||
*.luau text eol=lf
|
*.luau text eol=lf
|
||||||
*.html linguist-vendored
|
*.html linguist-vendored
|
||||||
|
|
28
.github/PULL_REQUEST_TEMPLATE.md
vendored
28
.github/PULL_REQUEST_TEMPLATE.md
vendored
|
@ -1,15 +1,15 @@
|
||||||
## Brief Description of your Changes.
|
## Brief Description of your Changes.
|
||||||
|
|
||||||
Describe what you did here. Additionally, you should link any relevant issues within this section. If there is no corresponding issue, you should include relevant information (repro steps, motivation, etc) here.
|
Describe what you did here. Additionally, you should link any relevant issues within this section. If there is no corresponding issue, you should include relevant information (repro steps, motivation, etc) here.
|
||||||
|
|
||||||
## Impact of your Changes
|
## Impact of your Changes
|
||||||
|
|
||||||
What implications will this have on the project? Will there be altered behavior or performance with this change?
|
What implications will this have on the project? Will there be altered behavior or performance with this change?
|
||||||
|
|
||||||
## Tests Performed
|
## Tests Performed
|
||||||
|
|
||||||
What have you done to ensure this change has the least possible impact on the project?
|
What have you done to ensure this change has the least possible impact on the project?
|
||||||
|
|
||||||
## Additional Comments
|
## Additional Comments
|
||||||
|
|
||||||
Anything else you feel is relevant.
|
Anything else you feel is relevant.
|
146
.gitignore
vendored
146
.gitignore
vendored
|
@ -1,73 +1,73 @@
|
||||||
# Compiled Lua sources
|
# Compiled Lua sources
|
||||||
luac.out
|
luac.out
|
||||||
|
|
||||||
# luarocks build files
|
# luarocks build files
|
||||||
*.src.rock
|
*.src.rock
|
||||||
*.zip
|
*.zip
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
*.rbxm
|
*.rbxm
|
||||||
|
|
||||||
# Object files
|
# Object files
|
||||||
*.o
|
*.o
|
||||||
*.os
|
*.os
|
||||||
*.ko
|
*.ko
|
||||||
*.obj
|
*.obj
|
||||||
*.elf
|
*.elf
|
||||||
|
|
||||||
# Precompiled Headers
|
# Precompiled Headers
|
||||||
*.gch
|
*.gch
|
||||||
*.pch
|
*.pch
|
||||||
|
|
||||||
# Libraries
|
# Libraries
|
||||||
*.lib
|
*.lib
|
||||||
*.a
|
*.a
|
||||||
*.la
|
*.la
|
||||||
*.lo
|
*.lo
|
||||||
*.def
|
*.def
|
||||||
*.exp
|
*.exp
|
||||||
|
|
||||||
# Shared objects (inc. Windows DLLs)
|
# Shared objects (inc. Windows DLLs)
|
||||||
*.dll
|
*.dll
|
||||||
*.so
|
*.so
|
||||||
*.so.*
|
*.so.*
|
||||||
*.dylib
|
*.dylib
|
||||||
|
|
||||||
# Executables
|
# Executables
|
||||||
*.exe
|
*.exe
|
||||||
*.out
|
*.out
|
||||||
*.app
|
*.app
|
||||||
*.i*86
|
*.i*86
|
||||||
*.x86_64
|
*.x86_64
|
||||||
*.hex
|
*.hex
|
||||||
|
|
||||||
# Wally files
|
# Wally files
|
||||||
DevPackages
|
DevPackages
|
||||||
Packages
|
Packages
|
||||||
wally.lock
|
wally.lock
|
||||||
WallyPatches
|
WallyPatches
|
||||||
|
|
||||||
# Typescript
|
# Typescript
|
||||||
/node_modules
|
/node_modules
|
||||||
/include
|
/include
|
||||||
|
|
||||||
# Misc
|
# Misc
|
||||||
roblox.toml
|
roblox.toml
|
||||||
sourcemap.json
|
sourcemap.json
|
||||||
drafts/
|
drafts/
|
||||||
|
|
||||||
# Cached Vitepress (docs)
|
# Cached Vitepress (docs)
|
||||||
|
|
||||||
/docs/.vitepress/cache
|
/docs/.vitepress/cache
|
||||||
/docs/.vitepress/dist
|
/docs/.vitepress/dist
|
||||||
|
|
||||||
.vitepress/cache
|
.vitepress/cache
|
||||||
.vitepress/dist
|
.vitepress/dist
|
||||||
|
|
||||||
# Luau tools
|
# Luau tools
|
||||||
profile.*
|
profile.*
|
||||||
|
|
||||||
# Patch files
|
# Patch files
|
||||||
|
|
||||||
*.patch
|
*.patch
|
||||||
|
|
||||||
genhtml.perl
|
genhtml.perl
|
||||||
|
|
20
.luaurc
20
.luaurc
|
@ -1,10 +1,10 @@
|
||||||
{
|
{
|
||||||
"aliases": {
|
"aliases": {
|
||||||
"jecs": "jecs",
|
"jecs": "jecs",
|
||||||
"testkit": "tools/testkit",
|
"testkit": "tools/testkit",
|
||||||
"mirror": "mirror",
|
"mirror": "mirror",
|
||||||
"tools": "tools",
|
"tools": "tools",
|
||||||
"addons": "addons"
|
"addons": "addons"
|
||||||
},
|
},
|
||||||
"languageMode": "strict"
|
"languageMode": "strict"
|
||||||
}
|
}
|
||||||
|
|
18
.stylua.toml
18
.stylua.toml
|
@ -1,9 +1,9 @@
|
||||||
syntax = "All"
|
syntax = "All"
|
||||||
column_width = 120
|
column_width = 120
|
||||||
line_endings = "Unix"
|
line_endings = "Unix"
|
||||||
indent_type = "Tabs"
|
indent_type = "Tabs"
|
||||||
indent_width = 4
|
indent_width = 4
|
||||||
quote_style = "AutoPreferDouble"
|
quote_style = "AutoPreferDouble"
|
||||||
call_parentheses = "Always"
|
call_parentheses = "Always"
|
||||||
space_after_function_names = "Never"
|
space_after_function_names = "Never"
|
||||||
collapse_simple_statement = "Never"
|
collapse_simple_statement = "Never"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<svg width="47" height="18" viewBox="0 0 47 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="47" height="18" viewBox="0 0 47 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path d="M5 14C5.8 14 6 13.3333 6 13V4H0V0H6H10V13C10 17 6.66667 18 5 18H0V14H5Z" fill="white"/>
|
<path d="M5 14C5.8 14 6 13.3333 6 13V4H0V0H6H10V13C10 17 6.66667 18 5 18H0V14H5Z" fill="white"/>
|
||||||
<path d="M46.5 4V0H39C37.1667 0 33.5 1.1 33.5 5.5C33.5 9.9 36.8333 11 38.5 11H41C41.5 11 42.5 11.3 42.5 12.5C42.5 13.7 41.5 14 41 14H33.5V18H41.5C43.1667 18 46.5 16.9 46.5 12.5C46.5 8.1 43.1667 7 41.5 7H39C38.5 7 37.5 6.7 37.5 5.5C37.5 4.3 38.5 4 39 4H46.5Z" fill="white"/>
|
<path d="M46.5 4V0H39C37.1667 0 33.5 1.1 33.5 5.5C33.5 9.9 36.8333 11 38.5 11H41C41.5 11 42.5 11.3 42.5 12.5C42.5 13.7 41.5 14 41 14H33.5V18H41.5C43.1667 18 46.5 16.9 46.5 12.5C46.5 8.1 43.1667 7 41.5 7H39C38.5 7 37.5 6.7 37.5 5.5C37.5 4.3 38.5 4 39 4H46.5Z" fill="white"/>
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M32.5 0V4H30.5C28.5 4 24.5 5 24.5 9C24.5 11.0835 25.5853 12.3531 26.9078 13.0914L22.4606 14.661C21.2893 13.3156 20.5 11.4775 20.5 9C20.5 1.8 27.1667 0 30.5 0H32.5ZM24.4656 16.3357C26.5037 17.5803 28.8905 18 30.5 18H32.5V14H31.0833L24.4656 16.3357Z" fill="white"/>
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M32.5 0V4H30.5C28.5 4 24.5 5 24.5 9C24.5 11.0835 25.5853 12.3531 26.9078 13.0914L22.4606 14.661C21.2893 13.3156 20.5 11.4775 20.5 9C20.5 1.8 27.1667 0 30.5 0H32.5ZM24.4656 16.3357C26.5037 17.5803 28.8905 18 30.5 18H32.5V14H31.0833L24.4656 16.3357Z" fill="white"/>
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M25.3793 0C24.766 0.241156 24.1568 0.53354 23.571 0.885014C22.1712 1.72492 20.9038 2.91123 20.0606 4.5H11V0H25.3793ZM25.5 4.39421C25.445 4.42876 25.3906 4.46402 25.3368 4.5H25.5V4.39421ZM20.0606 13.5C20.9038 15.0888 22.1712 16.2751 23.571 17.115C24.1568 17.4665 24.766 17.7588 25.3793 18H11V13.5H20.0606ZM19.1854 7C19.0649 7.62348 19 8.28956 19 9C19 9.71044 19.0649 10.3765 19.1854 11H11V7H19.1854Z" fill="white"/>
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M25.3793 0C24.766 0.241156 24.1568 0.53354 23.571 0.885014C22.1712 1.72492 20.9038 2.91123 20.0606 4.5H11V0H25.3793ZM25.5 4.39421C25.445 4.42876 25.3906 4.46402 25.3368 4.5H25.5V4.39421ZM20.0606 13.5C20.9038 15.0888 22.1712 16.2751 23.571 17.115C24.1568 17.4665 24.766 17.7588 25.3793 18H11V13.5H20.0606ZM19.1854 7C19.0649 7.62348 19 8.28956 19 9C19 9.71044 19.0649 10.3765 19.1854 11H11V7H19.1854Z" fill="white"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
|
@ -1,6 +1,6 @@
|
||||||
<svg width="47" height="18" viewBox="0 0 47 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
<svg width="47" height="18" viewBox="0 0 47 18" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
<path d="M5 14C5.8 14 6 13.3333 6 13V4H0V0H6H10V13C10 17 6.66667 18 5 18H0V14H5Z" fill="black"/>
|
<path d="M5 14C5.8 14 6 13.3333 6 13V4H0V0H6H10V13C10 17 6.66667 18 5 18H0V14H5Z" fill="black"/>
|
||||||
<path d="M46.5 4V0H39C37.1667 0 33.5 1.1 33.5 5.5C33.5 9.9 36.8333 11 38.5 11H41C41.5 11 42.5 11.3 42.5 12.5C42.5 13.7 41.5 14 41 14H33.5V18H41.5C43.1667 18 46.5 16.9 46.5 12.5C46.5 8.1 43.1667 7 41.5 7H39C38.5 7 37.5 6.7 37.5 5.5C37.5 4.3 38.5 4 39 4H46.5Z" fill="black"/>
|
<path d="M46.5 4V0H39C37.1667 0 33.5 1.1 33.5 5.5C33.5 9.9 36.8333 11 38.5 11H41C41.5 11 42.5 11.3 42.5 12.5C42.5 13.7 41.5 14 41 14H33.5V18H41.5C43.1667 18 46.5 16.9 46.5 12.5C46.5 8.1 43.1667 7 41.5 7H39C38.5 7 37.5 6.7 37.5 5.5C37.5 4.3 38.5 4 39 4H46.5Z" fill="black"/>
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M32.5 0V4H30.5C28.5 4 24.5 5 24.5 9C24.5 11.0835 25.5853 12.3531 26.9078 13.0914L22.4606 14.661C21.2893 13.3156 20.5 11.4775 20.5 9C20.5 1.8 27.1667 0 30.5 0H32.5ZM24.4656 16.3357C26.5037 17.5803 28.8905 18 30.5 18H32.5V14H31.0833L24.4656 16.3357Z" fill="black"/>
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M32.5 0V4H30.5C28.5 4 24.5 5 24.5 9C24.5 11.0835 25.5853 12.3531 26.9078 13.0914L22.4606 14.661C21.2893 13.3156 20.5 11.4775 20.5 9C20.5 1.8 27.1667 0 30.5 0H32.5ZM24.4656 16.3357C26.5037 17.5803 28.8905 18 30.5 18H32.5V14H31.0833L24.4656 16.3357Z" fill="black"/>
|
||||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M25.3793 0C24.766 0.241156 24.1568 0.53354 23.571 0.885014C22.1712 1.72492 20.9038 2.91123 20.0606 4.5H11V0H25.3793ZM25.5 4.39421C25.445 4.42876 25.3906 4.46402 25.3368 4.5H25.5V4.39421ZM20.0606 13.5C20.9038 15.0888 22.1712 16.2751 23.571 17.115C24.1568 17.4665 24.766 17.7588 25.3793 18H11V13.5H20.0606ZM19.1854 7C19.0649 7.62348 19 8.28956 19 9C19 9.71044 19.0649 10.3765 19.1854 11H11V7H19.1854Z" fill="black"/>
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M25.3793 0C24.766 0.241156 24.1568 0.53354 23.571 0.885014C22.1712 1.72492 20.9038 2.91123 20.0606 4.5H11V0H25.3793ZM25.5 4.39421C25.445 4.42876 25.3906 4.46402 25.3368 4.5H25.5V4.39421ZM20.0606 13.5C20.9038 15.0888 22.1712 16.2751 23.571 17.115C24.1568 17.4665 24.766 17.7588 25.3793 18H11V13.5H20.0606ZM19.1854 7C19.0649 7.62348 19 8.28956 19 9C19 9.71044 19.0649 10.3765 19.1854 11H11V7H19.1854Z" fill="black"/>
|
||||||
</svg>
|
</svg>
|
||||||
|
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
100
docs/api/jecs.md
100
docs/api/jecs.md
|
@ -1,50 +1,50 @@
|
||||||
# Jecs
|
# Jecs
|
||||||
|
|
||||||
Jecs. Just an Entity Component System.
|
Jecs. Just an Entity Component System.
|
||||||
|
|
||||||
# Properties
|
# Properties
|
||||||
|
|
||||||
## World
|
## World
|
||||||
```luau
|
```luau
|
||||||
jecs.World: World
|
jecs.World: World
|
||||||
```
|
```
|
||||||
A world is a container of all ECS data. Games can have multiple worlds but component IDs may conflict between worlds. Ensure to register the same component IDs in the same order for each world.
|
A world is a container of all ECS data. Games can have multiple worlds but component IDs may conflict between worlds. Ensure to register the same component IDs in the same order for each world.
|
||||||
|
|
||||||
## Wildcard
|
## Wildcard
|
||||||
```luau
|
```luau
|
||||||
jecs.Wildcard: Entity
|
jecs.Wildcard: Entity
|
||||||
```
|
```
|
||||||
Builtin component type. This ID is used for wildcard queries.
|
Builtin component type. This ID is used for wildcard queries.
|
||||||
|
|
||||||
## Component
|
## Component
|
||||||
```luau
|
```luau
|
||||||
jecs.Component: Entity
|
jecs.Component: Entity
|
||||||
```
|
```
|
||||||
Builtin component type. Every ID created with [world:component()](world.md#component()) has this type added to it. This is meant for querying every component ID.
|
Builtin component type. Every ID created with [world:component()](world.md#component()) has this type added to it. This is meant for querying every component ID.
|
||||||
|
|
||||||
## ChildOf
|
## ChildOf
|
||||||
```luau
|
```luau
|
||||||
jecs.ChildOf: Entity
|
jecs.ChildOf: Entity
|
||||||
```
|
```
|
||||||
Builtin component type. This ID is for creating parent-child hierarchies.
|
Builtin component type. This ID is for creating parent-child hierarchies.
|
||||||
|
|
||||||
## Rest
|
## Rest
|
||||||
```luau
|
```luau
|
||||||
jecs.Rest: Entity
|
jecs.Rest: Entity
|
||||||
```
|
```
|
||||||
|
|
||||||
# Functions
|
# Functions
|
||||||
|
|
||||||
## pair()
|
## pair()
|
||||||
```luau
|
```luau
|
||||||
function jecs.pair(
|
function jecs.pair(
|
||||||
first: Entity, -- The first element of the pair, referred to as the relationship of the relationship pair.
|
first: Entity, -- The first element of the pair, referred to as the relationship of the relationship pair.
|
||||||
object: Entity, -- The second element of the pair, referred to as the target of the relationship pair.
|
object: Entity, -- The second element of the pair, referred to as the target of the relationship pair.
|
||||||
): number -- Returns the ID with those two elements
|
): number -- Returns the ID with those two elements
|
||||||
|
|
||||||
```
|
```
|
||||||
::: info
|
::: info
|
||||||
|
|
||||||
While relationship pairs can be used as components and have data associated with an ID, they cannot be used as entities. Meaning you cannot add components to a pair as the source of a binding.
|
While relationship pairs can be used as components and have data associated with an ID, they cannot be used as entities. Meaning you cannot add components to a pair as the source of a binding.
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
# Contribution Guidelines
|
# Contribution Guidelines
|
||||||
|
|
||||||
Whether you found an issue, or want to make a change to jecs, we'd love to hear back from the community on what features you want or bugs you've run into.
|
Whether you found an issue, or want to make a change to jecs, we'd love to hear back from the community on what features you want or bugs you've run into.
|
||||||
|
|
||||||
There's a few different ways you can go about this.
|
There's a few different ways you can go about this.
|
||||||
|
|
||||||
## Creating an Issue
|
## Creating an Issue
|
||||||
|
|
||||||
This is what you should be filing if you have a bug you want to report.
|
This is what you should be filing if you have a bug you want to report.
|
||||||
|
|
||||||
[Click here](https://github.com/Ukendio/jecs/issues/new/choose) to file a bug report. We have a few templates ready for the most common issue types.
|
[Click here](https://github.com/Ukendio/jecs/issues/new/choose) to file a bug report. We have a few templates ready for the most common issue types.
|
||||||
|
|
||||||
Additionally, see the [Submitting Issues](../contributing/issues) page for more information.
|
Additionally, see the [Submitting Issues](../contributing/issues) page for more information.
|
||||||
|
|
||||||
## Creating a Pull Request
|
## Creating a Pull Request
|
||||||
|
|
||||||
This is what you should be filing if you have a change you want to merge into the main project.
|
This is what you should be filing if you have a change you want to merge into the main project.
|
||||||
|
|
||||||
[Click here](https://github.com/Ukendio/jecs/compare) to select the branch you want to merge from.
|
[Click here](https://github.com/Ukendio/jecs/compare) to select the branch you want to merge from.
|
||||||
|
|
||||||
Additionally, see the [Submitting Pull Requests](../contributing/pull-requests) page for more information.
|
Additionally, see the [Submitting Pull Requests](../contributing/pull-requests) page for more information.
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
# Submitting Issues
|
# Submitting Issues
|
||||||
|
|
||||||
When you're submitting an issue, generally they fall into a few categories:
|
When you're submitting an issue, generally they fall into a few categories:
|
||||||
|
|
||||||
## Bug
|
## Bug
|
||||||
|
|
||||||
We need some information to figure out what's going wrong. At a minimum, you need to tell us:
|
We need some information to figure out what's going wrong. At a minimum, you need to tell us:
|
||||||
|
|
||||||
(1) What's supposed to happen
|
(1) What's supposed to happen
|
||||||
|
|
||||||
(2) What actually happened
|
(2) What actually happened
|
||||||
|
|
||||||
(3) Steps to reproduce
|
(3) Steps to reproduce
|
||||||
|
|
||||||
|
|
||||||
Stack traces and other useful information that you find make a bug report more likely to be fixed.
|
Stack traces and other useful information that you find make a bug report more likely to be fixed.
|
||||||
|
|
||||||
Consult the template for a bug report if you don't know or have questions about how to format this.
|
Consult the template for a bug report if you don't know or have questions about how to format this.
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
Depending on how you go about it, this can be done as a [Pull Request](../contributing/pull-requests) instead of an issue. Generally, we need to know what was wrong, what you changed, and how it improved the documentation if it isn't obvious.
|
Depending on how you go about it, this can be done as a [Pull Request](../contributing/pull-requests) instead of an issue. Generally, we need to know what was wrong, what you changed, and how it improved the documentation if it isn't obvious.
|
||||||
|
|
||||||
We just need to know what's wrong. You should fill out a [PR](../contributing/pull-requests) if you know what should be there instead.
|
We just need to know what's wrong. You should fill out a [PR](../contributing/pull-requests) if you know what should be there instead.
|
||||||
|
|
|
@ -1,77 +1,77 @@
|
||||||
# Submitting Pull Requests
|
# Submitting Pull Requests
|
||||||
|
|
||||||
When submitting a Pull Request, there's a few reasons to do so:
|
When submitting a Pull Request, there's a few reasons to do so:
|
||||||
|
|
||||||
|
|
||||||
## Documentation
|
## Documentation
|
||||||
|
|
||||||
If there's something to change with the documentation, you should follow a similar format to this example:
|
If there's something to change with the documentation, you should follow a similar format to this example:
|
||||||
|
|
||||||
An example of an appropriate typo-fixing PR would be:
|
An example of an appropriate typo-fixing PR would be:
|
||||||
|
|
||||||
>**Brief Description of your Changes**
|
>**Brief Description of your Changes**
|
||||||
>
|
>
|
||||||
>I fixed a couple of typos found in the /contributing/issues.md file.
|
>I fixed a couple of typos found in the /contributing/issues.md file.
|
||||||
>
|
>
|
||||||
>**Impact of your Changes**
|
>**Impact of your Changes**
|
||||||
>
|
>
|
||||||
>- Documentation is more clear and readable for the users.
|
>- Documentation is more clear and readable for the users.
|
||||||
>
|
>
|
||||||
>**Tests Performed**
|
>**Tests Performed**
|
||||||
>
|
>
|
||||||
>Ran `vitepress dev docs` and verified it was built successfully.
|
>Ran `vitepress dev docs` and verified it was built successfully.
|
||||||
>
|
>
|
||||||
>**Additional Comments**
|
>**Additional Comments**
|
||||||
>
|
>
|
||||||
>[At Discretion]
|
>[At Discretion]
|
||||||
|
|
||||||
## Change in Behavior
|
## Change in Behavior
|
||||||
|
|
||||||
An example of an appropriate PR that adds a new feature would be:
|
An example of an appropriate PR that adds a new feature would be:
|
||||||
|
|
||||||
>
|
>
|
||||||
>**Brief Description of your Changes**
|
>**Brief Description of your Changes**
|
||||||
>
|
>
|
||||||
>I added `jecs.best_function`, which gives everyone who uses the module an immediate boost in concurrent player counts. (this is a joke)
|
>I added `jecs.best_function`, which gives everyone who uses the module an immediate boost in concurrent player counts. (this is a joke)
|
||||||
>
|
>
|
||||||
>**Impact of your Changes**
|
>**Impact of your Changes**
|
||||||
>
|
>
|
||||||
>- jecs functionality is extended to better fit the needs of the community [explain why].
|
>- jecs functionality is extended to better fit the needs of the community [explain why].
|
||||||
>
|
>
|
||||||
>**Tests Performed**
|
>**Tests Performed**
|
||||||
>
|
>
|
||||||
>Added a few test cases to ensure the function runs as expected [link to changes].
|
>Added a few test cases to ensure the function runs as expected [link to changes].
|
||||||
>
|
>
|
||||||
>**Additional Comments**
|
>**Additional Comments**
|
||||||
>
|
>
|
||||||
>[At Discretion]
|
>[At Discretion]
|
||||||
|
|
||||||
## Addons
|
## Addons
|
||||||
|
|
||||||
If you made something you think should be included into the [resources page](../../resources), let us know!
|
If you made something you think should be included into the [resources page](../../resources), let us know!
|
||||||
|
|
||||||
We have tons of examples of libraries and other tools which can be used in conjunction with jecs on this page.
|
We have tons of examples of libraries and other tools which can be used in conjunction with jecs on this page.
|
||||||
|
|
||||||
One example of a PR that would be accepted is:
|
One example of a PR that would be accepted is:
|
||||||
|
|
||||||
>**Brief Description of your Changes**
|
>**Brief Description of your Changes**
|
||||||
>
|
>
|
||||||
>I added `jecs observers` to the addons page.
|
>I added `jecs observers` to the addons page.
|
||||||
>
|
>
|
||||||
>**Impact of your Changes**
|
>**Impact of your Changes**
|
||||||
>
|
>
|
||||||
>- jecs observers are a different and important way of handling queries which benefit the users of jecs by [explain why your tool benefits users here]
|
>- jecs observers are a different and important way of handling queries which benefit the users of jecs by [explain why your tool benefits users here]
|
||||||
>
|
>
|
||||||
>- [talk about why you went with this design instead of maybe an alternative]
|
>- [talk about why you went with this design instead of maybe an alternative]
|
||||||
>
|
>
|
||||||
>**Tests Performed**
|
>**Tests Performed**
|
||||||
>
|
>
|
||||||
> I used this tool in conjunction with jecs and ensured it works as expected.
|
> I used this tool in conjunction with jecs and ensured it works as expected.
|
||||||
>
|
>
|
||||||
> [If you wrote unit tests for your tool, mention it here.]
|
> [If you wrote unit tests for your tool, mention it here.]
|
||||||
>
|
>
|
||||||
>**Additional Comments**
|
>**Additional Comments**
|
||||||
>
|
>
|
||||||
>[At Discretion]
|
>[At Discretion]
|
||||||
|
|
||||||
Keep in mind the list on the addons page is *not* exhaustive. If you came up with a tool that doesn't fit into any of the categories listed, we still want to hear from you!
|
Keep in mind the list on the addons page is *not* exhaustive. If you came up with a tool that doesn't fit into any of the categories listed, we still want to hear from you!
|
||||||
|
|
|
@ -1,177 +1,177 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
# This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
# This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
||||||
|
|
||||||
# Given a profile dump, this tool generates a flame graph based on the stacks listed in the profile
|
# Given a profile dump, this tool generates a flame graph based on the stacks listed in the profile
|
||||||
# The result of analysis is a .svg file which can be viewed in a browser
|
# The result of analysis is a .svg file which can be viewed in a browser
|
||||||
|
|
||||||
import svg
|
import svg
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
|
|
||||||
argumentParser = argparse.ArgumentParser(description='Generate flamegraph SVG from Luau sampling profiler dumps')
|
argumentParser = argparse.ArgumentParser(description='Generate flamegraph SVG from Luau sampling profiler dumps')
|
||||||
argumentParser.add_argument('source_file', type=open)
|
argumentParser.add_argument('source_file', type=open)
|
||||||
argumentParser.add_argument('--json', dest='useJson',action='store_const',const=1,default=0,help='Parse source_file as JSON')
|
argumentParser.add_argument('--json', dest='useJson',action='store_const',const=1,default=0,help='Parse source_file as JSON')
|
||||||
|
|
||||||
class Node(svg.Node):
|
class Node(svg.Node):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
svg.Node.__init__(self)
|
svg.Node.__init__(self)
|
||||||
self.function = ""
|
self.function = ""
|
||||||
self.source = ""
|
self.source = ""
|
||||||
self.line = 0
|
self.line = 0
|
||||||
self.ticks = 0
|
self.ticks = 0
|
||||||
|
|
||||||
def text(self):
|
def text(self):
|
||||||
return self.function
|
return self.function
|
||||||
|
|
||||||
def title(self):
|
def title(self):
|
||||||
if self.line > 0:
|
if self.line > 0:
|
||||||
return "{}\n{}:{}".format(self.function, self.source, self.line)
|
return "{}\n{}:{}".format(self.function, self.source, self.line)
|
||||||
else:
|
else:
|
||||||
return self.function
|
return self.function
|
||||||
|
|
||||||
def details(self, root):
|
def details(self, root):
|
||||||
return "Function: {} [{}:{}] ({:,} usec, {:.1%}); self: {:,} usec".format(self.function, self.source, self.line, self.width, self.width / root.width, self.ticks)
|
return "Function: {} [{}:{}] ({:,} usec, {:.1%}); self: {:,} usec".format(self.function, self.source, self.line, self.width, self.width / root.width, self.ticks)
|
||||||
|
|
||||||
|
|
||||||
def nodeFromCallstackListFile(source_file):
|
def nodeFromCallstackListFile(source_file):
|
||||||
dump = source_file.readlines()
|
dump = source_file.readlines()
|
||||||
root = Node()
|
root = Node()
|
||||||
|
|
||||||
for l in dump:
|
for l in dump:
|
||||||
ticks, stack = l.strip().split(" ", 1)
|
ticks, stack = l.strip().split(" ", 1)
|
||||||
node = root
|
node = root
|
||||||
|
|
||||||
for f in reversed(stack.split(";")):
|
for f in reversed(stack.split(";")):
|
||||||
source, function, line = f.split(",")
|
source, function, line = f.split(",")
|
||||||
|
|
||||||
child = node.child(f)
|
child = node.child(f)
|
||||||
child.function = function
|
child.function = function
|
||||||
child.source = source
|
child.source = source
|
||||||
child.line = int(line) if len(line) > 0 else 0
|
child.line = int(line) if len(line) > 0 else 0
|
||||||
|
|
||||||
node = child
|
node = child
|
||||||
|
|
||||||
node.ticks += int(ticks)
|
node.ticks += int(ticks)
|
||||||
|
|
||||||
return root
|
return root
|
||||||
|
|
||||||
|
|
||||||
def getDuration(nodes, nid):
|
def getDuration(nodes, nid):
|
||||||
node = nodes[nid - 1]
|
node = nodes[nid - 1]
|
||||||
total = node['TotalDuration']
|
total = node['TotalDuration']
|
||||||
|
|
||||||
if 'NodeIds' in node:
|
if 'NodeIds' in node:
|
||||||
for cid in node['NodeIds']:
|
for cid in node['NodeIds']:
|
||||||
total -= nodes[cid - 1]['TotalDuration']
|
total -= nodes[cid - 1]['TotalDuration']
|
||||||
|
|
||||||
return total
|
return total
|
||||||
|
|
||||||
def getFunctionKey(fn):
|
def getFunctionKey(fn):
|
||||||
source = fn['Source'] if 'Source' in fn else ''
|
source = fn['Source'] if 'Source' in fn else ''
|
||||||
name = fn['Name'] if 'Name' in fn else ''
|
name = fn['Name'] if 'Name' in fn else ''
|
||||||
line = str(fn['Line']) if 'Line' in fn else '-1'
|
line = str(fn['Line']) if 'Line' in fn else '-1'
|
||||||
|
|
||||||
return source + "," + name + "," + line
|
return source + "," + name + "," + line
|
||||||
|
|
||||||
def recursivelyBuildNodeTree(nodes, functions, parent, fid, nid):
|
def recursivelyBuildNodeTree(nodes, functions, parent, fid, nid):
|
||||||
ninfo = nodes[nid - 1]
|
ninfo = nodes[nid - 1]
|
||||||
finfo = functions[fid - 1]
|
finfo = functions[fid - 1]
|
||||||
|
|
||||||
child = parent.child(getFunctionKey(finfo))
|
child = parent.child(getFunctionKey(finfo))
|
||||||
child.source = finfo['Source'] if 'Source' in finfo else ''
|
child.source = finfo['Source'] if 'Source' in finfo else ''
|
||||||
child.function = finfo['Name'] if 'Name' in finfo else ''
|
child.function = finfo['Name'] if 'Name' in finfo else ''
|
||||||
child.line = int(finfo['Line']) if 'Line' in finfo and finfo['Line'] > 0 else 0
|
child.line = int(finfo['Line']) if 'Line' in finfo and finfo['Line'] > 0 else 0
|
||||||
|
|
||||||
child.ticks = getDuration(nodes, nid)
|
child.ticks = getDuration(nodes, nid)
|
||||||
|
|
||||||
if 'FunctionIds' in ninfo:
|
if 'FunctionIds' in ninfo:
|
||||||
assert(len(ninfo['FunctionIds']) == len(ninfo['NodeIds']))
|
assert(len(ninfo['FunctionIds']) == len(ninfo['NodeIds']))
|
||||||
|
|
||||||
for i in range(0, len(ninfo['FunctionIds'])):
|
for i in range(0, len(ninfo['FunctionIds'])):
|
||||||
recursivelyBuildNodeTree(nodes, functions, child, ninfo['FunctionIds'][i], ninfo['NodeIds'][i])
|
recursivelyBuildNodeTree(nodes, functions, child, ninfo['FunctionIds'][i], ninfo['NodeIds'][i])
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
def nodeFromJSONV2(dump):
|
def nodeFromJSONV2(dump):
|
||||||
assert(dump['Version'] == 2)
|
assert(dump['Version'] == 2)
|
||||||
|
|
||||||
nodes = dump['Nodes']
|
nodes = dump['Nodes']
|
||||||
functions = dump['Functions']
|
functions = dump['Functions']
|
||||||
categories = dump['Categories']
|
categories = dump['Categories']
|
||||||
|
|
||||||
root = Node()
|
root = Node()
|
||||||
|
|
||||||
for category in categories:
|
for category in categories:
|
||||||
nid = category['NodeId']
|
nid = category['NodeId']
|
||||||
node = nodes[nid - 1]
|
node = nodes[nid - 1]
|
||||||
name = category['Name']
|
name = category['Name']
|
||||||
|
|
||||||
child = root.child(name)
|
child = root.child(name)
|
||||||
child.function = name
|
child.function = name
|
||||||
child.ticks = getDuration(nodes, nid)
|
child.ticks = getDuration(nodes, nid)
|
||||||
|
|
||||||
if 'FunctionIds' in node:
|
if 'FunctionIds' in node:
|
||||||
assert(len(node['FunctionIds']) == len(node['NodeIds']))
|
assert(len(node['FunctionIds']) == len(node['NodeIds']))
|
||||||
|
|
||||||
for i in range(0, len(node['FunctionIds'])):
|
for i in range(0, len(node['FunctionIds'])):
|
||||||
recursivelyBuildNodeTree(nodes, functions, child, node['FunctionIds'][i], node['NodeIds'][i])
|
recursivelyBuildNodeTree(nodes, functions, child, node['FunctionIds'][i], node['NodeIds'][i])
|
||||||
|
|
||||||
return root
|
return root
|
||||||
|
|
||||||
def getDurationV1(obj):
|
def getDurationV1(obj):
|
||||||
total = obj['TotalDuration']
|
total = obj['TotalDuration']
|
||||||
|
|
||||||
if 'Children' in obj:
|
if 'Children' in obj:
|
||||||
for key, obj in obj['Children'].items():
|
for key, obj in obj['Children'].items():
|
||||||
total -= obj['TotalDuration']
|
total -= obj['TotalDuration']
|
||||||
|
|
||||||
return total
|
return total
|
||||||
|
|
||||||
|
|
||||||
def nodeFromJSONObject(node, key, obj):
|
def nodeFromJSONObject(node, key, obj):
|
||||||
source, function, line = key.split(",")
|
source, function, line = key.split(",")
|
||||||
|
|
||||||
node.function = function
|
node.function = function
|
||||||
node.source = source
|
node.source = source
|
||||||
node.line = int(line) if len(line) > 0 else 0
|
node.line = int(line) if len(line) > 0 else 0
|
||||||
|
|
||||||
node.ticks = getDurationV1(obj)
|
node.ticks = getDurationV1(obj)
|
||||||
|
|
||||||
if 'Children' in obj:
|
if 'Children' in obj:
|
||||||
for key, obj in obj['Children'].items():
|
for key, obj in obj['Children'].items():
|
||||||
nodeFromJSONObject(node.child(key), key, obj)
|
nodeFromJSONObject(node.child(key), key, obj)
|
||||||
|
|
||||||
return node
|
return node
|
||||||
|
|
||||||
def nodeFromJSONV1(dump):
|
def nodeFromJSONV1(dump):
|
||||||
assert(dump['Version'] == 1)
|
assert(dump['Version'] == 1)
|
||||||
root = Node()
|
root = Node()
|
||||||
|
|
||||||
if 'Children' in dump:
|
if 'Children' in dump:
|
||||||
for key, obj in dump['Children'].items():
|
for key, obj in dump['Children'].items():
|
||||||
nodeFromJSONObject(root.child(key), key, obj)
|
nodeFromJSONObject(root.child(key), key, obj)
|
||||||
|
|
||||||
return root
|
return root
|
||||||
|
|
||||||
def nodeFromJSONFile(source_file):
|
def nodeFromJSONFile(source_file):
|
||||||
dump = json.load(source_file)
|
dump = json.load(source_file)
|
||||||
|
|
||||||
if dump['Version'] == 2:
|
if dump['Version'] == 2:
|
||||||
return nodeFromJSONV2(dump)
|
return nodeFromJSONV2(dump)
|
||||||
elif dump['Version'] == 1:
|
elif dump['Version'] == 1:
|
||||||
return nodeFromJSONV1(dump)
|
return nodeFromJSONV1(dump)
|
||||||
|
|
||||||
return Node()
|
return Node()
|
||||||
|
|
||||||
|
|
||||||
arguments = argumentParser.parse_args()
|
arguments = argumentParser.parse_args()
|
||||||
|
|
||||||
if arguments.useJson:
|
if arguments.useJson:
|
||||||
root = nodeFromJSONFile(arguments.source_file)
|
root = nodeFromJSONFile(arguments.source_file)
|
||||||
else:
|
else:
|
||||||
root = nodeFromCallstackListFile(arguments.source_file)
|
root = nodeFromCallstackListFile(arguments.source_file)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
svg.layout(root, lambda n: n.ticks)
|
svg.layout(root, lambda n: n.ticks)
|
||||||
svg.display(root, "Flame Graph", "hot", flip = True)
|
svg.display(root, "Flame Graph", "hot", flip = True)
|
||||||
|
|
|
@ -1,153 +1,153 @@
|
||||||
import os
|
import os
|
||||||
|
|
||||||
LCOV_FILE = "coverage.out"
|
LCOV_FILE = "coverage.out"
|
||||||
OUTPUT_DIR = "coverage"
|
OUTPUT_DIR = "coverage"
|
||||||
|
|
||||||
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
os.makedirs(OUTPUT_DIR, exist_ok=True)
|
||||||
|
|
||||||
def parse_lcov(content):
|
def parse_lcov(content):
|
||||||
"""Parses LCOV data from a single string."""
|
"""Parses LCOV data from a single string."""
|
||||||
files = {}
|
files = {}
|
||||||
current_file = None
|
current_file = None
|
||||||
|
|
||||||
for line in content.splitlines():
|
for line in content.splitlines():
|
||||||
if line.startswith("SF:"):
|
if line.startswith("SF:"):
|
||||||
current_file = line[3:].strip()
|
current_file = line[3:].strip()
|
||||||
files[current_file] = {"coverage": {}, "functions": []}
|
files[current_file] = {"coverage": {}, "functions": []}
|
||||||
elif line.startswith("DA:") and current_file:
|
elif line.startswith("DA:") and current_file:
|
||||||
parts = line[3:].split(",")
|
parts = line[3:].split(",")
|
||||||
line_num = int(parts[0])
|
line_num = int(parts[0])
|
||||||
execution_count = int(parts[1])
|
execution_count = int(parts[1])
|
||||||
files[current_file]["coverage"][line_num] = execution_count
|
files[current_file]["coverage"][line_num] = execution_count
|
||||||
elif line.startswith("FN:") and current_file:
|
elif line.startswith("FN:") and current_file:
|
||||||
parts = line[3:].split(",")
|
parts = line[3:].split(",")
|
||||||
line_num = int(parts[0])
|
line_num = int(parts[0])
|
||||||
function_name = parts[1].strip()
|
function_name = parts[1].strip()
|
||||||
files[current_file]["functions"].append({"name": function_name, "line": line_num, "hits": 0})
|
files[current_file]["functions"].append({"name": function_name, "line": line_num, "hits": 0})
|
||||||
elif line.startswith("FNDA:") and current_file:
|
elif line.startswith("FNDA:") and current_file:
|
||||||
parts = line[5:].split(",")
|
parts = line[5:].split(",")
|
||||||
hit_count = int(parts[0])
|
hit_count = int(parts[0])
|
||||||
function_name = parts[1].strip()
|
function_name = parts[1].strip()
|
||||||
for func in files[current_file]["functions"]:
|
for func in files[current_file]["functions"]:
|
||||||
if func["name"] == function_name:
|
if func["name"] == function_name:
|
||||||
func["hits"] = hit_count
|
func["hits"] = hit_count
|
||||||
break
|
break
|
||||||
|
|
||||||
return files
|
return files
|
||||||
|
|
||||||
def read_source_file(filepath):
|
def read_source_file(filepath):
|
||||||
"""Reads source file content if available."""
|
"""Reads source file content if available."""
|
||||||
if not os.path.exists(filepath):
|
if not os.path.exists(filepath):
|
||||||
return []
|
return []
|
||||||
|
|
||||||
with open(filepath, "r", encoding="utf-8") as f:
|
with open(filepath, "r", encoding="utf-8") as f:
|
||||||
return f.readlines()
|
return f.readlines()
|
||||||
|
|
||||||
def generate_file_html(filepath, coverage_data, functions_data):
|
def generate_file_html(filepath, coverage_data, functions_data):
|
||||||
"""Generates an HTML file for a specific source file."""
|
"""Generates an HTML file for a specific source file."""
|
||||||
filename = os.path.basename(filepath)
|
filename = os.path.basename(filepath)
|
||||||
source_code = read_source_file(filepath)
|
source_code = read_source_file(filepath)
|
||||||
html_path = os.path.join(OUTPUT_DIR, f"{filename}.html")
|
html_path = os.path.join(OUTPUT_DIR, f"{filename}.html")
|
||||||
|
|
||||||
total_hits = sum(func["hits"] for func in functions_data)
|
total_hits = sum(func["hits"] for func in functions_data)
|
||||||
max_hits = max((func["hits"] for func in functions_data), default=0)
|
max_hits = max((func["hits"] for func in functions_data), default=0)
|
||||||
|
|
||||||
total_functions = len(functions_data)
|
total_functions = len(functions_data)
|
||||||
covered_functions = sum(1 for func in functions_data if func["hits"] > 0)
|
covered_functions = sum(1 for func in functions_data if func["hits"] > 0)
|
||||||
function_coverage_percent = (covered_functions / total_functions * 100) if total_functions > 0 else 0
|
function_coverage_percent = (covered_functions / total_functions * 100) if total_functions > 0 else 0
|
||||||
|
|
||||||
lines = [
|
lines = [
|
||||||
"<html><head>",
|
"<html><head>",
|
||||||
'<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css">',
|
'<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css">',
|
||||||
'<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>',
|
'<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/js/bootstrap.bundle.min.js"></script>',
|
||||||
"<style>",
|
"<style>",
|
||||||
"body { font-family: monospace; text-align: center; }",
|
"body { font-family: monospace; text-align: center; }",
|
||||||
"#funcTable table { margin: 0 auto; width: auto; max-width: 300px; font-size: 14px; border-collapse: collapse; }",
|
"#funcTable table { margin: 0 auto; width: auto; max-width: 300px; font-size: 14px; border-collapse: collapse; }",
|
||||||
"#funcTable th, #funcTable td { padding: 2px 6px; text-align: left; white-space: nowrap; }",
|
"#funcTable th, #funcTable td { padding: 2px 6px; text-align: left; white-space: nowrap; }",
|
||||||
"#funcTable th { background-color: #ddd; }",
|
"#funcTable th { background-color: #ddd; }",
|
||||||
"#funcTable td:nth-child(2) { text-align: right; min-width: 50px; }",
|
"#funcTable td:nth-child(2) { text-align: right; min-width: 50px; }",
|
||||||
".zero-hits { background-color: #fcc; font-weight: bold; color: red; }",
|
".zero-hits { background-color: #fcc; font-weight: bold; color: red; }",
|
||||||
".nonzero-hits { color: green; font-weight: bold; }",
|
".nonzero-hits { color: green; font-weight: bold; }",
|
||||||
".low-hits { background-color: #ffe6b3; }",
|
".low-hits { background-color: #ffe6b3; }",
|
||||||
".high-hits { background-color: #cfc; }",
|
".high-hits { background-color: #cfc; }",
|
||||||
".source-code-table { margin-left: 10px; }"
|
".source-code-table { margin-left: 10px; }"
|
||||||
"th, td { padding: 0px; font-size: 12px; }",
|
"th, td { padding: 0px; font-size: 12px; }",
|
||||||
"table.table { font-size: 14px; border-collapse: collapse; }",
|
"table.table { font-size: 14px; border-collapse: collapse; }",
|
||||||
"table.table th, table.table td { padding: 1px; font-size: 12px; line-height: 1.2; }",
|
"table.table th, table.table td { padding: 1px; font-size: 12px; line-height: 1.2; }",
|
||||||
"table.table tr { height: auto; }",
|
"table.table tr { height: auto; }",
|
||||||
"</style></head><body>",
|
"</style></head><body>",
|
||||||
f'<h1 class="text-center">{filename} Coverage</h1>',
|
f'<h1 class="text-center">{filename} Coverage</h1>',
|
||||||
f'<h2>Total Execution Hits: {total_hits}</h2>',
|
f'<h2>Total Execution Hits: {total_hits}</h2>',
|
||||||
f'<h2>Function Coverage Overview: {function_coverage_percent:.2f}%</h2>',
|
f'<h2>Function Coverage Overview: {function_coverage_percent:.2f}%</h2>',
|
||||||
|
|
||||||
'<button class="btn btn-primary mb-2" type="button" data-bs-toggle="collapse" data-bs-target="#funcTable">'
|
'<button class="btn btn-primary mb-2" type="button" data-bs-toggle="collapse" data-bs-target="#funcTable">'
|
||||||
'Toggle Function Coverage</button>',
|
'Toggle Function Coverage</button>',
|
||||||
|
|
||||||
'<div class="collapse show" id="funcTable">',
|
'<div class="collapse show" id="funcTable">',
|
||||||
'<h2>Function Coverage:</h2><table class="table table-bordered"><thead><tr><th>Function</th><th>Hits</th></tr></thead><tbody>'
|
'<h2>Function Coverage:</h2><table class="table table-bordered"><thead><tr><th>Function</th><th>Hits</th></tr></thead><tbody>'
|
||||||
]
|
]
|
||||||
|
|
||||||
longest_name = max((len(func["name"]) for func in functions_data), default=0)
|
longest_name = max((len(func["name"]) for func in functions_data), default=0)
|
||||||
|
|
||||||
for func in functions_data:
|
for func in functions_data:
|
||||||
hit_color = "red" if func["hits"] == 0 else "green"
|
hit_color = "red" if func["hits"] == 0 else "green"
|
||||||
lines.append(
|
lines.append(
|
||||||
f'<tr><td style="padding: 1px; min-width: {longest_name}ch;">{func["name"]}</td>'
|
f'<tr><td style="padding: 1px; min-width: {longest_name}ch;">{func["name"]}</td>'
|
||||||
f'<td style="padding: 1px; color: {hit_color}; font-weight: bold;">{func["hits"]}</td></tr>'
|
f'<td style="padding: 1px; color: {hit_color}; font-weight: bold;">{func["hits"]}</td></tr>'
|
||||||
)
|
)
|
||||||
|
|
||||||
lines.append('</tbody></table></div>') # Close collapsible div
|
lines.append('</tbody></table></div>') # Close collapsible div
|
||||||
|
|
||||||
lines.append('<h2>Source Code:</h2><table class="table table-bordered source-code-table "><thead><tr><th>Line</th><th>Hits</th><th>Code</th></tr></thead><tbody>')
|
lines.append('<h2>Source Code:</h2><table class="table table-bordered source-code-table "><thead><tr><th>Line</th><th>Hits</th><th>Code</th></tr></thead><tbody>')
|
||||||
|
|
||||||
for i, line in enumerate(source_code, start=1):
|
for i, line in enumerate(source_code, start=1):
|
||||||
stripped_line = line.strip()
|
stripped_line = line.strip()
|
||||||
class_name = "text-muted"
|
class_name = "text-muted"
|
||||||
if not stripped_line or stripped_line.startswith("end") or stripped_line.startswith("--"):
|
if not stripped_line or stripped_line.startswith("end") or stripped_line.startswith("--"):
|
||||||
count_display = "<span class='text-muted'>N/A</span>"
|
count_display = "<span class='text-muted'>N/A</span>"
|
||||||
lines.append(f'<tr><td>{i}</td><td>{count_display}</td><td>{line.strip()}</td>></tr>')
|
lines.append(f'<tr><td>{i}</td><td>{count_display}</td><td>{line.strip()}</td>></tr>')
|
||||||
else:
|
else:
|
||||||
count = coverage_data.get(i, 0)
|
count = coverage_data.get(i, 0)
|
||||||
class_name = "zero-hits" if count == 0 else "low-hits" if count < max_hits * 0.3 else "high-hits"
|
class_name = "zero-hits" if count == 0 else "low-hits" if count < max_hits * 0.3 else "high-hits"
|
||||||
count_display = f'{count}'
|
count_display = f'{count}'
|
||||||
marked_text = f'<span class={class_name}>{line.strip()}</span>'
|
marked_text = f'<span class={class_name}>{line.strip()}</span>'
|
||||||
lines.append(f'<tr><td>{i}</td><td>{count_display}</td><td>{marked_text}</td></tr>')
|
lines.append(f'<tr><td>{i}</td><td>{count_display}</td><td>{marked_text}</td></tr>')
|
||||||
|
|
||||||
lines.append("</tbody></table></body></html>")
|
lines.append("</tbody></table></body></html>")
|
||||||
|
|
||||||
with open(html_path, "w", encoding="utf-8") as f:
|
with open(html_path, "w", encoding="utf-8") as f:
|
||||||
f.write("\n".join(lines))
|
f.write("\n".join(lines))
|
||||||
|
|
||||||
def generate_index(files):
|
def generate_index(files):
|
||||||
"""Generates an index.html summarizing the coverage."""
|
"""Generates an index.html summarizing the coverage."""
|
||||||
index_html = [
|
index_html = [
|
||||||
"<html><head>",
|
"<html><head>",
|
||||||
'<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css">',
|
'<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.3.0/css/bootstrap.min.css">',
|
||||||
"</head><body>",
|
"</head><body>",
|
||||||
'<h1 class="text-center">Coverage Report</h1>',
|
'<h1 class="text-center">Coverage Report</h1>',
|
||||||
'<table class="table table-striped table-bordered"><thead><tr><th>File</th><th>Total Hits</th><th>Functions</th></tr></thead><tbody>'
|
'<table class="table table-striped table-bordered"><thead><tr><th>File</th><th>Total Hits</th><th>Functions</th></tr></thead><tbody>'
|
||||||
]
|
]
|
||||||
|
|
||||||
for filepath, data in files.items():
|
for filepath, data in files.items():
|
||||||
filename = os.path.basename(filepath)
|
filename = os.path.basename(filepath)
|
||||||
total_hits = sum(func["hits"] for func in data["functions"])
|
total_hits = sum(func["hits"] for func in data["functions"])
|
||||||
total_functions = len(data["functions"])
|
total_functions = len(data["functions"])
|
||||||
|
|
||||||
index_html.append(f'<tr><td><a href="{filename}.html">{filename}</a></td><td>{total_hits}</td><td>{total_functions}</td></tr>')
|
index_html.append(f'<tr><td><a href="{filename}.html">{filename}</a></td><td>{total_hits}</td><td>{total_functions}</td></tr>')
|
||||||
|
|
||||||
index_html.append("</tbody></table></body></html>")
|
index_html.append("</tbody></table></body></html>")
|
||||||
|
|
||||||
with open(os.path.join(OUTPUT_DIR, "index.html"), "w", encoding="utf-8") as f:
|
with open(os.path.join(OUTPUT_DIR, "index.html"), "w", encoding="utf-8") as f:
|
||||||
f.write("\n".join(index_html))
|
f.write("\n".join(index_html))
|
||||||
|
|
||||||
with open(LCOV_FILE, "r", encoding="utf-8") as f:
|
with open(LCOV_FILE, "r", encoding="utf-8") as f:
|
||||||
lcov_content = f.read()
|
lcov_content = f.read()
|
||||||
|
|
||||||
files_data = parse_lcov(lcov_content)
|
files_data = parse_lcov(lcov_content)
|
||||||
|
|
||||||
for file_path, data in files_data.items():
|
for file_path, data in files_data.items():
|
||||||
generate_file_html(file_path, data["coverage"], data["functions"])
|
generate_file_html(file_path, data["coverage"], data["functions"])
|
||||||
|
|
||||||
generate_index(files_data)
|
generate_index(files_data)
|
||||||
|
|
||||||
print(f"Coverage report generated in {OUTPUT_DIR}/index.html")
|
print(f"Coverage report generated in {OUTPUT_DIR}/index.html")
|
||||||
|
|
1002
tools/svg.py
1002
tools/svg.py
File diff suppressed because it is too large
Load diff
|
@ -1,24 +1,24 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"allowSyntheticDefaultImports": true,
|
"allowSyntheticDefaultImports": true,
|
||||||
"downlevelIteration": true,
|
"downlevelIteration": true,
|
||||||
"jsx": "react",
|
"jsx": "react",
|
||||||
"jsxFactory": "Roact.createElement",
|
"jsxFactory": "Roact.createElement",
|
||||||
"jsxFragmentFactory": "Roact.Fragment",
|
"jsxFragmentFactory": "Roact.Fragment",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"moduleResolution": "Node",
|
"moduleResolution": "Node",
|
||||||
"noLib": true,
|
"noLib": true,
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"target": "ESNext",
|
"target": "ESNext",
|
||||||
"typeRoots": [
|
"typeRoots": [
|
||||||
"node_modules/@rbxts"
|
"node_modules/@rbxts"
|
||||||
],
|
],
|
||||||
"rootDir": "lib",
|
"rootDir": "lib",
|
||||||
"outDir": "out",
|
"outDir": "out",
|
||||||
"baseUrl": "lib",
|
"baseUrl": "lib",
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"tsBuildInfoFile": "out/tsconfig.tsbuildinfo",
|
"tsBuildInfoFile": "out/tsconfig.tsbuildinfo",
|
||||||
"moduleDetection": "force"
|
"moduleDetection": "force"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
30
wally.toml
30
wally.toml
|
@ -1,15 +1,15 @@
|
||||||
[package]
|
[package]
|
||||||
name = "ukendio/jecs"
|
name = "ukendio/jecs"
|
||||||
version = "0.6.0"
|
version = "0.6.0"
|
||||||
registry = "https://github.com/UpliftGames/wally-index"
|
registry = "https://github.com/UpliftGames/wally-index"
|
||||||
realm = "shared"
|
realm = "shared"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
include = [
|
include = [
|
||||||
"default.project.json",
|
"default.project.json",
|
||||||
"jecs.luau",
|
"jecs.luau",
|
||||||
"wally.toml",
|
"wally.toml",
|
||||||
"README.md",
|
"README.md",
|
||||||
"CHANGELOG.md",
|
"CHANGELOG.md",
|
||||||
"LICENSE",
|
"LICENSE",
|
||||||
]
|
]
|
||||||
exclude = ["**"]
|
exclude = ["**"]
|
||||||
|
|
Loading…
Reference in a new issue