MCPcopy Index your code
hub / github.com/deepnote/deepnote / analyzeNotebook

Function analyzeNotebook

packages/cli/src/utils/analysis.ts:628–658  ·  view source on GitHub ↗
(notebook: DeepnoteFile['project']['notebooks'][number])

Source from the content-addressed store, hash-verified

626// ============================================================================
627
628function analyzeNotebook(notebook: DeepnoteFile['project']['notebooks'][number]): NotebookStats {
629 const blockTypesMap = new Map<string, { count: number; loc: number }>()
630 let totalLoc = 0
631
632 for (const block of notebook.blocks) {
633 const loc = countLinesOfCode(block)
634 totalLoc += loc
635
636 const existing = blockTypesMap.get(block.type) ?? { count: 0, loc: 0 }
637 blockTypesMap.set(block.type, {
638 count: existing.count + 1,
639 loc: existing.loc + loc,
640 })
641 }
642
643 const blockTypes: BlockTypeStats[] = Array.from(blockTypesMap.entries())
644 .map(([type, stats]) => ({
645 type,
646 count: stats.count,
647 linesOfCode: stats.loc,
648 }))
649 .sort((a, b) => b.count - a.count)
650
651 return {
652 name: notebook.name,
653 id: notebook.id,
654 blockCount: notebook.blocks.length,
655 linesOfCode: totalLoc,
656 blockTypes,
657 }
658}
659
660/**
661 * Count lines of code in a block's content.

Callers 1

computeProjectStatsFunction · 0.85

Calls 1

countLinesOfCodeFunction · 0.85

Tested by

no test coverage detected