Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Primitive table vis #67

Merged
merged 9 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion .github/workflows/upload_indexhtml.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ name: Deploy static content to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ["main", "primitive_table_vis"]
branches: ["main"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -31,6 +31,30 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
-
name: 'Install packages for generator'
run: |
sudo apt-get update
sudo apt-get install graphviz-dev util-linux
-
name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
-
name: 'Install python dependencies for generator'
run: |
python -m pip install --upgrade pip
pip3 install ruff
if [ -f requirements.txt ]; then pip3 install -r requirements.txt; fi
-
name: Try generating the whole TSL with python ${{ matrix.python-version }}
id: generate
continue-on-error: true
run: |
python main.py --print-outputs-only
- name: Setup Pages
uses: actions/configure-pages@v3
- name: Upload artifact
Expand Down
Binary file added doc/media/tsl_logo_small.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions generator/config/default_conf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ configuration:
primitive_definitions: "definitions"
silent_warnings: ["-Wno-ignored-attributes", "-Wno-attributes"]
expansions:
primitive_vis:
enabled: True
template_path: "generator/config/generator/tsl_templates/expansions/primitive_table.template"
target_path: "./index.html"
cmake:
enabled: True
minimum_version: "3.13"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {font-family: sans-serif;}
.checkmark {
display: inline-block;
transform: rotate(45deg);
height: 12px;
width: 5px;
border-bottom: 6px solid #78b13f;
border-right: 5px solid #78b13f;
}
.dot_yes {
height: 25px;
width: 25px;
background-color: rgb(51, 208, 51);
border-radius: 50%;
display: inline-block;
}
.dot_no {
height: 25px;
width: 25px;
background-color: rgb(187, 40, 40);
border-radius: 50%;
display: inline-block;
}
.avail {
color: rgb(51, 208, 51);
font-weight: bolder;
font-size: 15pt;
}
.no_avail {
color: rgb(187, 40, 40);
font-weight: bold;
font-size: 15pt;
}
.primitive {
overflow: hidden;
border: 1px dashed #ccc;
background-color: #f1f1f1;
}
.primitive button {
background-color: inherit;
float: left;
border: none;
outline: none;
cursor: pointer;
padding: 14px 16px;
transition: 0.3s;
font-size: 17px;
text-align: left;
width: 100%;
}
.primitive button:hover {
background-color: #ddd;
}
.primitive button.active {
background-color: #ccc;
}
.primitiveinfo {
display: none;
padding: 14px 16px;
border: 1px solid #ccc;
}
.container{
margin: 20px auto;
width:98%;
height:100%;
background-color:#fff;
display:grid;
grid-template-columns: 250px auto;
grid-column-gap: 20px;
grid-row-gap: 20px;
.box{
padding:20px;
border-radius:10px;
border: 1px solid #ccc;
color:#000;
align-items:center;
font-family:sans-serif;
}
.corner {
padding:20px;
border-radius:10px;
color:#000;
align-items:center;
font-family:sans-serif;
}
.search {
padding:20px;
border-radius:10px;
color:#000;
font-family:sans-serif;
bottom: 0;
align-self: end;
}
.bar {
min-width: 250px;
width:100%;
}
}
.resetButton {
background-image: linear-gradient(#f7f8fa ,#e7e9ec);
border-color: #adb1b8 #a2a6ac #8d9096;
border-style: solid;
border-width: 1px;
border-radius: 3px;
box-shadow: rgba(255,255,255,.6) 0 1px 0 inset;
box-sizing: border-box;
color: #0f1111;
cursor: pointer;
display: inline-block;
font-family: sans-serif;
font-size: 14px;
height: 29px;
font-size: 13px;
outline: 0;
overflow: hidden;
padding: 0 11px;
text-align: center;
text-decoration: none;
text-overflow: ellipsis;
user-select: none;
-webkit-user-select: none;
touch-action: manipulation;
white-space: nowrap;
}

.resetButton:active {
border-bottom-color: #a2a6ac;
}

.resetButton:active:hover {
border-bottom-color: #a2a6ac;
}

.resetButton:hover {
border-color: #a2a6ac #979aa1 #82858a;
}

</style>
</head>
<body>
<div class="container">
<div class="corner"><img src="./doc/media/tsl_logo_small.png" width="120%"></div>
<div class="search"><input class="bar" type="text" id="primitiveFilterInput" onkeyup="filterPrimitives()" placeholder="Search primitives by name or keywords in their brief description"></div>
<div class="box">Check to filter by primitive category. If all are unchecked, no filters are applied.<br><br>---filterBoxes---<br><button class="resetButton" role="button" onclick="resetBoxesAndSearch()">Reset</button></div>
<div class="box">---content---</div>
</div>
<script>
function togglePrimitive(evt, primName) {
if (document.getElementById(primName).style.display == "block") {
button = document.getElementById(primName + "_link");
button.className = button.className.replace(" active", "");
document.getElementById(primName).style.display = "none";
} else {
document.getElementById(primName).style.display = "block";
evt.currentTarget.className += " active";
}
}
function filterPrimitives() {
var input, filterPredicate, primContainer;
input = document.getElementById('primitiveFilterInput');
filterPredicate = input.value.toUpperCase();
primContainer = document.getElementsByClassName("primitiveContainer");
for (var i = 0; i < primContainer.length; i++) {
var primitive = primContainer[i].getElementsByTagName("button")[0];
var descr = primContainer[i].getElementsByClassName("description")[0].textContent;
var found_match = 0
txtValue = primitive.textContent;
if (txtValue.toUpperCase().indexOf(filterPredicate) > -1) {
found_match += 1
}
keywordsFound = 0
txtKeywords = filterPredicate.split(" ").filter(n=>n)
for ( keyword of txtKeywords ) {
if (descr.toUpperCase().indexOf(keyword) > -1) {
keywordsFound += 1
}
}
if ( keywordsFound === txtKeywords.length) {
found_match += 1
}
if (found_match > 0) {
primContainer[i].style.display = "";
} else {
primContainer[i].style.display = "none";
}
}
}
function filterByCheckbox() {
var primCategories = document.getElementsByClassName('primitiveCategory');
var checkboxes = document.getElementsByClassName('primitiveClassSelector');
var checked_boxes = [];
for (var i = 0; i < checkboxes.length; i++) {
if (checkboxes[i].checked) { checked_boxes.push(checkboxes[i]); }
}
console.log("checkedboxes:",checked_boxes.length," All Count:", checkboxes.length);
// If all are unchecked, we do not filter
if ( checked_boxes.length == 0 ) {
console.log("All unchecked.");
for ( category of primCategories ) {
category.style.display = '';
}
} else {
for ( category of primCategories ) {
category.style.display = 'none';
for (checkbox of checked_boxes) {
if ( checkbox.value == category.id ) {category.style.display = '';}
}
}
}
}
function resetBoxesAndSearch(){
var checkboxes = document.getElementsByClassName('primitiveClassSelector');
for ( checkbox of checkboxes ) { checkbox.checked = false; }
input = document.getElementById('primitiveFilterInput');
input.value = "";
filterByCheckbox();
filterPrimitives();
}
</script>
</body>
</html>
1 change: 1 addition & 0 deletions generator/core/tsl_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ def parse_args(**kwargs) -> dict:
help="", metavar="ExOutPath")

parser.add_argument('--generate-readme-files', dest='configuration:expansions:readme_md:enabled', action="store_true", required=False, help="Add README.md generation step.")
parser.add_argument('--generate-index-html', dest='configuration:expansions:primitive_vis:enabled', action="store_false", required=False, help="Add README.md generation step.")

parser.add_argument('--no-debug-info', dest='configuration:debug_generator', action='store_false', required=False)
add_bool_arg(parser, 'workaround-warnings', 'configuration:emit_workaround_warnings', "Enable ", "Disable ", True, help='workaround warnings', required=False)
Expand Down
5 changes: 5 additions & 0 deletions generator/core/tsl_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from pathlib import Path
from typing import List


from generator.core.ctrl.tsl_libfile_generator import TSLFileGenerator
from generator.expansions.tsl_cmake import TSLCMakeGenerator
from generator.core.ctrl.tsl_lib import TSLLib
Expand All @@ -17,6 +18,7 @@
from generator.utils.log_utils import LogInit
from generator.utils.requirement import requirement
from generator.utils.yaml_utils import yaml_load, yaml_load_all, yaml_store
from parseForPrimitiveTable import create_primitive_index_html


class TSLGenerator:
Expand Down Expand Up @@ -188,6 +190,9 @@ def generate(self, relevant_hardware_flags: List[str] = None, relevant_primitive

lib: TSLLib = TSLLib(relevant_extensions_set, relevant_primitives_class_set)

if config.expansion_enabled("primitive_vis"):
create_primitive_index_html(lib)

dep_graph = TSLDependencyGraph(lib)
if not dep_graph.is_acyclic():
self.log(logging.ERROR, "Dependency graph for primitive definitions is not acyclic. Please check your dependencies.")
Expand Down
Loading
Loading