Skip to content

Add --compile flag to jsii-rosetta markdown command #4932

@pahud

Description

@pahud

Describe the feature

Add a --compile flag to the jsii-rosetta markdown command that enables TypeScript compilation and type checking for code snippets, similar to the existing extract command.

Use Case

The markdown command currently only does syntactic translation without type checking. This results in:

  • Less accurate translations due to missing type information
  • Undetected errors in documentation examples
  • Inconsistent behavior compared to the extract command which supports --compile

For projects like AWS CDK generating polyglot documentation, compilation would improve translation accuracy and catch errors in examples.

Proposed Solution

Add --compile and --fail flags to the markdown command, reusing the existing Translator class infrastructure:

# Enable compilation
npx jsii-rosetta markdown README.md --language python --compile

# Fail on compilation errors
npx jsii-rosetta markdown README.md --language python --compile --fail

Implementation would modify src/main.ts to add the CLI options and update src/commands/convert.ts to use the full Translator class instead of direct SnippetTranslator.

Other Information

  • Backwards compatible (compilation is opt-in)
  • Reuses existing compilation infrastructure
  • Aligns behavior with other jsii-rosetta commands
  • Improves documentation quality through type checking

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

N/A (jsii-rosetta feature)

Environment details

macOS, Node.js, TypeScript

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestA feature should be added or improved.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions