Skip to content

Commit

Permalink
chore: add Type deprecation to schemata script
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-alford committed Feb 13, 2023
1 parent 7be43b5 commit 054290a
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions scripts/generate-schemables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,16 @@ const makeSchemableExtContents: (
),
),

instanceComment('1.0.0'),
instanceComment('Schemable', '1.0.0'),
makeSchemableExtTypeclass(schemables, ''),

instanceComment('1.0.0'),
instanceComment('Schemable', '1.0.0'),
makeSchemableExtTypeclass(schemables, '1'),

instanceComment('1.0.0'),
instanceComment('Schemable', '1.0.0'),
makeSchemableExtTypeclass(schemables, '2'),

instanceComment('1.0.0'),
instanceComment('Schemable', '1.0.0'),
makeSchemableExtTypeclass(schemables, '2C'),
],
_.createNodeArray,
Expand Down Expand Up @@ -156,6 +156,7 @@ export type SchemableTypeclasses =
| SchemableTypeclass<'Arbitrary', 'Arb', 'SchemableExt1', '1.0.0'>
| SchemableTypeclass<'Printer', 'P', 'SchemableExt2', '1.1.0'>
| SchemableTypeclass<'JsonSchema', 'JS', 'SchemableExt2', '1.2.0'>
| SchemableTypeclass<'Schemable', '_', 'SchemableExt2', '1.0.0'>

// #region Typeclass modules

Expand All @@ -164,11 +165,18 @@ export const moduleHeaderComment: (module: string, version: string) => ts.JSDoc
version,
) =>
_.createJSDocComment(
`SchemableExt instances for ${module}\n\n**Warning: DO NOT EDIT, this module is autogenerated**\n\n@since ${version}`,
`SchemableExt instances for ${module}\n\n**Warning: DO NOT EDIT, this module is autogenerated**\n\n${
module === 'Type' ? `@deprecated\n` : ''
}@since ${version}`,
)

export const instanceComment: (version: SchemableTypeclasses[3]) => ts.JSDoc = verision =>
_.createJSDocComment(`@since ${verision}\n@category Instances`)
export const instanceComment: (
module: SchemableTypeclasses[0],
version: SchemableTypeclasses[3],
) => ts.JSDoc = (module, version) =>
_.createJSDocComment(
`${module === 'Type' ? '@deprecated\n' : ''}@since ${version}\n@category Instances`,
)

const makeInstanceTypeExport: (tc: SchemableTypeclasses) => ts.ExportDeclaration = ([
typeclassName,
Expand All @@ -183,7 +191,9 @@ const makeInstanceTypeExport: (tc: SchemableTypeclasses) => ts.ExportDeclaration
ts.addSyntheticLeadingComment(
_.createExportSpecifier(false, undefined, _.createIdentifier(typeclassName)),
ts.SyntaxKind.MultiLineCommentTrivia,
`* @since ${version}\n\n@category Model`,
`* ${
typeclassName === 'Type' ? '@deprecated\n' : ''
}@since ${version}\n\n@category Model`,
true,
),
]),
Expand Down Expand Up @@ -263,7 +273,9 @@ const makeInterpreter: (typeclass: SchemableTypeclasses) => ts.VariableStatement
),
),
ts.SyntaxKind.MultiLineCommentTrivia,
`* @since ${version}\n\n@category Interpreters`,
`* ${
module === 'Type' ? '@deprecated\n' : ''
}@since ${version}\n\n@category Interpreters`,
true,
)

Expand Down Expand Up @@ -299,7 +311,7 @@ const makeSchemableInstanceModuleContents: (
),
),
makeInstanceTypeExport(typeclass),
instanceComment(sinceVersion),
instanceComment(module, sinceVersion),
makeSchemableInstance(typeclass, schemables),
makeInterpreter(typeclass),
],
Expand Down

0 comments on commit 054290a

Please sign in to comment.