2025-04-11 12:27:29 -07:00
|
|
|
import bracket from '@public/kcl-samples/bracket/main.kcl?raw'
|
2023-09-15 22:37:40 -04:00
|
|
|
|
2025-04-11 12:27:29 -07:00
|
|
|
export { bracket }
|
2024-03-29 12:56:32 -04:00
|
|
|
|
2024-08-19 15:36:18 -04:00
|
|
|
/**
|
|
|
|
* @throws Error if the search text is not found in the example code.
|
|
|
|
*/
|
2024-03-29 12:56:32 -04:00
|
|
|
function findLineInExampleCode({
|
|
|
|
searchText,
|
|
|
|
example = bracket,
|
|
|
|
}: {
|
|
|
|
searchText: string
|
|
|
|
example?: string
|
|
|
|
}) {
|
|
|
|
const lines = example.split('\n')
|
|
|
|
const lineNumber = lines.findIndex((l) => l.includes(searchText)) + 1
|
|
|
|
if (lineNumber === 0) {
|
2024-08-19 15:36:18 -04:00
|
|
|
// We are exporting a constant, so we don't want to return an Error.
|
|
|
|
// eslint-disable-next-line suggest-no-throw/suggest-no-throw
|
2024-03-29 12:56:32 -04:00
|
|
|
throw new Error(
|
|
|
|
`Could not find the line with search text "${searchText}" in the example code. Was it removed?`
|
|
|
|
)
|
|
|
|
}
|
|
|
|
return lineNumber
|
|
|
|
}
|
|
|
|
export const bracketWidthConstantLine = findLineInExampleCode({
|
2024-12-06 16:04:17 -05:00
|
|
|
searchText: 'width =',
|
2024-03-29 12:56:32 -04:00
|
|
|
})
|
|
|
|
export const bracketThicknessCalculationLine = findLineInExampleCode({
|
2024-12-06 16:04:17 -05:00
|
|
|
searchText: 'thickness =',
|
2024-03-29 12:56:32 -04:00
|
|
|
})
|