From 110791ff4550a803304c5f6513c53ef9bb60924d Mon Sep 17 00:00:00 2001 From: Egutierrez Date: Fri, 15 May 2026 15:06:06 +0200 Subject: [PATCH] scaffolder: auto-wire fn_table_viz in new C++ apps (issue 0081-M) - CMakeLists.txt template: adds target_link_libraries fn_table_viz with if(TARGET fn_table_viz) guard (compiles even without vendor/lua). - main.cpp template: adds commented include + data_table::render() panel block in render(). Also fixes include to use app_base.h + panel_menu.h (matching convention of chart_demo, shaders_lab). - app.md template: uses_functions lists all 12 fn_table_viz stack IDs commented out; uncomment when activating data_table::render(). - Bump version 0.1.0 -> 1.1.0. Add capability growth log entry. - Tag cpp-tables added to capability group. - Verified: test app test_scaffolder_default compiled clean, residues removed (dir + CMakeLists entry). Co-Authored-By: Claude Sonnet 4.6 --- bash/functions/pipelines/init_cpp_app.md | 36 +++++++++++++++++++----- bash/functions/pipelines/init_cpp_app.sh | 30 ++++++++++++++++++-- 2 files changed, 57 insertions(+), 9 deletions(-) diff --git a/bash/functions/pipelines/init_cpp_app.md b/bash/functions/pipelines/init_cpp_app.md index 2d149c6a..67810c12 100644 --- a/bash/functions/pipelines/init_cpp_app.md +++ b/bash/functions/pipelines/init_cpp_app.md @@ -3,11 +3,11 @@ name: init_cpp_app kind: pipeline lang: bash domain: pipelines -version: "0.1.0" +version: "1.1.0" purity: impure signature: "init_cpp_app(name: string, [--project

] [--domain ] [--desc ] [--tags ]) -> void" description: "Scaffolder estandar de apps C++ del registry. Genera main.cpp + CMakeLists.txt + app.md siguiendo el patron canonico (cfg.about/log/panels, sin app_menubar manual, dockspace via framework), registra la app en cpp/CMakeLists.txt, inicializa repo Gitea dataforge/ y ejecuta fn index." -tags: [cpp, imgui, scaffold, pipeline, bash, launcher] +tags: [cpp, imgui, scaffold, pipeline, bash, launcher, cpp-tables] uses_functions: - ensure_repo_synced_bash_infra uses_types: [] @@ -47,9 +47,9 @@ fn run init_cpp_app finance_panel --project budget --desc "Panel de finanzas" -- ```

/ - main.cpp # Plantilla canonica: panels[] + cfg.about + cfg.log + run_app(cfg, render) - CMakeLists.txt # add_imgui_app( main.cpp) - app.md # Frontmatter completo (lang:cpp, framework:imgui, dir_path, repo_url) + main.cpp # Plantilla canonica: panels[] + cfg.about + cfg.log + run_app(cfg, render) + data_table comentado + CMakeLists.txt # add_imgui_app( main.cpp) + target_link_libraries fn_table_viz (con guard) + app.md # Frontmatter completo (lang:cpp, framework:imgui, dir_path, repo_url) + uses_functions comentados ``` Y ademas: @@ -66,9 +66,31 @@ La plantilla cumple `cpp/PATTERNS.md`: - NO llama `DockSpaceOverViewport` (auto_dockspace=true por defecto). - Declara `panels[]` con un panel "Main" toggleable. - Setea `cfg.about` (window About) y `cfg.log` (logger + ventana Logs). +- Include `viz/data_table.h` comentado + panel "Data" comentado en `render()` — descomentar para activar `data_table::render()`. + +## Activar data_table::render() + +1. En `main.cpp`: descomentar `#include "viz/data_table.h"` y el bloque del panel Data en `render()`. +2. En `app.md`: descomentar los 12 IDs del stack `fn_table_viz` en `uses_functions`. +3. El `CMakeLists.txt` ya linka `fn_table_viz` via guard `if(TARGET fn_table_viz)` — sin cambio manual. +4. Poblar `data_tables` con tus `data_table::TableInput` y el panel aparece en el DockSpace. + +## Cuando usarla + +Cuando necesites crear una app C++ nueva que siga el patron canonico del registry. Es el unico camino autorizado para crear apps en `cpp/apps/` o `projects/*/apps/` — nunca escribir `main.cpp` + `CMakeLists.txt` a mano. + +## Gotchas + +- Si `GITEA_URL`/`GITEA_TOKEN` no estan seteados, solo hace `git init` local (no crea repo remoto). +- `fn_table_viz` requiere que `vendor/lua` este presente en `cpp/`; el guard `if(TARGET fn_table_viz)` evita errores de link si no esta disponible. +- El bloque de `uses_functions` en `app.md` queda comentado intencionalmente — descomenta solo las funciones que la app realmente use para mantener el grafo de dependencias limpio. ## Despues de crear -1. Editar `app.md` y completar `uses_functions` cuando la app consuma funciones del registry. -2. Anadir las funciones del registry al `CMakeLists.txt` como paths absolutos: `${CMAKE_SOURCE_DIR}/functions//.cpp`. +1. Si usas `data_table::render()`: descomentar include + panel en `main.cpp`, descomentar IDs en `app.md`, ejecutar `fn index`. +2. Para otras funciones del registry: anadir paths absolutos en `CMakeLists.txt` y los IDs en `uses_functions` de `app.md`. 3. Build: `cd cpp && cmake --build build --target -j`. + +## Capability growth log + +v1.1.0 (2026-05-15) — Auto-wires fn_table_viz; new apps get target_link_libraries + commented data_table template. diff --git a/bash/functions/pipelines/init_cpp_app.sh b/bash/functions/pipelines/init_cpp_app.sh index 489c8260..6d4fa7db 100755 --- a/bash/functions/pipelines/init_cpp_app.sh +++ b/bash/functions/pipelines/init_cpp_app.sh @@ -69,9 +69,11 @@ init_cpp_app() { # ---------- main.cpp ---------- cat > "$abs_dir/main.cpp" < -#include "framework/app_base.h" +#include "app_base.h" +#include "core/panel_menu.h" #include "core/icons_tabler.h" #include "core/logger.h" +// #include "viz/data_table.h" // uncomment to enable data_table::render() panel // Toggles de paneles (visibles desde el menu View del menubar canonico) static bool g_show_main = true; @@ -90,6 +92,11 @@ static void render() { // DockSpaceOverViewport central (auto_dockspace=true por defecto). // Aqui solo se dibujan los paneles propios de la app. if (g_show_main) draw_main(); + + // === Data panel (uncomment to enable) === + // static data_table::State data_state; + // static std::vector data_tables; // populate from your source + // data_table::render("main_data", data_tables, data_state); } int main(int /*argc*/, char** /*argv*/) { @@ -115,6 +122,12 @@ add_imgui_app($name ) target_include_directories($name PRIVATE \${CMAKE_CURRENT_SOURCE_DIR}) +# fn_table_viz: provides data_table::render(), viz_render, TQL engine, Lua, LLM. +# Guard keeps the app compilable in builds where vendor/lua is absent. +if(TARGET fn_table_viz) + target_link_libraries($name PRIVATE fn_table_viz) +endif() + if(WIN32) set_target_properties($name PROPERTIES WIN32_EXECUTABLE TRUE) endif() @@ -135,7 +148,20 @@ lang: cpp domain: $domain description: "$desc" tags: $tags_yaml -uses_functions: [] +uses_functions: + # Uncomment when using data_table::render() — provided via fn_table_viz: + # - data_table_cpp_viz + # - viz_render_cpp_viz + # - compute_stage_cpp_core + # - compute_pipeline_cpp_core + # - compute_column_stats_cpp_core + # - auto_detect_type_cpp_core + # - tql_emit_cpp_core + # - tql_apply_cpp_core + # - lua_engine_cpp_core + # - join_tables_cpp_core + # - tql_to_sql_cpp_core + # - llm_anthropic_cpp_core uses_types: [] framework: "imgui" entry_point: "main.cpp"