Skip to content

Conversation

@httpdss
Copy link
Owner

@httpdss httpdss commented Jul 26, 2025

Description

This PR adds a new generate-schema command that generates JSON schema definitions for available structure templates.

Features

  • New Command: struct generate-schema command
  • Flexible Input: Supports scanning built-in contribs directory and custom structures path
  • Output Options: Can output to stdout or save to a specified file
  • JSON Schema Generation: Creates a properly formatted JSON schema with PluginList enum

Usage

# Generate schema to stdout
struct generate-schema

# Generate schema with custom structures path
struct generate-schema -s /path/to/structures

# Save schema to file
struct generate-schema -o schema.json

# Combine custom path and output file
struct generate-schema -s /path/to/structures -o schema.json

Implementation Details

  • Scans YAML files in the contribs directory and optional custom structures path
  • Removes file extensions and creates relative paths for structure names
  • Generates JSON schema with sorted enum values for consistency
  • Includes proper error handling and logging
  • Creates output directories if they don't exist

Files Changed

  • struct_module/commands/generate_schema.py - New command implementation
  • struct_module/main.py - Updated to register the new command
  • docs/generate-schema.md - Added documentation for the new command

This enhancement makes it easier for users and tools to discover available structure templates programmatically.

- Implement GenerateSchemaCommand class to generate JSON schema for available structures
- Add command line arguments for structures path and output file
- Scan both contribs directory and custom structures path
- Generate JSON schema with PluginList enum containing all available structures
- Support output to file or stdout
- Add documentation for the generate-schema command
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 60.20%. Comparing base (d2c4cd5) to head (60343c1).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #63   +/-   ##
=======================================
  Coverage   60.20%   60.20%           
=======================================
  Files          21       21           
  Lines         980      980           
  Branches      141      141           
=======================================
  Hits          590      590           
  Misses        365      365           
  Partials       25       25           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

httpdss added 3 commits July 26, 2025 14:43
- Add generate-schema command to subcommands list in both English and Spanish READMEs
- Add comprehensive documentation section for generate-schema command with usage examples
- Include command options and use cases for the new functionality
- Fix markdown linting issue with missing language specification for code blocks
- Provide Spanish translation of all new documentation content
- Fix comprehensive mock setup for os.path functions to avoid NoneType errors
- Implement proper mock_join_side_effect to handle path construction correctly
- Update mock_relpath_side_effect to return proper file paths with extensions
- Correct mock_exists_side_effect logic for file output directory creation tests
- Ensure all tests properly simulate filesystem behavior with complete mocking
- All 8 generate_schema tests now passing successfully

Test coverage includes:
- Command initialization and argument parsing
- stdout output with multiple structures and subdirectories
- file output with directory creation
- custom structures path handling
- nonexistent path graceful handling
- empty directory handling
@httpdss httpdss self-assigned this Jul 26, 2025
@httpdss httpdss added enhancement New feature or request minor labels Jul 26, 2025
@httpdss httpdss moved this to In Progress in struct-mainboard Jul 26, 2025
@httpdss httpdss merged commit fe908bc into main Jul 26, 2025
2 checks passed
@httpdss httpdss deleted the feature/generate-schema-command branch July 26, 2025 16:05
@github-project-automation github-project-automation bot moved this from In Progress to Done in struct-mainboard Jul 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request minor

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants