Skip to content

Replace mock functions with production implementations#18

Merged
kayodebristol merged 3 commits intomainfrom
copilot/implement-mock-functions
Nov 14, 2025
Merged

Replace mock functions with production implementations#18
kayodebristol merged 3 commits intomainfrom
copilot/implement-mock-functions

Conversation

Copy link
Contributor

Copilot AI commented Nov 13, 2025

Description

Removed placeholder implementations and integrated production-ready parsers and template rendering. The template engine was using Eta syntax while configs specified Handlebars, and the FSM parser was returning hard-coded demo data.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Other (please describe):

Changes Made

Template Engine

  • Replaced Eta with Handlebars to match configuration syntax ({{}} instead of <%= %>)
  • Templates now render variables and loops correctly

FSM Parser

  • Removed fakeParseMachines placeholder
  • Implemented runtime-based parser that dynamically imports TypeScript/JavaScript files
  • Extracts state machines from exported objects with nested state support
  • Handles both Deno and Node.js environments with proper path resolution

Binary File Support

  • Added writeBinaryFile method to FSLike interface
  • Integrated PNG export logic (infrastructure ready for future renderer)
  • Note: toPng returns null per roadmap - PNG export planned for v1.1.0+

Example:

// Before: Hard-coded demo machine
function fakeParseMachines() {
  return Promise.resolve([{ name: "demoMachine", ... }]);
}

// After: Real parser extracts from files
export const shoppingCartMachine = {
  id: 'shoppingCart',
  states: { empty: {...}, active: {...} }
};
// Parser automatically discovers and processes all exported machines

Testing

  • Tested with Deno runtime
  • Tested with Node.js runtime (if applicable)
  • Ran deno task gen successfully
  • Ran deno lint (noted any acceptable errors)
  • Ran deno check mod.ts

Verified with traffic light example (simple) and shopping cart example (nested states). Generated documentation includes proper state pages, transitions, and Mermaid diagrams.

Architectural Decision Record (ADR)

  • This change requires an ADR
    • ADR has been created and included in docs/adr/
    • ADR index has been updated in docs/adr/README.md
  • This change does not require an ADR

Documentation

  • Documentation has been updated (if needed)
  • README updated (if needed)
  • CONTRIBUTING.md updated (if needed)
  • No documentation changes needed

Breaking Changes

None. Maintains backward compatibility with existing configurations.

Related Issues

Fixes #17

Additional Notes

Security: CodeQL scan passed with 0 vulnerabilities

Files Modified:

  • src/tpl.ts - Handlebars integration
  • src/parser.ts - New FSM parser
  • src/generate.ts - Parser integration
  • runtime.ts - Binary file write support
  • src/fsm/example.machine.ts - Test fixture

Checklist

  • My code follows the project's coding standards
  • I have performed a self-review of my own code
  • I have commented my code where necessary
  • My changes generate no new warnings
  • I have updated the documentation accordingly
  • My changes maintain compatibility with both Deno and Node.js (where applicable)

Original prompt

This section details on the original issue you should resolve

<issue_title>Search and destroy mock functions</issue_title>
<issue_description>Fully implement mock/placeholder functions with carefully developed solutions</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits November 13, 2025 00:58
- Replaced Eta template engine with Handlebars to match config syntax
- Implemented real FSM parser that extracts machines from TypeScript/JavaScript files
- Parser uses runtime imports to extract machine definitions
- Supports nested states and transitions
- Tested with shopping cart example - successfully generates documentation

Co-authored-by: kayodebristol <3579196+kayodebristol@users.noreply.github.com>
- Added writeBinaryFile method to FSLike interface
- Implemented writeBinaryFile for both Deno and Node.js
- Added PNG export logic in generate.ts (calls toPng when exportPng is enabled)
- Created example traffic light machine for testing
- Fixed linter issues (unused parameter, import prefix)
- Updated .gitignore to exclude test output

Co-authored-by: kayodebristol <3579196+kayodebristol@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement mock functions with developed solutions Replace mock functions with production implementations Nov 13, 2025
Copilot AI requested a review from kayodebristol November 13, 2025 01:07
@kayodebristol kayodebristol marked this pull request as ready for review November 14, 2025 00:31
@kayodebristol kayodebristol merged commit 82e70c7 into main Nov 14, 2025
6 checks passed
@kayodebristol kayodebristol deleted the copilot/implement-mock-functions branch November 14, 2025 00:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Search and destroy mock functions

2 participants