python2ib
Version:
Convert Python code to IB Pseudocode format
61 lines • 1.83 kB
JavaScript
/**
* Configuration types for Python to IB Pseudocode conversion
*/
/** Default configuration */
export const DEFAULT_CONFIG = {
format: 'plain',
indentStyle: 'spaces',
indentSize: 4,
includeLineNumbers: false,
includeOriginalCode: false,
validateSyntax: true,
preserveEmptyLines: true,
strictMode: false,
normalizeIndentation: false,
variableMapping: {},
functionMapping: {},
preserveComments: true,
customOperators: {},
customKeywords: {},
outputOptions: {
includeLineNumbers: false,
includeComments: true,
wrapInCodeBlock: false
},
conversionRules: {
forceExplicitTypes: false,
convertFStrings: true,
expandCompoundAssignments: true,
simplifyExpressions: false
}
};
/** Merge user options with defaults */
export function mergeConfig(options) {
return {
...DEFAULT_CONFIG,
...options,
variableMapping: {
...DEFAULT_CONFIG.variableMapping,
...options?.variableMapping
},
functionMapping: {
...DEFAULT_CONFIG.functionMapping,
...options?.functionMapping
}
};
}
/** Validation for configuration options */
export function validateConfig(config) {
const errors = [];
if (config.indentSize !== undefined && (config.indentSize < 1 || config.indentSize > 8)) {
errors.push('indentSize must be between 1 and 8');
}
if (config.format && !['plain', 'markdown'].includes(config.format)) {
errors.push('format must be either "plain" or "markdown"');
}
if (config.indentStyle && !['spaces', 'tabs'].includes(config.indentStyle)) {
errors.push('indentStyle must be either "spaces" or "tabs"');
}
return errors;
}
//# sourceMappingURL=config.js.map