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

Function printBlocks

packages/cli/src/commands/cat.ts:157–186  ·  view source on GitHub ↗

* Print blocks to stdout with formatting.

(
  absolutePath: string,
  notebooks: DeepnoteFile['project']['notebooks'],
  options: CatOptions
)

Source from the content-addressed store, hash-verified

155 * Print blocks to stdout with formatting.
156 */
157async function printBlocks(
158 absolutePath: string,
159 notebooks: DeepnoteFile['project']['notebooks'],
160 options: CatOptions
161): Promise<void> {
162 const chalk = getChalk()
163 output(chalk.dim(`File: ${absolutePath}`))
164 output('')
165
166 for (let i = 0; i < notebooks.length; i++) {
167 const notebook = notebooks[i]
168 const filteredBlocks = filterBlocks(notebook.blocks, options)
169
170 // Add divider between notebooks (not before the first one)
171 if (i > 0) {
172 output('')
173 output(chalk.cyan('═'.repeat(60)))
174 output('')
175 }
176
177 output(chalk.bold.cyan(`Notebook: ${notebook.name}`))
178 output(chalk.dim(` ID: ${notebook.id}`))
179 output(chalk.dim(` Blocks: ${filteredBlocks.length}`))
180 output('')
181
182 for (const block of filteredBlocks) {
183 await printBlock(block, options)
184 }
185 }
186}
187
188/**
189 * Print a single block with formatting.

Callers 1

catDeepnoteFileFunction · 0.85

Calls 4

getChalkFunction · 0.90
outputFunction · 0.90
filterBlocksFunction · 0.85
printBlockFunction · 0.85

Tested by

no test coverage detected